coltrane 3.4.2 → 4.0.3

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.ruby-version +1 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Gemfile.lock +15 -4
  6. data/bin/old-coltrane +29 -0
  7. data/coltrane.gemspec +4 -4
  8. data/exe/coltrane +77 -47
  9. data/lib/.DS_Store +0 -0
  10. data/lib/coltrane/.DS_Store +0 -0
  11. data/lib/coltrane/commands.rb +4 -9
  12. data/lib/coltrane/commands/available_chord_representations.rb +9 -0
  13. data/lib/coltrane/commands/available_classic_scales.rb +9 -0
  14. data/lib/coltrane/commands/available_notable_progressions.rb +9 -0
  15. data/lib/coltrane/commands/available_representations.rb +9 -0
  16. data/lib/coltrane/commands/command.rb +3 -54
  17. data/lib/coltrane/commands/find_chord_by_notes.rb +9 -0
  18. data/lib/coltrane/commands/find_common_chords.rb +9 -0
  19. data/lib/coltrane/commands/find_progressions_from_chords.rb +9 -0
  20. data/lib/coltrane/commands/find_scale_by_chords.rb +9 -0
  21. data/lib/coltrane/commands/find_scale_by_notes.rb +9 -0
  22. data/lib/coltrane/commands/get_chords_from_notable_progression.rb +9 -0
  23. data/lib/coltrane/commands/get_chords_from_progression.rb +9 -0
  24. data/lib/coltrane/commands/get_chords_from_scale.rb +9 -0
  25. data/lib/coltrane/commands/get_chords_from_string.rb +11 -0
  26. data/lib/coltrane/commands/get_classic_scale.rb +9 -0
  27. data/lib/coltrane/commands/get_notes.rb +9 -0
  28. data/lib/coltrane/commands/get_notes_from_string.rb +9 -0
  29. data/lib/coltrane/commands/get_representation_chords.rb +18 -0
  30. data/lib/coltrane/commands/get_representation_notes.rb +12 -0
  31. data/lib/coltrane/commands/render.rb +9 -0
  32. data/lib/coltrane/renderers/text_renderer/hash_drawer.rb +1 -0
  33. data/lib/coltrane/renderers/text_renderer/theory_chord_drawer.rb +1 -2
  34. data/lib/coltrane/theory/classic_scales.rb +1 -1
  35. data/lib/coltrane/ui.rb +9 -0
  36. data/lib/coltrane/ui/.DS_Store +0 -0
  37. data/lib/coltrane/ui/router.rb +87 -0
  38. data/lib/coltrane/ui/views.rb +4 -0
  39. data/lib/coltrane/ui/views/chords.rb +19 -0
  40. data/lib/coltrane/ui/views/custom_progression.rb +27 -0
  41. data/lib/coltrane/ui/views/find_chord_by_notes.rb +16 -0
  42. data/lib/coltrane/ui/views/find_chords_in_scale.rb +34 -0
  43. data/lib/coltrane/ui/views/find_common_chords_in_scales.rb +40 -0
  44. data/lib/coltrane/ui/views/find_progressions_from_chords.rb +14 -0
  45. data/lib/coltrane/ui/views/find_scale.rb +14 -0
  46. data/lib/coltrane/ui/views/find_scale_by_chords.rb +16 -0
  47. data/lib/coltrane/ui/views/find_scale_by_notes.rb +16 -0
  48. data/lib/coltrane/ui/views/index.rb +14 -0
  49. data/lib/coltrane/ui/views/notes.rb +20 -0
  50. data/lib/coltrane/ui/views/progressions.rb +18 -0
  51. data/lib/coltrane/ui/views/scales.rb +17 -0
  52. data/lib/coltrane/ui/views/show_chord.rb +21 -0
  53. data/lib/coltrane/ui/views/show_progression.rb +26 -0
  54. data/lib/coltrane/ui/views/show_scale.rb +26 -0
  55. data/lib/coltrane/ui/views/view.rb +47 -0
  56. data/lib/coltrane/version.rb +1 -1
  57. metadata +64 -28
  58. data/lib/coltrane/commands/chords.rb +0 -93
  59. data/lib/coltrane/commands/common_chords.rb +0 -33
  60. data/lib/coltrane/commands/errors.rb +0 -44
  61. data/lib/coltrane/commands/find_guitar_chord.rb +0 -25
  62. data/lib/coltrane/commands/find_progression.rb +0 -28
  63. data/lib/coltrane/commands/find_scale.rb +0 -39
  64. data/lib/coltrane/commands/notes.rb +0 -50
  65. data/lib/coltrane/commands/progression.rb +0 -28
  66. data/lib/coltrane/commands/scale.rb +0 -46
@@ -0,0 +1,16 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class FindScaleByNotes < View
5
+ questions({
6
+ notes: { statement: 'Which Notes?' }
7
+ })
8
+
9
+ def render
10
+ notes = Commands::GetNotesFromString.run(params[:notes])
11
+ Commands::FindScaleByNotes.run(*notes)
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class Index < View
5
+ questions({
6
+ path: {
7
+ statement: "Welcome to Coltrane #{Coltrane::VERSION}",
8
+ options: %w[notes chords scales progressions exit]
9
+ }
10
+ })
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class Notes < View
5
+ questions({
6
+ notes: { statement: 'Which notes?' } ,
7
+ representation: {
8
+ statement: 'How to display?',
9
+ options: Commands::AvailableRepresentations.run
10
+ }
11
+ })
12
+
13
+ def render
14
+ notes = Commands::GetNotesFromString.run(params[:notes])
15
+ Commands::GetRepresentationNotes.run(params[:representation], notes)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class Progressions < View
5
+ questions({
6
+ path: {
7
+ statement: 'What do you need?',
8
+ options: [
9
+ 'show progression',
10
+ 'custom progression',
11
+ 'find progressions from chords'
12
+ ]
13
+ }
14
+ })
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class Scales < View
5
+ questions({
6
+ path: {
7
+ statement: 'What do you need?',
8
+ options: [
9
+ 'show scale',
10
+ 'find scale'
11
+ ]
12
+ }
13
+ })
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class ShowChord < View
5
+ questions({
6
+ chord: { statement: 'Which chord?' },
7
+ chord_representation: {
8
+ statement: 'How do you wanna see it?',
9
+ options: Commands::AvailableChordRepresentations.run
10
+ }
11
+ })
12
+
13
+ def render
14
+ chord = Commands::GetChordsFromString.run(params[:chord]).first
15
+ Commands::GetRepresentationChords.run(params[:chord_representation], [chord])
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,26 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class ShowProgression < View
5
+ questions({
6
+ progression: {
7
+ statement: 'What is the progression?',
8
+ options: Commands::AvailableNotableProgressions.run
9
+ },
10
+
11
+ representation: {
12
+ statement: 'How do you wanna see the chords?',
13
+ options: Commands::AvailableChordRepresentations.run
14
+ },
15
+
16
+ root: { statement: 'Start at which note? (Ex: C; D#; Fb)' }
17
+ })
18
+
19
+ def render
20
+ chords = Commands::GetChordsFromNotableProgression.run(*params.values_at(:progression, :root))
21
+ Commands::GetRepresentationChords.run(params[:representation], chords)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class ShowScale < View
5
+ questions({
6
+ scale: {
7
+ statement: 'Which Scale?',
8
+ options: Commands::AvailableClassicScales.run
9
+ },
10
+
11
+ tone: { statement: 'What is the root of the scale?' },
12
+
13
+ representation: {
14
+ statement: 'How to display?',
15
+ options: Commands::AvailableRepresentations.run
16
+ }
17
+ })
18
+
19
+ def render
20
+ scale = Commands::GetClassicScale.run(*params.values_at(:scale, :tone))
21
+ Commands::GetRepresentationNotes.run(params[:representation], scale.notes)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,47 @@
1
+ module Coltrane
2
+ module UI
3
+ module Views
4
+ class View
5
+ attr_reader :params, :path
6
+
7
+ class << self
8
+ def inherited(subclass)
9
+ @questions ||= {}
10
+ subclass.instance_variable_set(:@questions, @questions.deep_dup)
11
+ end
12
+
13
+ def questions(question_data)
14
+ @questions.merge!(question_data)
15
+ end
16
+
17
+ def set_path(value)
18
+ @params[:path] = value
19
+ end
20
+
21
+ def render(**params)
22
+ remaining_questions = @questions.slice(*(@questions.keys - params.keys))
23
+ return { questions: remaining_questions, **params } if remaining_questions.any?
24
+ view = new(**params)
25
+ { content: Commands::Render.run(view.render), **params }
26
+ end
27
+ end
28
+
29
+ def initialize(**params)
30
+ @params = params
31
+ end
32
+
33
+ def output(object)
34
+ self.class.output(object)
35
+ end
36
+
37
+ def go_to(path, **params)
38
+ # App.router.set_next(path, **params) and return
39
+ end
40
+
41
+ def ensure_param(param_name, &block)
42
+ @params[param_name] = block.call if @params[param_name].nil?
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coltrane
4
- VERSION = '3.4.2'
4
+ VERSION = '4.0.3'
5
5
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coltrane
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 4.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Maciel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-26 00:00:00.000000000 Z
11
+ date: 2018-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: tty-reader
14
+ name: dry-monads
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.2'
26
+ version: '0.4'
27
27
  - !ruby/object:Gem::Dependency
28
- name: dry-monads
28
+ name: paint
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '2.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.4'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: paint
42
+ name: color
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.0'
47
+ version: '1.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.0'
54
+ version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
- name: color
56
+ name: cli-ui
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.8'
61
+ version: '1.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.8'
68
+ version: '1.1'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pedrozath-mercenary
70
+ name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - ">"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.3.8
75
+ version: '5.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ">"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.3.8
82
+ version: '5.2'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -116,10 +116,12 @@ executables:
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".DS_Store"
119
120
  - ".bundle/config"
120
121
  - ".gitignore"
121
122
  - ".rspec"
122
123
  - ".rubocop.yml"
124
+ - ".ruby-version"
123
125
  - ".travis.yml"
124
126
  - CHANGELOG.md
125
127
  - CODE_OF_CONDUCT.md
@@ -148,6 +150,7 @@ files:
148
150
  - bin/ldiff
149
151
  - bin/listen
150
152
  - bin/nokogiri
153
+ - bin/old-coltrane
151
154
  - bin/opal
152
155
  - bin/opal-build
153
156
  - bin/opal-mspec
@@ -172,18 +175,30 @@ files:
172
175
  - coltrane.gemspec
173
176
  - config.ru
174
177
  - exe/coltrane
178
+ - lib/.DS_Store
175
179
  - lib/coltrane.rb
180
+ - lib/coltrane/.DS_Store
176
181
  - lib/coltrane/commands.rb
177
- - lib/coltrane/commands/chords.rb
182
+ - lib/coltrane/commands/available_chord_representations.rb
183
+ - lib/coltrane/commands/available_classic_scales.rb
184
+ - lib/coltrane/commands/available_notable_progressions.rb
185
+ - lib/coltrane/commands/available_representations.rb
178
186
  - lib/coltrane/commands/command.rb
179
- - lib/coltrane/commands/common_chords.rb
180
- - lib/coltrane/commands/errors.rb
181
- - lib/coltrane/commands/find_guitar_chord.rb
182
- - lib/coltrane/commands/find_progression.rb
183
- - lib/coltrane/commands/find_scale.rb
184
- - lib/coltrane/commands/notes.rb
185
- - lib/coltrane/commands/progression.rb
186
- - lib/coltrane/commands/scale.rb
187
+ - lib/coltrane/commands/find_chord_by_notes.rb
188
+ - lib/coltrane/commands/find_common_chords.rb
189
+ - lib/coltrane/commands/find_progressions_from_chords.rb
190
+ - lib/coltrane/commands/find_scale_by_chords.rb
191
+ - lib/coltrane/commands/find_scale_by_notes.rb
192
+ - lib/coltrane/commands/get_chords_from_notable_progression.rb
193
+ - lib/coltrane/commands/get_chords_from_progression.rb
194
+ - lib/coltrane/commands/get_chords_from_scale.rb
195
+ - lib/coltrane/commands/get_chords_from_string.rb
196
+ - lib/coltrane/commands/get_classic_scale.rb
197
+ - lib/coltrane/commands/get_notes.rb
198
+ - lib/coltrane/commands/get_notes_from_string.rb
199
+ - lib/coltrane/commands/get_representation_chords.rb
200
+ - lib/coltrane/commands/get_representation_notes.rb
201
+ - lib/coltrane/commands/render.rb
187
202
  - lib/coltrane/renderers.rb
188
203
  - lib/coltrane/renderers/renderer.rb
189
204
  - lib/coltrane/renderers/text_renderer.rb
@@ -241,6 +256,27 @@ files:
241
256
  - lib/coltrane/theory/scale_search_result.rb
242
257
  - lib/coltrane/theory/scale_set.rb
243
258
  - lib/coltrane/theory/voicing.rb
259
+ - lib/coltrane/ui.rb
260
+ - lib/coltrane/ui/.DS_Store
261
+ - lib/coltrane/ui/router.rb
262
+ - lib/coltrane/ui/views.rb
263
+ - lib/coltrane/ui/views/chords.rb
264
+ - lib/coltrane/ui/views/custom_progression.rb
265
+ - lib/coltrane/ui/views/find_chord_by_notes.rb
266
+ - lib/coltrane/ui/views/find_chords_in_scale.rb
267
+ - lib/coltrane/ui/views/find_common_chords_in_scales.rb
268
+ - lib/coltrane/ui/views/find_progressions_from_chords.rb
269
+ - lib/coltrane/ui/views/find_scale.rb
270
+ - lib/coltrane/ui/views/find_scale_by_chords.rb
271
+ - lib/coltrane/ui/views/find_scale_by_notes.rb
272
+ - lib/coltrane/ui/views/index.rb
273
+ - lib/coltrane/ui/views/notes.rb
274
+ - lib/coltrane/ui/views/progressions.rb
275
+ - lib/coltrane/ui/views/scales.rb
276
+ - lib/coltrane/ui/views/show_chord.rb
277
+ - lib/coltrane/ui/views/show_progression.rb
278
+ - lib/coltrane/ui/views/show_scale.rb
279
+ - lib/coltrane/ui/views/view.rb
244
280
  - lib/coltrane/version.rb
245
281
  - lib/core_ext.rb
246
282
  homepage: http://github.com/pedrozath/coltrane
@@ -1,93 +0,0 @@
1
- module Coltrane
2
- module Commands
3
- class Chords < Command
4
- attr_reader :chord, :flavor, :on, :preface, :voicings
5
-
6
- def initialize(chord = nil,
7
- flavor: :notes,
8
- on: :text,
9
- notes: nil,
10
- preface: nil,
11
- voicings: 4,
12
- **options)
13
- if chord
14
- @chord = chord.is_a?(Theory::Chord) ? chord : Theory::Chord.new(name: chord)
15
- elsif notes
16
- @chord = Theory::Chord.new(notes: notes&.split('-'))
17
- else
18
- raise 'Provide chord names or notes. Ex: coltrane chords Cm7-Db7, ' \
19
- 'or coltrane chords --notes C-E-G'
20
- end
21
-
22
- @flavor = flavor.to_sym
23
- @preface = preface || @chord.name
24
- @on = on.to_sym
25
- @voicings = voicings.to_i
26
- end
27
-
28
- def representation
29
- return on_model if on == :text
30
- { preface => on_model }
31
- end
32
-
33
- def on_model
34
- case on
35
- when :text then chord
36
- when :guitar then Representation::Guitar.find_chords(chord).first(voicings)
37
- when :ukulele, :ukelele then Representation::Ukulele.find_chords(chord).first(voicings)
38
- when :bass then Representation::Bass.find_notes(chord.notes)
39
- when :piano then Representation::Piano.find_notes(chord.notes)
40
- when :'guitar-frets' then Representation::Guitar.find_notes(chord.notes)
41
- when :'ukulele-frets', :'ukelele-frets' then Representation::Ukulele.find_notes(chord.notes)
42
- when /custom_guitar_frets/ then custom_guitar_notes
43
- when /custom_guitar/ then custom_guitar_chords.first(voicings)
44
- end
45
- end
46
-
47
- def custom_guitar_notes
48
- Representation::Guitar::NoteSet.new(chord.notes, guitar: custom_guitar)
49
- end
50
-
51
- def custom_guitar_chords
52
- Representation::Guitar::Chord.find(chord, guitar: custom_guitar)
53
- end
54
-
55
- def layout_horizontal?
56
- on.to_s =~ /guitar|ukulele|ukelele|bass|piano/
57
- end
58
-
59
- def renderer_options
60
- [
61
- { flavor: flavor },
62
- (
63
- {
64
- layout: :horizontal,
65
- per_row: 4,
66
- } if layout_horizontal?
67
- )
68
- ]
69
- .compact
70
- .reduce({}, :merge)
71
- end
72
-
73
- def self.mercenary_init(program)
74
- program.command(:chords) do |c|
75
- c.alias(:chord)
76
- c.syntax 'chords [<chord-name>] [--on <instrument>]'
77
- c.description 'Shows the given chord. Ex: coltrane chord Cmaj7 --on piano'
78
- c.option :notes, '--notes C-D-E', 'finds chords with those notes, ' \
79
- 'provided they are separated by dashes'
80
-
81
- add_shared_option(:flavor, c)
82
- add_shared_option(:on, c)
83
- add_shared_option(:voicings, c)
84
- c.action { |(chords), **options|
85
- (chords&.split('-') || [nil]).each { |chord|
86
- new(chord, **options).render
87
- }
88
- }
89
- end
90
- end
91
- end
92
- end
93
- end