wtf_chord 0.5.0 → 0.6.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
- SHA1:
3
- metadata.gz: b01a7a811a348cefa9b4e05c67d4ae4cb4af5f20
4
- data.tar.gz: 814e86e9e218ab85ec3605bdf72c99bb632c22d3
2
+ SHA256:
3
+ metadata.gz: 6b17613170273223d591f45e88733cf89449d8b872088496c7c569a7e053f4e0
4
+ data.tar.gz: 10460d448a476b45fd1ea0c96b6b418458f7c123b83f9bc8f8d45593e6fd1b36
5
5
  SHA512:
6
- metadata.gz: ff5fe7b9623c92b26d74c01cccfda962196affa8a6e171975d39b91828cce3080e31ed3bc29d2fd208030c3ed47847b8a692367ef40ffe1f1bfda72f12ddb516
7
- data.tar.gz: f9fbcb0adc02b779dc665cafef34466c4cf569e79eb0a8636e0c5e689e3c59f271b51f62fd75d05bb64ae21a6c9d0d1118ba273cb039d0127a25136a1bc70a6e
6
+ metadata.gz: 37dc9a3b6f74eeb4615f8ff897982c0a4dff8577316415ce50cd9278968298d2c9a18d24ca885fde1f599c919b6547884983ab38e68f5ae49e33f6671436e8a9
7
+ data.tar.gz: 8d326d7047187a13e778af13928a3e5ac847e56c57109817feab09b17d00a29c2d56a33c9d98d23946ccde52fa5cc65e158f14ee71e59470bdb57ec319514ccb
data/lib/wtf_chord/cli.rb CHANGED
@@ -12,6 +12,8 @@ module WTFChord
12
12
 
13
13
  debug { "Output using formatter: #{formatter.formatter.to_s}\n" }
14
14
 
15
+ options['amount'] = 1 if options['output'] == 'piano'
16
+
15
17
  puts chord.inspect, nil
16
18
  puts formatter[*chord.fingerings(options['amount'])] * formatter.separator
17
19
  end
@@ -31,6 +31,10 @@ module WTFChord
31
31
  def draw
32
32
  end
33
33
 
34
+ def keys
35
+ strings.reject(&:dead?).map(&:key)
36
+ end
37
+
34
38
  def with_rates?
35
39
  !!@with_rates
36
40
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "wtf_chord/keyboard"
4
+
5
+ module WTFChord
6
+ module Formatters
7
+ class Piano < Base
8
+ def draw
9
+ [
10
+ unique_notes.sort.join(" - "),
11
+ Keyboard.press(*unique_notes.map(&:position))
12
+ ].join("\n\n")
13
+ end
14
+
15
+ def unique_notes
16
+ strings.reject(&:dead?).each_with_object([[], []]) do |string, (positions, notes)|
17
+ unless positions.include?(string.note.position)
18
+ positions << string.note.position
19
+ notes << string.note
20
+ end
21
+ end[1]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WTFChord
2
4
  module RomanNumbersHelper
3
- ROMAN_SYMBOLS ||= %w(I II III IV V VI VII VIII IX X XII XIII XIV XV XVI XVII).unshift(nil).freeze
5
+ ROMAN_SYMBOLS ||= ("\u2160".."\u216B").to_a.unshift(nil).freeze
4
6
 
5
7
  def romanize(number)
6
8
  ROMAN_SYMBOLS[number]
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module WTFChord
4
+ class Keyboard
5
+ FRAME = <<~EOF
6
+ ┌─┬─┬┬─┬─┬─┬─┬┬─┬┬─┬─┐
7
+ │ │ ││ │ │ │ ││ ││ │ │
8
+ │ └┬┘└┬┘ │ └┬┘└┬┘└┬┘ │
9
+ │ │ │ │ │ │ │ │
10
+ └──┴──┴──┴──┴──┴──┴──┘
11
+ EOF
12
+
13
+ Key = Struct.new(:offset)
14
+ class Key
15
+ singleton_class.attr_accessor :select_symbol
16
+ singleton_class.alias_method :[], :new
17
+
18
+ def select(frame)
19
+ frame[offset] = self.class.select_symbol
20
+ frame
21
+ end
22
+ end
23
+
24
+ W = Class.new(Key) { self.select_symbol = "▐▌" }
25
+ B = Class.new(Key) { self.select_symbol = "█" }
26
+
27
+ KEYS = {
28
+ 1 => W[70...72],
29
+ 2 => B[26...27],
30
+ 3 => W[73...75],
31
+ 4 => B[29...30],
32
+ 5 => W[76...78],
33
+ 6 => W[79...81],
34
+ 7 => B[35...36],
35
+ 8 => W[82...84],
36
+ 9 => B[38...39],
37
+ 10 => W[85...87],
38
+ 11 => B[41...42],
39
+ 12 => W[88...90]
40
+ }
41
+
42
+ def self.press(*positions)
43
+ positions.each_with_object(FRAME.dup) do |pos, frame|
44
+ KEYS.fetch(pos).select(frame)
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module WTFChord
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  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.5.0
4
+ version: 0.6.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-08-17 00:00:00.000000000 Z
11
+ date: 2021-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: methadone
@@ -100,10 +100,12 @@ files:
100
100
  - lib/wtf_chord/formatter.rb
101
101
  - lib/wtf_chord/formatters/base.rb
102
102
  - lib/wtf_chord/formatters/default.rb
103
+ - lib/wtf_chord/formatters/piano.rb
103
104
  - lib/wtf_chord/formatters/simple.rb
104
105
  - lib/wtf_chord/fretboard.rb
105
106
  - lib/wtf_chord/guitar_string.rb
106
107
  - lib/wtf_chord/helpers/roman_numbers_helper.rb
108
+ - lib/wtf_chord/keyboard.rb
107
109
  - lib/wtf_chord/note.rb
108
110
  - lib/wtf_chord/pitch.rb
109
111
  - lib/wtf_chord/rules.rb
@@ -128,10 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
130
  - !ruby/object:Gem::Version
129
131
  version: '0'
130
132
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.6.6
133
+ rubygems_version: 3.0.3
133
134
  signing_key:
134
135
  specification_version: 4
135
136
  summary: "‘WTF Chord?’ is the Ruby guitar chords generator library."
136
137
  test_files: []
137
- has_rdoc: