wtf_chord 0.3 → 0.3.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/README.md +12 -12
- data/lib/wtf_chord/cli.rb +1 -1
- data/lib/wtf_chord/fingerings_generator.rb +8 -1
- data/lib/wtf_chord/formatter.rb +7 -5
- data/lib/wtf_chord/formatters/default.rb +28 -27
- data/lib/wtf_chord/helpers/roman_numbers_helper.rb +9 -0
- data/lib/wtf_chord/note.rb +1 -1
- data/lib/wtf_chord/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6659fef8eb5eb71f547c1186e3d676a600f4b075
|
4
|
+
data.tar.gz: b4bff9c2a9251ece5fb9fc21b6ff03b0484dd102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6c5b2ac510e44764a577b3af1744bfd71cc573047866a9cfed73e79cb882a299c894d62c664fcd8ae04814faebf04ef7740168045edccf2a304630fb9f05cc5
|
7
|
+
data.tar.gz: 18342e90f1af73920ee3d5974bb662c5d1e506af50c9bc822f67367dcc04f68717d4649ce5a925afc671edb184bf0339b200d5c64f822c4b72457e56328f9eee
|
data/README.md
CHANGED
@@ -31,13 +31,13 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
Finds fingerings of the requested chord.
|
33
33
|
|
34
|
-
v0.
|
34
|
+
v0.3.1
|
35
35
|
|
36
36
|
Options:
|
37
37
|
-h, --help Show command line help
|
38
38
|
--version Show help/version info
|
39
39
|
-n, --amount N Amount of fingering variants to output.
|
40
|
-
(default:
|
40
|
+
(default: 5)
|
41
41
|
-o, --output FORMAT Output format.
|
42
42
|
(default: default)
|
43
43
|
-R, --[no-]rates Output fingering complexity rates
|
@@ -57,25 +57,25 @@ For example, to print two fingering variants of the `Dm` chord, just run:
|
|
57
57
|
And you'll get the visual presentation of chords' fingerings:
|
58
58
|
|
59
59
|
[ × × 0 2 3 1 ]
|
60
|
-
|
61
|
-
| | | | |
|
62
|
-
| | |
|
63
|
-
| | | |
|
60
|
+
——————————————————
|
61
|
+
| | | | | ◉
|
62
|
+
| | | ◉ | |
|
63
|
+
| | | | ◉ |
|
64
64
|
| | | | | |
|
65
65
|
| | | | | |
|
66
66
|
| | | | | |
|
67
|
-
|
67
|
+
——————————————————
|
68
68
|
D A D F
|
69
69
|
|
70
70
|
[ × 5 7 7 6 5 ]
|
71
|
-
|
72
|
-
|
|
73
|
-
| | | |
|
74
|
-
| |
|
71
|
+
——————————————————
|
72
|
+
| ◉ | | | ◉ ← V
|
73
|
+
| | | | ◉ |
|
74
|
+
| | ◉ ◉ | |
|
75
75
|
| | | | | |
|
76
76
|
| | | | | |
|
77
77
|
| | | | | |
|
78
|
-
|
78
|
+
——————————————————
|
79
79
|
D A D F A
|
80
80
|
|
81
81
|
You can get simpler output, using the `--output` option:
|
data/lib/wtf_chord/cli.rb
CHANGED
@@ -51,7 +51,10 @@ module WTFChord
|
|
51
51
|
|
52
52
|
!fingerings.include?(variant) &&
|
53
53
|
basetone?(used_strings[0]) &&
|
54
|
-
(
|
54
|
+
(
|
55
|
+
(third?(used_strings[1]) || third?(used_strings[2])) ||
|
56
|
+
(last?(used_strings[1]) || last?(used_strings[2]))
|
57
|
+
) &&
|
55
58
|
all_notes?(used_notes) &&
|
56
59
|
used_notes.each_cons(2).none? { |(l, r)| l == r } &&
|
57
60
|
tones_count.all? { |n| tones_count[0] >= n || tones_count[notes.index(third_tone)] >= n } &&
|
@@ -81,5 +84,9 @@ module WTFChord
|
|
81
84
|
def third?(string)
|
82
85
|
string && (string.note == third_tone)
|
83
86
|
end
|
87
|
+
|
88
|
+
def last?(string)
|
89
|
+
string && (string.note == notes[-1])
|
90
|
+
end
|
84
91
|
end
|
85
92
|
end
|
data/lib/wtf_chord/formatter.rb
CHANGED
@@ -9,19 +9,21 @@ module WTFChord
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(*fingerings)
|
12
|
-
formatter.with_rates(@with_rates)
|
13
|
-
puts (fingerings.map(&f) * f.separator)
|
14
|
-
end
|
12
|
+
formatter.with_rates(@with_rates) { |f| fingerings.map(&f) }
|
15
13
|
end
|
16
14
|
|
17
15
|
alias :[] :call
|
18
16
|
|
17
|
+
def separator
|
18
|
+
formatter.separator
|
19
|
+
end
|
20
|
+
|
19
21
|
def formatter
|
20
|
-
|
22
|
+
Formatters.const_get(formatter_name)
|
21
23
|
end
|
22
24
|
|
23
25
|
def formatter?
|
24
|
-
|
26
|
+
Formatters.const_defined?(formatter_name)
|
25
27
|
end
|
26
28
|
|
27
29
|
def formatter_name
|
@@ -1,25 +1,28 @@
|
|
1
|
+
require 'wtf_chord/helpers/roman_numbers_helper'
|
2
|
+
|
1
3
|
module WTFChord
|
2
4
|
module Formatters
|
3
5
|
class Default < Base
|
4
6
|
OPEN = "|".freeze
|
5
|
-
HORIZ = "
|
7
|
+
HORIZ = "—".freeze
|
6
8
|
SPACE = " ".freeze
|
7
|
-
BULL = "\
|
8
|
-
LATIN = %w(0 I II III IV V VI VII VIII IX X XII XIII).freeze
|
9
|
+
BULL = "\u25C9".freeze
|
9
10
|
NEWLINE = "\n".freeze
|
11
|
+
COMPLEXITY_FORMAT = " (complexity: %.2f)".freeze
|
12
|
+
EMPTY_STRING = Array.new(FRETS, OPEN).freeze
|
10
13
|
|
11
|
-
|
12
|
-
"\n\n".freeze
|
13
|
-
end
|
14
|
+
include RomanNumbersHelper
|
14
15
|
|
15
16
|
def draw
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"
|
22
|
-
|
17
|
+
<<-EOF.gsub(/^\s+\|/, '')
|
18
|
+
|[ #{head} ] #{capo}
|
19
|
+
| #{border}
|
20
|
+
#{fret_rows.map.with_index { |row, index|
|
21
|
+
" | #{row} #{roman_min_fret if index == 0}"
|
22
|
+
}.join("\n")}
|
23
|
+
| #{border}
|
24
|
+
| #{string_keys}#{rate}
|
25
|
+
EOF
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
@@ -29,11 +32,15 @@ module WTFChord
|
|
29
32
|
end
|
30
33
|
|
31
34
|
def capo
|
32
|
-
"
|
35
|
+
"(capo #{romanize(@fret.capo)})" if @fret.capo > 0
|
36
|
+
end
|
37
|
+
|
38
|
+
def roman_min_fret
|
39
|
+
" ← #{romanize(min_fret)}" if min_fret > 1
|
33
40
|
end
|
34
41
|
|
35
42
|
def rate
|
36
|
-
|
43
|
+
COMPLEXITY_FORMAT % @fret.complexity if with_rates?
|
37
44
|
end
|
38
45
|
|
39
46
|
def border
|
@@ -41,27 +48,21 @@ module WTFChord
|
|
41
48
|
end
|
42
49
|
|
43
50
|
def string_rows
|
44
|
-
strings.map { |string| draw_string(string
|
51
|
+
strings.map { |string| draw_string(string) }
|
45
52
|
end
|
46
53
|
|
47
54
|
def fret_rows
|
48
|
-
|
49
|
-
|
50
|
-
end
|
55
|
+
return to_enum(__method__) unless block_given?
|
56
|
+
string_rows.transpose.each { |row| yield(row * SPACE) }
|
51
57
|
end
|
52
58
|
|
53
59
|
def string_keys
|
54
60
|
strings.map { |s| s.dead? ? SPACE : "%-2s" % s.key } * " "
|
55
61
|
end
|
56
62
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
def draw_string(fret)
|
62
|
-
Array.new(FRETS, OPEN).tap do |rows|
|
63
|
-
rows[(fret - min_fret.pred).pred] = BULL if fret.to_i > 0
|
64
|
-
end
|
63
|
+
def draw_string(string)
|
64
|
+
EMPTY_STRING.dup.
|
65
|
+
tap { |rows| rows[string.fret - min_fret] = BULL if string.holded? }
|
65
66
|
end
|
66
67
|
end
|
67
68
|
end
|
data/lib/wtf_chord/note.rb
CHANGED
@@ -25,7 +25,7 @@ module WTFChord
|
|
25
25
|
|
26
26
|
def == other
|
27
27
|
case other
|
28
|
-
when String then other.casecmp(@key).zero?
|
28
|
+
when String then other.casecmp(@key).zero? || aliases.any? { |a| other.casecmp(a.key).zero? }
|
29
29
|
when Integer then other == @position
|
30
30
|
when Note then other.position == @position
|
31
31
|
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:
|
4
|
+
version: 0.3.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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: methadone
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/wtf_chord/formatters/simple.rb
|
115
115
|
- lib/wtf_chord/fretboard.rb
|
116
116
|
- lib/wtf_chord/guitar_string.rb
|
117
|
+
- lib/wtf_chord/helpers/roman_numbers_helper.rb
|
117
118
|
- lib/wtf_chord/note.rb
|
118
119
|
- lib/wtf_chord/pitch.rb
|
119
120
|
- lib/wtf_chord/rules.rb
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.2
|
143
144
|
signing_key:
|
144
145
|
specification_version: 4
|
145
146
|
summary: "‘WTF Chord?’ is the Ruby guitar chords generator library."
|