wtf_chord 0.2.0 → 0.2.1
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 +4 -4
- data/.gitignore +2 -1
- data/README.md +2 -1
- data/lib/wtf_chord/cli.rb +5 -3
- data/lib/wtf_chord/complexity_counter.rb +8 -6
- data/lib/wtf_chord/fingering.rb +5 -1
- data/lib/wtf_chord/formatter.rb +5 -2
- data/lib/wtf_chord/formatters/base.rb +20 -2
- data/lib/wtf_chord/formatters/default.rb +5 -1
- data/lib/wtf_chord/formatters/simple.rb +1 -1
- data/lib/wtf_chord/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23feadfbf5375e890423135cc86a56d9b70af3e8
|
4
|
+
data.tar.gz: aaa6a0d46fbeb51e715306da3d127b86816ed293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 711ef213b9ea7302e812c122fda26aee2bb305960a0a1fc3f687106948ea401dcfe17eaeac3972d9a42f6bdf22f6189d01255be790bf89194dbb5e6479a3d86c
|
7
|
+
data.tar.gz: 4c081a0a57e196422c13fa0a40f671e55d2b39ad49f96678c8b87da277d5e242d4d38fd19924d7e0d920444cc290af7d5984208e75f8a1cbc4dbeeddd10e7547
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -31,7 +31,7 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
Finds fingerings of the requested chord.
|
33
33
|
|
34
|
-
v0.2.
|
34
|
+
v0.2.1
|
35
35
|
|
36
36
|
Options:
|
37
37
|
-h, --help Show command line help
|
@@ -40,6 +40,7 @@ Or install it yourself as:
|
|
40
40
|
(default: 3)
|
41
41
|
-o, --output FORMAT Output format.
|
42
42
|
(default: default)
|
43
|
+
-R, --[no-]rates Output fingering complexity rates
|
43
44
|
--log-level LEVEL Set the logging level
|
44
45
|
(debug|info|warn|error|fatal)
|
45
46
|
(Default: info)
|
data/lib/wtf_chord/cli.rb
CHANGED
@@ -9,7 +9,7 @@ module WTFChord
|
|
9
9
|
main do |name|
|
10
10
|
chord = WTFChord.chord(name)
|
11
11
|
fingerings = chord.fingerings(options['amount'])
|
12
|
-
formatter = WTFChord::Formatter.new(options['output'])
|
12
|
+
formatter = WTFChord::Formatter.new(options['output'], options['rates'])
|
13
13
|
|
14
14
|
debug { "Output using formatter: #{formatter.formatter.to_s}\n" }
|
15
15
|
|
@@ -33,9 +33,11 @@ module WTFChord
|
|
33
33
|
#
|
34
34
|
options['amount'] = 3
|
35
35
|
options['output'] = 'default'
|
36
|
+
options['rates'] = false
|
36
37
|
|
37
|
-
on "-n N",
|
38
|
-
on "-o FORMAT", "--output FORMAT",
|
38
|
+
on "-n N", "--amount N", Integer, "Amount of fingering variants to output."
|
39
|
+
on "-o FORMAT", "--output FORMAT", "Output format."
|
40
|
+
on "-R", "--[no-]rates", "Output fingering complexity rates"
|
39
41
|
|
40
42
|
use_log_level_option
|
41
43
|
end
|
@@ -6,15 +6,17 @@ module WTFChord
|
|
6
6
|
|
7
7
|
def rate
|
8
8
|
frets = @fingering.holded_strings.map(&:fret)
|
9
|
-
barre = frets.uniq.keep_if { |o| frets.count(o)
|
9
|
+
barre = frets.uniq.keep_if { |o| frets.count(o) >= 2 }.min
|
10
10
|
barre_strings = barre ? frets.count(barre).pred : 0
|
11
11
|
|
12
|
-
base_rate =
|
13
|
-
Rational(holded_strings - barre_strings,
|
14
|
-
Rational(finger_dist(frets), 5)
|
15
|
-
|
12
|
+
base_rate = begin
|
13
|
+
Rational(holded_strings - barre_strings, 6).to_f +
|
14
|
+
Rational(finger_dist(frets), 5).to_f
|
15
|
+
end
|
16
16
|
|
17
|
-
|
17
|
+
# p [@fingering, holded_strings, barre_strings]
|
18
|
+
|
19
|
+
base_rate += 1 if (barre_strings > 2 || frets.uniq.size > 3) && complex_barre?(barre, frets)
|
18
20
|
|
19
21
|
base_rate
|
20
22
|
end
|
data/lib/wtf_chord/fingering.rb
CHANGED
data/lib/wtf_chord/formatter.rb
CHANGED
@@ -2,13 +2,16 @@ require 'wtf_chord/formatters/base'
|
|
2
2
|
|
3
3
|
module WTFChord
|
4
4
|
class Formatter
|
5
|
-
def initialize(name)
|
5
|
+
def initialize(name, with_rates = false)
|
6
6
|
@name = name
|
7
|
+
@with_rates = with_rates
|
7
8
|
require_formatter! unless formatter?
|
8
9
|
end
|
9
10
|
|
10
11
|
def call(*fingerings)
|
11
|
-
|
12
|
+
formatter.with_rates(@with_rates) do |f|
|
13
|
+
puts (fingerings.map(&f) * f.separator)
|
14
|
+
end
|
12
15
|
end
|
13
16
|
|
14
17
|
alias :[] :call
|
@@ -13,16 +13,28 @@ module WTFChord
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.to_proc
|
16
|
-
proc { |fret| new(fret).draw }
|
16
|
+
proc { |fret| new(fret, Thread.current[:with_rates]).draw }
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
19
|
+
def self.with_rates(value = false)
|
20
|
+
Thread.current[:with_rates], with_rates_was = !!value, !!Thread.current[:with_rates]
|
21
|
+
yield(self)
|
22
|
+
ensure
|
23
|
+
Thread.current[:with_rates] = with_rates_was
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(fret, with_rates = false)
|
20
27
|
@fret = fret
|
28
|
+
@with_rates = !!with_rates
|
21
29
|
end
|
22
30
|
|
23
31
|
def draw
|
24
32
|
end
|
25
33
|
|
34
|
+
def with_rates?
|
35
|
+
!!@with_rates
|
36
|
+
end
|
37
|
+
|
26
38
|
protected
|
27
39
|
|
28
40
|
def min_fret
|
@@ -32,6 +44,12 @@ module WTFChord
|
|
32
44
|
_min > 2 ? _min : 1
|
33
45
|
end
|
34
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def rate
|
51
|
+
" complexity: %.2f" % @fret.complexity if with_rates?
|
52
|
+
end
|
35
53
|
end
|
36
54
|
end
|
37
55
|
end
|
@@ -18,7 +18,7 @@ module WTFChord
|
|
18
18
|
" #{border}",
|
19
19
|
*fret_rows,
|
20
20
|
" #{border}",
|
21
|
-
" #{string_keys}"
|
21
|
+
" #{string_keys}#{rate}"
|
22
22
|
] * NEWLINE
|
23
23
|
end
|
24
24
|
|
@@ -32,6 +32,10 @@ module WTFChord
|
|
32
32
|
" (capo #{to_latin @fret.capo})" if @fret.capo > 0
|
33
33
|
end
|
34
34
|
|
35
|
+
def rate
|
36
|
+
" (complexity: %.2f)" % @fret.complexity if with_rates?
|
37
|
+
end
|
38
|
+
|
35
39
|
def border
|
36
40
|
@border ||= HORIZ * 3 * strings.length
|
37
41
|
end
|
data/lib/wtf_chord/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.1
|
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-
|
11
|
+
date: 2016-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: methadone
|