wtf_chord 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6659fef8eb5eb71f547c1186e3d676a600f4b075
4
- data.tar.gz: b4bff9c2a9251ece5fb9fc21b6ff03b0484dd102
3
+ metadata.gz: ff26ad0548f061f6982cfa47df59f0ffff78b136
4
+ data.tar.gz: 073b2e5c14ac65a19c6aa806f97467c618f10145
5
5
  SHA512:
6
- metadata.gz: b6c5b2ac510e44764a577b3af1744bfd71cc573047866a9cfed73e79cb882a299c894d62c664fcd8ae04814faebf04ef7740168045edccf2a304630fb9f05cc5
7
- data.tar.gz: 18342e90f1af73920ee3d5974bb662c5d1e506af50c9bc822f67367dcc04f68717d4649ce5a925afc671edb184bf0339b200d5c64f822c4b72457e56328f9eee
6
+ metadata.gz: 40326155782d5c90b1e99f6b1e0d117d06d6c6b10139636fe7d27bcc5a9207c72073a205298e870405fd5af1aee6865ffb8271d80c3e47b940d86a65d54ca74b
7
+ data.tar.gz: 33d25bb0f14caaa21278dfdce45ef553656c29a77eb29bab409c80910e3f7f5c2aeeb97e5b99f580c2f2949d4ca2c1359594ce80d0798bdc7fadde366ceac4ca
data/lib/wtf_chord/cli.rb CHANGED
@@ -7,14 +7,13 @@ module WTFChord
7
7
  include Methadone::CLILogging
8
8
 
9
9
  main do |name|
10
- chord = WTFChord.chord(name)
11
- fingerings = chord.fingerings(options['amount'])
12
- formatter = WTFChord::Formatter.new(options['output'], options['rates'])
10
+ chord = WTFChord.chord(name)
11
+ formatter = WTFChord::Formatter.new(options['output'], options['rates'])
13
12
 
14
13
  debug { "Output using formatter: #{formatter.formatter.to_s}\n" }
15
14
 
16
15
  puts chord.inspect, nil
17
- puts formatter[*fingerings] * formatter.separator
16
+ puts formatter[*chord.fingerings(options['amount'])] * formatter.separator
18
17
  end
19
18
 
20
19
  version VERSION
@@ -26,18 +26,16 @@ module WTFChord
26
26
  private
27
27
 
28
28
  def generate(fret_range)
29
- combinations = GUITAR.strings.map.with_index do |s, index|
30
- fret_range.select do |dist|
31
- pitch = s.original + dist
32
- has_note?(pitch)
33
- end.tap do |frets|
34
- frets << nil if frets.size == 0
35
- end
29
+ combinations = WTFChord.guitar.strings.map.with_index do |s, index|
30
+ fret_range.
31
+ select { |dist| pitch = s.original + dist; has_note?(pitch) }.
32
+ tap { |frets| frets << nil if frets.size == 0 }
36
33
  end
37
34
 
38
35
  combinations.inject(&:product).each do |fingers|
39
36
  fingers.flatten!
40
- Fingering.new(GUITAR, fingers) do |variant|
37
+
38
+ Fingering.new(WTFChord.guitar, fingers) do |variant|
41
39
  adjust(variant)
42
40
  yield(variant)
43
41
  end
@@ -23,6 +23,14 @@ module WTFChord
23
23
  self
24
24
  end
25
25
 
26
+ def with_capo(capo)
27
+ capo_was = @capo
28
+ set_capo(capo)
29
+ yield
30
+ ensure
31
+ set_capo(capo_was)
32
+ end
33
+
26
34
  def fingers
27
35
  @strings.map { |string| string.dead? ? DEAD : string.fret }
28
36
  end
@@ -63,5 +63,11 @@ module WTFChord
63
63
  ScaleArray.build(*chromatic_scale).freeze
64
64
  end
65
65
 
66
- GUITAR ||= Fretboard.new(*%w(E2 A2 D3 G3 B3 E4))
66
+ def self.guitar=(guitar)
67
+ Thread.current[:wtf_guitar] = guitar
68
+ end
69
+
70
+ def self.guitar
71
+ Thread.current[:wtf_guitar] ||= Fretboard.new(*%w(E2 A2 D3 G3 B3 E4))
72
+ end
67
73
  end
@@ -1,3 +1,3 @@
1
1
  module WTFChord
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
data/wtf_chord.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "methadone"
24
24
 
25
- spec.add_development_dependency "bundler", ">= 1.11", "< 2"
26
- spec.add_development_dependency "rake", ">= 10.0", "< 12"
25
+ spec.add_development_dependency "bundler"
26
+ spec.add_development_dependency "rake"
27
27
  spec.add_development_dependency "rspec", ">= 3.0", "< 4"
28
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wtf_chord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: methadone
@@ -30,40 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.11'
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: '2'
33
+ version: '0'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - ">="
42
39
  - !ruby/object:Gem::Version
43
- version: '1.11'
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: '2'
40
+ version: '0'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: rake
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - ">="
52
46
  - !ruby/object:Gem::Version
53
- version: '10.0'
54
- - - "<"
55
- - !ruby/object:Gem::Version
56
- version: '12'
47
+ version: '0'
57
48
  type: :development
58
49
  prerelease: false
59
50
  version_requirements: !ruby/object:Gem::Requirement
60
51
  requirements:
61
52
  - - ">="
62
53
  - !ruby/object:Gem::Version
63
- version: '10.0'
64
- - - "<"
65
- - !ruby/object:Gem::Version
66
- version: '12'
54
+ version: '0'
67
55
  - !ruby/object:Gem::Dependency
68
56
  name: rspec
69
57
  requirement: !ruby/object:Gem::Requirement
@@ -140,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
128
  version: '0'
141
129
  requirements: []
142
130
  rubyforge_project:
143
- rubygems_version: 2.6.2
131
+ rubygems_version: 2.6.6
144
132
  signing_key:
145
133
  specification_version: 4
146
134
  summary: "‘WTF Chord?’ is the Ruby guitar chords generator library."