music 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/.rubocop.yml +72 -0
- data/.rubocop_todo.yml +47 -0
- data/.travis.yml +5 -4
- data/CHANGELOG.md +15 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +90 -51
- data/Guardfile +8 -21
- data/README.md +4 -0
- data/Rakefile +7 -8
- data/lib/music/chord.rb +34 -31
- data/lib/music/note.rb +60 -70
- data/lib/music/version.rb +1 -1
- data/lib/music.rb +0 -1
- data/music.gemspec +13 -13
- data/spec/classes/chord_spec.rb +59 -59
- data/spec/classes/note_spec.rb +295 -286
- data/spec/spec_helper.rb +1 -1
- data/spec/support/matchers/have_an_interval.rb +2 -2
- metadata +18 -16
checksums.yaml
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
|
|
5
|
-
data.tar.gz: !binary |-
|
|
6
|
-
MTNmNjM2NjRiMzYyODcyMTYxNzRjZjA0YTlhMjM1ZTgwN2M2ODQ3YQ==
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 233bb144abfc81d9816b2136296a16c25a33b72a23c571d3e010fd947c8d8dda
|
|
4
|
+
data.tar.gz: 0ac2263fd0357000ee6c2a804bf6d44d5c37036b65403e36d5d066e8f521fe99
|
|
7
5
|
SHA512:
|
|
8
|
-
metadata.gz:
|
|
9
|
-
|
|
10
|
-
MWIwMzA5OWY4ZmFiNDY0NTNhY2Y2NmUzMmM0MDM0NjI2OTYwN2E5YmViYTM0
|
|
11
|
-
MWE4ODNiMGU0NTVmZDljNzE2ZjQyMzgwMzViMDQ1NDc5ZDdiM2U=
|
|
12
|
-
data.tar.gz: !binary |-
|
|
13
|
-
ZGQ0ZWE2ODNhOGFmMzg1YTJmNTZhOThlOTNmNmY5NjYwNGU3NGUwMDJlNDU2
|
|
14
|
-
NWE1NWM5ZDlkMmJjOGE2MGE3MTdiM2U4ODc2MmQ1NDRmYzYyMzMwNGY0ZjE4
|
|
15
|
-
ZmM3MDU0MTdhZDZlNGIzYjYxOTE3ZjU1ZDA0NzU3ZjRiMmJjYTI=
|
|
6
|
+
metadata.gz: 42e298406270084a5d7b0f544c699b94d1354c1b8751e4e910cb4a69ddf1c373e2288531520ae59f4987fb6527a5c2e7c8a32f1cfd1ef8c0c5f79582bc77e3bd
|
|
7
|
+
data.tar.gz: 2fc2e7fdb4f756f11cb20799434a5676f2f6506bfa155a1c5e419a41dfc9c5bf701fd29cf5b32605b01a356e9627140da49629a70d9ff13a8f5eea8152b8dc2a
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
#---------------------------
|
|
6
|
+
# Style configuration
|
|
7
|
+
#---------------------------
|
|
8
|
+
|
|
9
|
+
# Cop supports --auto-correct.
|
|
10
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
11
|
+
Style/HashSyntax:
|
|
12
|
+
Enabled: true
|
|
13
|
+
EnforcedStyle: ruby19
|
|
14
|
+
|
|
15
|
+
# Cop supports --auto-correct.
|
|
16
|
+
Style/SpaceInsideHashLiteralBraces:
|
|
17
|
+
Enabled: true
|
|
18
|
+
EnforcedStyle: no_space
|
|
19
|
+
|
|
20
|
+
# I think this one is broken...
|
|
21
|
+
Style/FileName:
|
|
22
|
+
Enabled: false
|
|
23
|
+
|
|
24
|
+
#---------------------------
|
|
25
|
+
# Don't intend to fix these:
|
|
26
|
+
#---------------------------
|
|
27
|
+
|
|
28
|
+
# Cop supports --auto-correct.
|
|
29
|
+
# Reason: Double spaces can be useful for grouping code
|
|
30
|
+
Style/EmptyLines:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
# Cop supports --auto-correct.
|
|
34
|
+
# Reason: I have very big opinions on this one. See:
|
|
35
|
+
# https://github.com/bbatsov/ruby-style-guide/issues/329
|
|
36
|
+
# https://github.com/bbatsov/ruby-style-guide/pull/325
|
|
37
|
+
Style/NegatedIf:
|
|
38
|
+
Enabled: false
|
|
39
|
+
|
|
40
|
+
# Cop supports --auto-correct.
|
|
41
|
+
# Reason: I'm fine either way on this, but could maybe be convinced that this should be enforced
|
|
42
|
+
Style/Not:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# Cop supports --auto-correct.
|
|
46
|
+
# Reason: I'm fine with this
|
|
47
|
+
Style/PerlBackrefs:
|
|
48
|
+
Enabled: false
|
|
49
|
+
|
|
50
|
+
# Configuration parameters: Methods.
|
|
51
|
+
# Reason: We should be able to specify full variable names, even if it's only one line
|
|
52
|
+
Style/SingleLineBlockParams:
|
|
53
|
+
Enabled: false
|
|
54
|
+
|
|
55
|
+
# Reason: Switched `extend self` to `module_function` in id_property.rb but that caused errors
|
|
56
|
+
Style/ModuleFunction:
|
|
57
|
+
Enabled: false
|
|
58
|
+
|
|
59
|
+
# Configuration parameters: AllowSafeAssignment.
|
|
60
|
+
# Reason: I'm a proud user of assignment in conditionals.
|
|
61
|
+
Lint/AssignmentInCondition:
|
|
62
|
+
Enabled: false
|
|
63
|
+
|
|
64
|
+
# Reason: Fine with any sort of lambda syntax
|
|
65
|
+
Style/Lambda:
|
|
66
|
+
Enabled: false
|
|
67
|
+
|
|
68
|
+
# Reason: I'm proud to be part of the double negative Ruby tradition
|
|
69
|
+
Style/DoubleNegation:
|
|
70
|
+
Enabled: false
|
|
71
|
+
|
|
72
|
+
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
|
2
|
+
# on 2015-01-19 01:03:42 +0200 using RuboCop version 0.28.0.
|
|
3
|
+
# The point is for the user to remove these configuration records
|
|
4
|
+
# one by one as the offenses are removed from the code base.
|
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
7
|
+
|
|
8
|
+
# Offense count: 5
|
|
9
|
+
Metrics/AbcSize:
|
|
10
|
+
Max: 25
|
|
11
|
+
|
|
12
|
+
# Offense count: 1
|
|
13
|
+
# Configuration parameters: CountComments.
|
|
14
|
+
Metrics/ClassLength:
|
|
15
|
+
Max: 232
|
|
16
|
+
|
|
17
|
+
# Offense count: 2
|
|
18
|
+
Metrics/CyclomaticComplexity:
|
|
19
|
+
Max: 10
|
|
20
|
+
|
|
21
|
+
# Offense count: 53
|
|
22
|
+
# Configuration parameters: AllowURI, URISchemes.
|
|
23
|
+
Metrics/LineLength:
|
|
24
|
+
Max: 141
|
|
25
|
+
|
|
26
|
+
# Offense count: 4
|
|
27
|
+
# Configuration parameters: CountComments.
|
|
28
|
+
Metrics/MethodLength:
|
|
29
|
+
Max: 25
|
|
30
|
+
|
|
31
|
+
# Offense count: 1
|
|
32
|
+
Metrics/PerceivedComplexity:
|
|
33
|
+
Max: 9
|
|
34
|
+
|
|
35
|
+
# Offense count: 3
|
|
36
|
+
Style/Documentation:
|
|
37
|
+
Enabled: false
|
|
38
|
+
|
|
39
|
+
# Offense count: 2
|
|
40
|
+
# Configuration parameters: MinBodyLength.
|
|
41
|
+
Style/GuardClause:
|
|
42
|
+
Enabled: false
|
|
43
|
+
|
|
44
|
+
# Offense count: 29
|
|
45
|
+
# Cop supports --auto-correct.
|
|
46
|
+
Style/RedundantSelf:
|
|
47
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [0.8.0] - 2022-11-27
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- Support for parsing enharmonic notes such as 'E#5' (#9, thanks @stufro)
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,46 +1,84 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
music (0.
|
|
4
|
+
music (0.7.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: http://rubygems.org/
|
|
8
8
|
specs:
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
ast (2.0.0)
|
|
10
|
+
astrolabe (1.3.0)
|
|
11
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
|
12
|
+
celluloid (0.16.0)
|
|
13
|
+
timers (~> 4.0.0)
|
|
14
|
+
coderay (1.1.0)
|
|
15
|
+
diff-lcs (1.2.5)
|
|
16
|
+
ffi (1.9.6)
|
|
11
17
|
ffi2-generators (0.1.1)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
formatador (0.2.5)
|
|
19
|
+
guard (2.11.1)
|
|
20
|
+
formatador (>= 0.2.4)
|
|
21
|
+
listen (~> 2.7)
|
|
22
|
+
lumberjack (~> 1.0)
|
|
23
|
+
nenv (~> 0.1)
|
|
24
|
+
notiffany (~> 0.0)
|
|
25
|
+
pry (>= 0.9.12)
|
|
26
|
+
shellany (~> 0.0)
|
|
27
|
+
thor (>= 0.18.1)
|
|
28
|
+
guard-bundler (2.1.0)
|
|
19
29
|
bundler (~> 1.0)
|
|
20
|
-
guard (~>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
guard (~> 2.2)
|
|
31
|
+
guard-compat (~> 1.1)
|
|
32
|
+
guard-compat (1.2.1)
|
|
33
|
+
guard-rspec (4.5.0)
|
|
34
|
+
guard (~> 2.1)
|
|
35
|
+
guard-compat (~> 1.1)
|
|
36
|
+
rspec (>= 2.99.0, < 4.0)
|
|
37
|
+
guard-rubocop (1.2.0)
|
|
38
|
+
guard (~> 2.0)
|
|
39
|
+
rubocop (~> 0.20)
|
|
40
|
+
hitimes (1.2.2)
|
|
41
|
+
listen (2.8.5)
|
|
42
|
+
celluloid (>= 0.15.2)
|
|
43
|
+
rb-fsevent (>= 0.9.3)
|
|
44
|
+
rb-inotify (>= 0.9)
|
|
45
|
+
lumberjack (1.0.9)
|
|
46
|
+
method_source (0.8.2)
|
|
47
|
+
nenv (0.2.0)
|
|
48
|
+
notiffany (0.0.3)
|
|
49
|
+
nenv (~> 0.1)
|
|
50
|
+
shellany (~> 0.0)
|
|
51
|
+
parser (2.2.0.2)
|
|
52
|
+
ast (>= 1.1, < 3.0)
|
|
53
|
+
powerpack (0.0.9)
|
|
54
|
+
pry (0.10.1)
|
|
55
|
+
coderay (~> 1.1.0)
|
|
56
|
+
method_source (~> 0.8.1)
|
|
30
57
|
slop (~> 3.4)
|
|
31
|
-
psych (2.0.
|
|
32
|
-
racc (1.4.
|
|
58
|
+
psych (2.0.10)
|
|
59
|
+
racc (1.4.12)
|
|
60
|
+
rainbow (2.0.0)
|
|
33
61
|
rake (0.9.6)
|
|
34
|
-
rb-fsevent (0.9.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
rb-fsevent (0.9.4)
|
|
63
|
+
rb-inotify (0.9.5)
|
|
64
|
+
ffi (>= 0.5.0)
|
|
65
|
+
rb-readline (0.5.2)
|
|
66
|
+
rspec (2.99.0)
|
|
67
|
+
rspec-core (~> 2.99.0)
|
|
68
|
+
rspec-expectations (~> 2.99.0)
|
|
69
|
+
rspec-mocks (~> 2.99.0)
|
|
70
|
+
rspec-core (2.99.2)
|
|
71
|
+
rspec-expectations (2.99.2)
|
|
41
72
|
diff-lcs (>= 1.1.3, < 2.0)
|
|
42
|
-
rspec-mocks (2.
|
|
43
|
-
|
|
73
|
+
rspec-mocks (2.99.3)
|
|
74
|
+
rubocop (0.28.0)
|
|
75
|
+
astrolabe (~> 1.3)
|
|
76
|
+
parser (>= 2.2.0.pre.7, < 3.0)
|
|
77
|
+
powerpack (~> 0.0.6)
|
|
78
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
79
|
+
ruby-progressbar (~> 1.4)
|
|
80
|
+
ruby-progressbar (1.7.1)
|
|
81
|
+
rubysl (2.1.0)
|
|
44
82
|
rubysl-abbrev (~> 2.0)
|
|
45
83
|
rubysl-base64 (~> 2.0)
|
|
46
84
|
rubysl-benchmark (~> 2.0)
|
|
@@ -74,7 +112,7 @@ GEM
|
|
|
74
112
|
rubysl-io-nonblock (~> 2.0)
|
|
75
113
|
rubysl-io-wait (~> 2.0)
|
|
76
114
|
rubysl-ipaddr (~> 2.0)
|
|
77
|
-
rubysl-irb (~> 2.
|
|
115
|
+
rubysl-irb (~> 2.1)
|
|
78
116
|
rubysl-logger (~> 2.0)
|
|
79
117
|
rubysl-mathn (~> 2.0)
|
|
80
118
|
rubysl-matrix (~> 2.0)
|
|
@@ -103,7 +141,6 @@ GEM
|
|
|
103
141
|
rubysl-pstore (~> 2.0)
|
|
104
142
|
rubysl-pty (~> 2.0)
|
|
105
143
|
rubysl-rational (~> 2.0)
|
|
106
|
-
rubysl-readline (~> 2.0)
|
|
107
144
|
rubysl-resolv (~> 2.0)
|
|
108
145
|
rubysl-rexml (~> 2.0)
|
|
109
146
|
rubysl-rinda (~> 2.0)
|
|
@@ -145,14 +182,14 @@ GEM
|
|
|
145
182
|
rubysl-csv (2.0.2)
|
|
146
183
|
rubysl-english (~> 2.0)
|
|
147
184
|
rubysl-curses (2.0.1)
|
|
148
|
-
rubysl-date (2.0.
|
|
185
|
+
rubysl-date (2.0.8)
|
|
149
186
|
rubysl-delegate (2.0.1)
|
|
150
187
|
rubysl-digest (2.0.3)
|
|
151
188
|
rubysl-drb (2.0.1)
|
|
152
189
|
rubysl-e2mmap (2.0.0)
|
|
153
190
|
rubysl-english (2.0.0)
|
|
154
191
|
rubysl-enumerator (2.0.0)
|
|
155
|
-
rubysl-erb (2.0.
|
|
192
|
+
rubysl-erb (2.0.2)
|
|
156
193
|
rubysl-etc (2.0.3)
|
|
157
194
|
ffi2-generators (~> 0.1)
|
|
158
195
|
rubysl-expect (2.0.0)
|
|
@@ -170,12 +207,12 @@ GEM
|
|
|
170
207
|
rubysl-io-nonblock (2.0.0)
|
|
171
208
|
rubysl-io-wait (2.0.0)
|
|
172
209
|
rubysl-ipaddr (2.0.0)
|
|
173
|
-
rubysl-irb (2.0
|
|
210
|
+
rubysl-irb (2.1.0)
|
|
211
|
+
rb-readline (~> 0.5)
|
|
174
212
|
rubysl-e2mmap (~> 2.0)
|
|
175
213
|
rubysl-mathn (~> 2.0)
|
|
176
|
-
rubysl-readline (~> 2.0)
|
|
177
214
|
rubysl-thread (~> 2.0)
|
|
178
|
-
rubysl-logger (2.
|
|
215
|
+
rubysl-logger (2.1.0)
|
|
179
216
|
rubysl-mathn (2.0.0)
|
|
180
217
|
rubysl-matrix (2.1.0)
|
|
181
218
|
rubysl-e2mmap (~> 2.0)
|
|
@@ -198,21 +235,20 @@ GEM
|
|
|
198
235
|
rubysl-observer (2.0.0)
|
|
199
236
|
rubysl-open-uri (2.0.0)
|
|
200
237
|
rubysl-open3 (2.0.0)
|
|
201
|
-
rubysl-openssl (2.1
|
|
238
|
+
rubysl-openssl (2.2.1)
|
|
202
239
|
rubysl-optparse (2.0.1)
|
|
203
240
|
rubysl-shellwords (~> 2.0)
|
|
204
241
|
rubysl-ostruct (2.0.4)
|
|
205
|
-
rubysl-pathname (2.
|
|
206
|
-
rubysl-prettyprint (2.0.
|
|
242
|
+
rubysl-pathname (2.1.0)
|
|
243
|
+
rubysl-prettyprint (2.0.3)
|
|
207
244
|
rubysl-prime (2.0.1)
|
|
208
245
|
rubysl-profile (2.0.0)
|
|
209
246
|
rubysl-profiler (2.0.1)
|
|
210
247
|
rubysl-pstore (2.0.0)
|
|
211
|
-
rubysl-pty (2.0.
|
|
248
|
+
rubysl-pty (2.0.3)
|
|
212
249
|
rubysl-rational (2.0.1)
|
|
213
|
-
rubysl-
|
|
214
|
-
rubysl-
|
|
215
|
-
rubysl-rexml (2.0.2)
|
|
250
|
+
rubysl-resolv (2.1.0)
|
|
251
|
+
rubysl-rexml (2.0.4)
|
|
216
252
|
rubysl-rinda (2.0.1)
|
|
217
253
|
rubysl-rss (2.0.0)
|
|
218
254
|
rubysl-scanf (2.0.0)
|
|
@@ -224,14 +260,14 @@ GEM
|
|
|
224
260
|
rubysl-stringio (2.0.0)
|
|
225
261
|
rubysl-strscan (2.0.0)
|
|
226
262
|
rubysl-sync (2.0.0)
|
|
227
|
-
rubysl-syslog (2.0
|
|
263
|
+
rubysl-syslog (2.1.0)
|
|
228
264
|
ffi2-generators (~> 0.1)
|
|
229
265
|
rubysl-tempfile (2.0.1)
|
|
230
266
|
rubysl-thread (2.0.2)
|
|
231
267
|
rubysl-thwait (2.0.0)
|
|
232
268
|
rubysl-time (2.0.3)
|
|
233
269
|
rubysl-timeout (2.0.0)
|
|
234
|
-
rubysl-tmpdir (2.0.
|
|
270
|
+
rubysl-tmpdir (2.0.1)
|
|
235
271
|
rubysl-tsort (2.0.1)
|
|
236
272
|
rubysl-un (2.0.0)
|
|
237
273
|
rubysl-fileutils (~> 2.0)
|
|
@@ -240,11 +276,13 @@ GEM
|
|
|
240
276
|
rubysl-weakref (2.0.0)
|
|
241
277
|
rubysl-webrick (2.0.0)
|
|
242
278
|
rubysl-xmlrpc (2.0.0)
|
|
243
|
-
rubysl-yaml (2.0
|
|
279
|
+
rubysl-yaml (2.1.0)
|
|
244
280
|
rubysl-zlib (2.0.1)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
thor (0.
|
|
281
|
+
shellany (0.0.1)
|
|
282
|
+
slop (3.6.0)
|
|
283
|
+
thor (0.19.1)
|
|
284
|
+
timers (4.0.1)
|
|
285
|
+
hitimes
|
|
248
286
|
|
|
249
287
|
PLATFORMS
|
|
250
288
|
ruby
|
|
@@ -252,6 +290,7 @@ PLATFORMS
|
|
|
252
290
|
DEPENDENCIES
|
|
253
291
|
guard-bundler
|
|
254
292
|
guard-rspec
|
|
293
|
+
guard-rubocop
|
|
255
294
|
music!
|
|
256
295
|
psych
|
|
257
296
|
racc
|
data/Guardfile
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
# A sample Guardfile
|
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
|
3
|
-
|
|
4
1
|
guard 'bundler' do
|
|
5
2
|
watch('Gemfile')
|
|
6
3
|
# Uncomment next line if Gemfile contain `gemspec' command
|
|
7
4
|
# watch(/^.+\.gemspec/)
|
|
8
5
|
end
|
|
9
6
|
|
|
10
|
-
guard
|
|
11
|
-
watch(
|
|
12
|
-
watch(
|
|
13
|
-
|
|
7
|
+
guard :rubocop, cli: '--auto-correct --display-cop-names' do
|
|
8
|
+
watch(/.+\.rb$/)
|
|
9
|
+
watch(/(?:.+\/)?\.rubocop.*\.yml$/) { |m| File.dirname(m[0]) }
|
|
10
|
+
end
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
watch(
|
|
17
|
-
watch(
|
|
18
|
-
watch(
|
|
19
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
|
20
|
-
watch('config/routes.rb') { "spec/routing" }
|
|
21
|
-
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
|
22
|
-
|
|
23
|
-
# Capybara request specs
|
|
24
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
|
25
|
-
|
|
26
|
-
# Turnip features and steps
|
|
27
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
28
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
|
12
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
|
13
|
+
watch(/^spec\/.+_spec\.rb$/)
|
|
14
|
+
watch(/^lib\/(.+)\.rb/) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
15
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
|
29
16
|
end
|
data/README.md
CHANGED
|
@@ -5,9 +5,13 @@ The *music* gem provides a means on calculating notes and chords.
|
|
|
5
5
|
|
|
6
6
|
[](https://travis-ci.org/cheerfulstoic/music)
|
|
7
7
|
|
|
8
|
+
[](https://www.pullreview.com/github/cheerfulstoic/music/reviews/master)
|
|
9
|
+
|
|
8
10
|
Examples:
|
|
9
11
|
---------
|
|
10
12
|
|
|
13
|
+
All examples below assume that `include Music` has been called, though you can also use `Music::Note`, `Music::Chord`, etc...
|
|
14
|
+
|
|
11
15
|
Creating notes:
|
|
12
16
|
|
|
13
17
|
note = Note.new(698.46) # Creates a note object with the frequency 698.46
|
data/Rakefile
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rspec/core/rake_task'
|
|
3
3
|
|
|
4
|
-
task :
|
|
4
|
+
task default: [:spec]
|
|
5
5
|
|
|
6
|
-
desc
|
|
7
|
-
task :
|
|
6
|
+
desc 'Run all test'
|
|
7
|
+
task test: [:spec]
|
|
8
8
|
|
|
9
9
|
# RSpec tasks
|
|
10
|
-
desc
|
|
10
|
+
desc 'Run all examples'
|
|
11
11
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
12
12
|
spec.ruby_opts = '-I lib'
|
|
13
13
|
spec.pattern = 'spec/**/*_spec.rb'
|
|
@@ -15,11 +15,10 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
# Gems tasks
|
|
18
|
-
require
|
|
18
|
+
require 'bundler'
|
|
19
19
|
Bundler::GemHelper.install_tasks
|
|
20
20
|
|
|
21
|
-
desc
|
|
21
|
+
desc 'Clean automatically generated files'
|
|
22
22
|
task :clean do
|
|
23
|
-
FileUtils.rm_rf
|
|
23
|
+
FileUtils.rm_rf 'pkg'
|
|
24
24
|
end
|
|
25
|
-
|
data/lib/music/chord.rb
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
+
require 'set'
|
|
2
|
+
|
|
1
3
|
module Music
|
|
2
4
|
class Chord
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@notes == other_chord.notes
|
|
5
|
+
def eql?(other)
|
|
6
|
+
@notes == other.notes
|
|
6
7
|
end
|
|
8
|
+
|
|
7
9
|
def hash
|
|
8
10
|
@notes.hash
|
|
9
11
|
end
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
|
|
13
|
+
def ==(other)
|
|
14
|
+
self.eql?(other)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
attr_reader :notes
|
|
15
18
|
|
|
16
19
|
def initialize(notes)
|
|
17
|
-
|
|
18
|
-
@notes = Set.new(notes) do |note|
|
|
20
|
+
fail ArgumentError, 'Chords must have at least two notes' if notes.size < 2
|
|
21
|
+
@notes = ::Set.new(notes) do |note|
|
|
19
22
|
if note.is_a?(Note)
|
|
20
23
|
note
|
|
21
24
|
else
|
|
@@ -28,7 +31,7 @@ module Music
|
|
|
28
31
|
# def to_i
|
|
29
32
|
|
|
30
33
|
def note_strings
|
|
31
|
-
Set.new(@notes.collect(&:note_string))
|
|
34
|
+
::Set.new(@notes.collect(&:note_string))
|
|
32
35
|
end
|
|
33
36
|
|
|
34
37
|
def describe
|
|
@@ -38,25 +41,25 @@ module Music
|
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
quality = case distances
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
when [4, 7]
|
|
45
|
+
:major
|
|
46
|
+
when [3, 7]
|
|
47
|
+
:minor
|
|
48
|
+
when [3, 6]
|
|
49
|
+
:diminished
|
|
50
|
+
when [4, 8]
|
|
51
|
+
:augmented
|
|
52
|
+
when [4, 7, 11]
|
|
53
|
+
:major_7
|
|
54
|
+
when [3, 7, 10]
|
|
55
|
+
:minor_7
|
|
56
|
+
when [3, 6, 9]
|
|
57
|
+
:diminished_7
|
|
58
|
+
when [3, 6, 10]
|
|
59
|
+
:half_diminished_7
|
|
60
|
+
when [4, 8, 10]
|
|
61
|
+
:augmented_7
|
|
62
|
+
end
|
|
60
63
|
|
|
61
64
|
[note_array.first.letter, quality]
|
|
62
65
|
end
|
|
@@ -69,8 +72,8 @@ module Music
|
|
|
69
72
|
#
|
|
70
73
|
# @returns [Chord] The specified inversion of chord
|
|
71
74
|
def inversion(amount)
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
fail ArgumentError, 'Inversion amount must be greater than or equal to 1' if amount < 1
|
|
76
|
+
fail ArgumentError, 'Not enough notes in chord for inversion' if amount >= @notes.size
|
|
74
77
|
|
|
75
78
|
note_array = @notes.to_a.sort
|
|
76
79
|
notes = (0...amount).collect { note_array.shift.adjust_by_semitones(12) }
|
|
@@ -95,9 +98,9 @@ module Music
|
|
|
95
98
|
class << self
|
|
96
99
|
def parse_chord_string(chord_string, assumed_octave = nil)
|
|
97
100
|
if note_string_match = chord_string.match(/^([A-Ga-g])([#b]?)([^\d]*)(\d*)$/)
|
|
98
|
-
|
|
101
|
+
_, note, accidental, interval, octave = note_string_match.to_a
|
|
99
102
|
|
|
100
|
-
|
|
103
|
+
fail ArgumentError, 'No octave found and no octave assumed' if note.empty? && assumed_octave.nil?
|
|
101
104
|
|
|
102
105
|
Note.new(note + accidental + octave, assumed_octave).chord(interval)
|
|
103
106
|
end
|