coltrane 3.4.2 → 4.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +15 -4
- data/bin/old-coltrane +29 -0
- data/coltrane.gemspec +4 -4
- data/exe/coltrane +77 -47
- data/lib/.DS_Store +0 -0
- data/lib/coltrane/.DS_Store +0 -0
- data/lib/coltrane/commands.rb +4 -9
- data/lib/coltrane/commands/available_chord_representations.rb +9 -0
- data/lib/coltrane/commands/available_classic_scales.rb +9 -0
- data/lib/coltrane/commands/available_notable_progressions.rb +9 -0
- data/lib/coltrane/commands/available_representations.rb +9 -0
- data/lib/coltrane/commands/command.rb +3 -54
- data/lib/coltrane/commands/find_chord_by_notes.rb +9 -0
- data/lib/coltrane/commands/find_common_chords.rb +9 -0
- data/lib/coltrane/commands/find_progressions_from_chords.rb +9 -0
- data/lib/coltrane/commands/find_scale_by_chords.rb +9 -0
- data/lib/coltrane/commands/find_scale_by_notes.rb +9 -0
- data/lib/coltrane/commands/get_chords_from_notable_progression.rb +9 -0
- data/lib/coltrane/commands/get_chords_from_progression.rb +9 -0
- data/lib/coltrane/commands/get_chords_from_scale.rb +9 -0
- data/lib/coltrane/commands/get_chords_from_string.rb +11 -0
- data/lib/coltrane/commands/get_classic_scale.rb +9 -0
- data/lib/coltrane/commands/get_notes.rb +9 -0
- data/lib/coltrane/commands/get_notes_from_string.rb +9 -0
- data/lib/coltrane/commands/get_representation_chords.rb +18 -0
- data/lib/coltrane/commands/get_representation_notes.rb +12 -0
- data/lib/coltrane/commands/render.rb +9 -0
- data/lib/coltrane/renderers/text_renderer/hash_drawer.rb +1 -0
- data/lib/coltrane/renderers/text_renderer/theory_chord_drawer.rb +1 -2
- data/lib/coltrane/theory/classic_scales.rb +1 -1
- data/lib/coltrane/ui.rb +9 -0
- data/lib/coltrane/ui/.DS_Store +0 -0
- data/lib/coltrane/ui/router.rb +87 -0
- data/lib/coltrane/ui/views.rb +4 -0
- data/lib/coltrane/ui/views/chords.rb +19 -0
- data/lib/coltrane/ui/views/custom_progression.rb +27 -0
- data/lib/coltrane/ui/views/find_chord_by_notes.rb +16 -0
- data/lib/coltrane/ui/views/find_chords_in_scale.rb +34 -0
- data/lib/coltrane/ui/views/find_common_chords_in_scales.rb +40 -0
- data/lib/coltrane/ui/views/find_progressions_from_chords.rb +14 -0
- data/lib/coltrane/ui/views/find_scale.rb +14 -0
- data/lib/coltrane/ui/views/find_scale_by_chords.rb +16 -0
- data/lib/coltrane/ui/views/find_scale_by_notes.rb +16 -0
- data/lib/coltrane/ui/views/index.rb +14 -0
- data/lib/coltrane/ui/views/notes.rb +20 -0
- data/lib/coltrane/ui/views/progressions.rb +18 -0
- data/lib/coltrane/ui/views/scales.rb +17 -0
- data/lib/coltrane/ui/views/show_chord.rb +21 -0
- data/lib/coltrane/ui/views/show_progression.rb +26 -0
- data/lib/coltrane/ui/views/show_scale.rb +26 -0
- data/lib/coltrane/ui/views/view.rb +47 -0
- data/lib/coltrane/version.rb +1 -1
- metadata +64 -28
- data/lib/coltrane/commands/chords.rb +0 -93
- data/lib/coltrane/commands/common_chords.rb +0 -33
- data/lib/coltrane/commands/errors.rb +0 -44
- data/lib/coltrane/commands/find_guitar_chord.rb +0 -25
- data/lib/coltrane/commands/find_progression.rb +0 -28
- data/lib/coltrane/commands/find_scale.rb +0 -39
- data/lib/coltrane/commands/notes.rb +0 -50
- data/lib/coltrane/commands/progression.rb +0 -28
- data/lib/coltrane/commands/scale.rb +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2dce8fab34c2d90d0317a80349b7fd3bec643bd0f32c491a351a0251251349b
|
4
|
+
data.tar.gz: de1772b25200811627df8937663417db2c9a9ad5f8106e05ba0c6a41f6ccc96d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0ed0415983d75c7fce264111e014e2c2bb3d2f0ae949c7579743668ea09678e93df6e85c450f66c4543fd13f60c89dd6711bc023cfb08c00a83300228713c5
|
7
|
+
data.tar.gz: 45fe81700b815b8762c39ad4d365ccafebfc8d7afa4d5e225f6344f70de713ce23d9d601273ee08a38f59bdb696815d2dd27cfd7920eae9f15f36f6fb3feb9eb
|
data/.DS_Store
ADDED
Binary file
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,9 @@
|
|
5
5
|
- Fix chords so that they generate a barre and a non-barre version and prevent
|
6
6
|
barre chords from picking notes before the barre.
|
7
7
|
|
8
|
+
## [4.0.0]
|
9
|
+
- Includes totally revamped, easy to use command line interface.
|
10
|
+
|
8
11
|
## [3.4.2]
|
9
12
|
- Fixes guitar strings rendering order (#41)
|
10
13
|
|
data/Gemfile.lock
CHANGED
@@ -1,18 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
coltrane (
|
4
|
+
coltrane (4.0.3)
|
5
|
+
activesupport (> 5.2)
|
6
|
+
cli-ui (~> 1.1)
|
5
7
|
color (~> 1.8)
|
6
8
|
dry-monads (~> 0.4)
|
7
9
|
paint (~> 2.0)
|
8
|
-
pedrozath-mercenary (= 0.3.8)
|
9
|
-
tty-reader (~> 0.2)
|
10
10
|
|
11
11
|
GEM
|
12
12
|
remote: https://rubygems.org/
|
13
13
|
specs:
|
14
|
+
activesupport (5.2.1)
|
15
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
16
|
+
i18n (>= 0.7, < 2)
|
17
|
+
minitest (~> 5.1)
|
18
|
+
tzinfo (~> 1.1)
|
14
19
|
ast (2.4.0)
|
15
20
|
byebug (10.0.2)
|
21
|
+
cli-ui (1.1.4)
|
16
22
|
coderay (1.1.2)
|
17
23
|
color (1.8)
|
18
24
|
concurrent-ruby (1.0.5)
|
@@ -27,8 +33,11 @@ GEM
|
|
27
33
|
equatable (0.5.0)
|
28
34
|
hike (1.2.3)
|
29
35
|
hitimes (1.2.6)
|
36
|
+
i18n (1.1.1)
|
37
|
+
concurrent-ruby (~> 1.0)
|
30
38
|
json (2.1.0)
|
31
39
|
method_source (0.9.0)
|
40
|
+
minitest (5.11.3)
|
32
41
|
necromancer (0.4.0)
|
33
42
|
opal (0.10.5)
|
34
43
|
hike (~> 1.2)
|
@@ -44,7 +53,6 @@ GEM
|
|
44
53
|
pastel (0.7.2)
|
45
54
|
equatable (~> 0.5.0)
|
46
55
|
tty-color (~> 0.4.0)
|
47
|
-
pedrozath-mercenary (0.3.8)
|
48
56
|
powerpack (0.1.1)
|
49
57
|
pry (0.11.3)
|
50
58
|
coderay (~> 1.1.0)
|
@@ -85,6 +93,7 @@ GEM
|
|
85
93
|
sprockets (3.7.1)
|
86
94
|
concurrent-ruby (~> 1.0)
|
87
95
|
rack (> 1, < 3)
|
96
|
+
thread_safe (0.3.6)
|
88
97
|
tilt (2.0.8)
|
89
98
|
timers (4.1.2)
|
90
99
|
hitimes
|
@@ -101,6 +110,8 @@ GEM
|
|
101
110
|
tty-screen (~> 0.6.4)
|
102
111
|
wisper (~> 2.0.0)
|
103
112
|
tty-screen (0.6.4)
|
113
|
+
tzinfo (1.2.5)
|
114
|
+
thread_safe (~> 0.1)
|
104
115
|
unicode-display_width (1.3.0)
|
105
116
|
wisper (2.0.0)
|
106
117
|
|
data/bin/old-coltrane
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'old-coltrane' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("coltrane", "old-coltrane")
|
data/coltrane.gemspec
CHANGED
@@ -32,11 +32,11 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ["lib"]
|
34
34
|
|
35
|
-
spec.add_runtime_dependency 'tty-reader', '~> 0.2'
|
36
35
|
spec.add_runtime_dependency 'dry-monads', '~> 0.4'
|
37
36
|
spec.add_runtime_dependency 'paint', '~> 2.0'
|
38
37
|
spec.add_runtime_dependency 'color', '~> 1.8'
|
39
|
-
spec.add_runtime_dependency '
|
40
|
-
spec.
|
41
|
-
spec.add_development_dependency "
|
38
|
+
spec.add_runtime_dependency 'cli-ui', '~> 1.1'
|
39
|
+
spec.add_runtime_dependency 'activesupport', '> 5.2'
|
40
|
+
spec.add_development_dependency "bundler", '~> 1.14'
|
41
|
+
spec.add_development_dependency "rake", '~> 10.0'
|
42
42
|
end
|
data/exe/coltrane
CHANGED
@@ -1,65 +1,95 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
|
-
|
4
3
|
$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
|
5
4
|
|
6
|
-
require '
|
7
|
-
require 'color'
|
5
|
+
require 'coltrane/ui'
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
module Coltrane
|
8
|
+
module UI
|
9
|
+
class App
|
10
|
+
attr_reader :router
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def self.start(initial_route)
|
13
|
+
if ENV['COLORTERM'] == 'truecolor'
|
14
|
+
Paint.mode = 0xFFFFFF
|
15
|
+
else
|
16
|
+
Paint.mode = 0
|
17
|
+
puts "This terminal doesn't seem to support true color. " \
|
18
|
+
"Try something like iTerm2 (for macOS), VTE or Konsole (for linux) or Hyper" \
|
19
|
+
" (for Windows) and you'll see the true magic!"
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
path, params = initial_route.split(' ').each_with_object([nil, {}]) do |segment, memo|
|
23
|
+
if segment =~ /:/
|
24
|
+
key, value = segment.split(':')
|
25
|
+
memo[1].merge!([[key.to_sym, value.gsub('-', ' ')]].to_h)
|
26
|
+
else
|
27
|
+
memo[0] = [memo[0], segment].compact.join(' ')
|
28
|
+
end
|
29
|
+
end
|
26
30
|
|
27
|
-
|
28
|
-
|
29
|
-
|
31
|
+
response = {path: (path || ''), **params}
|
32
|
+
loop { response = app.flow(**response) }
|
33
|
+
end
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
|
35
|
+
def self.app
|
36
|
+
@app ||= new
|
37
|
+
end
|
34
38
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
39
|
+
def initialize
|
40
|
+
@router = Router.new
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
def ask_questions(questions)
|
44
|
+
questions.map { |name, question| [name, ask_question(question)] }.to_h
|
45
|
+
end
|
46
|
+
|
47
|
+
def ask_question(question)
|
48
|
+
CLI::UI::Prompt.ask(question[:statement], options: question[:options])
|
49
|
+
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
puts begin
|
55
|
-
command_path.reduce(p) do |memo, key|
|
56
|
-
memo.commands.delete(key.to_sym)
|
57
|
-
end || "\n Sorry, command found."
|
51
|
+
def navigation(params)
|
52
|
+
return {} if params.empty?
|
53
|
+
CLI::UI::Prompt.ask('What to do now?') do |h|
|
54
|
+
params.each do |key, _value|
|
55
|
+
h.option("Different #{key}") { params[key] = nil }
|
56
|
+
end
|
57
|
+
h.option("Go back") { params[:path] = '' }
|
58
58
|
end
|
59
|
+
params
|
60
|
+
end
|
61
|
+
|
62
|
+
def output(response)
|
63
|
+
return unless response[:content]
|
64
|
+
puts [
|
65
|
+
nil,
|
66
|
+
"-> coltrane #{router.url}",
|
67
|
+
nil,
|
68
|
+
response[:content],
|
69
|
+
nil
|
70
|
+
]
|
71
|
+
end
|
72
|
+
|
73
|
+
def flow(response)
|
74
|
+
raise 'Response is empty' unless response
|
75
|
+
output(response)
|
76
|
+
response.delete(:content)
|
77
|
+
questions = response&.delete(:questions) || {}
|
78
|
+
response.merge!(navigation(response)) unless response.has_key?(:path) || questions.any?
|
79
|
+
response.merge!(ask_questions(questions)) if questions.any?
|
80
|
+
exit if response[:path] == 'exit'
|
81
|
+
router.get(**response.compact)
|
82
|
+
rescue => e
|
83
|
+
response.delete(:path)
|
84
|
+
puts e
|
85
|
+
retry
|
86
|
+
end
|
87
|
+
|
88
|
+
def exit
|
89
|
+
Kernel.exit(0)
|
59
90
|
end
|
60
91
|
end
|
61
92
|
end
|
62
|
-
|
63
|
-
p.default_command(:shell)
|
64
93
|
end
|
65
94
|
|
95
|
+
Coltrane::UI::App.start(ARGV.join(' '))
|
data/lib/.DS_Store
ADDED
Binary file
|
Binary file
|
data/lib/coltrane/commands.rb
CHANGED
@@ -3,13 +3,8 @@
|
|
3
3
|
require 'coltrane'
|
4
4
|
require 'coltrane/representation'
|
5
5
|
require 'coltrane/renderers'
|
6
|
-
|
7
6
|
require 'coltrane/commands/command'
|
8
|
-
|
9
|
-
|
10
|
-
require
|
11
|
-
|
12
|
-
require 'coltrane/commands/common_chords'
|
13
|
-
require 'coltrane/commands/find_scale'
|
14
|
-
require 'coltrane/commands/find_progression'
|
15
|
-
require 'coltrane/commands/find_guitar_chord'
|
7
|
+
|
8
|
+
Dir[File.expand_path('../commands/*', __FILE__)].map do |f|
|
9
|
+
require(f)
|
10
|
+
end
|
@@ -1,61 +1,10 @@
|
|
1
1
|
module Coltrane
|
2
2
|
module Commands
|
3
3
|
class Command
|
4
|
-
|
5
|
-
on: [
|
6
|
-
'--on <INSTRUMENT>',
|
7
|
-
'Shows the notes on the given instrument/representation type. ' \
|
8
|
-
'Can be text, piano, guitar, ukulele, bass.' \
|
9
|
-
'You can also provide a custom guitar using the following format:' \
|
10
|
-
'--on custom_guitar=D2-A3-D3-B3-C3'
|
11
|
-
],
|
4
|
+
attr_reader :error
|
12
5
|
|
13
|
-
|
14
|
-
|
15
|
-
'Chooses which additional information to display: ' \
|
16
|
-
'marks, notes, intervals or degrees'
|
17
|
-
],
|
18
|
-
|
19
|
-
voicings: [
|
20
|
-
'--voicings <NUMBER>',
|
21
|
-
'Number of voicings for guitar like instruments. Default is 6' \
|
22
|
-
'provided they are separated by dashes'
|
23
|
-
]
|
24
|
-
}
|
25
|
-
|
26
|
-
def custom_guitar
|
27
|
-
on
|
28
|
-
.to_s
|
29
|
-
.split('=')
|
30
|
-
.fetch(1)
|
31
|
-
.split('-')
|
32
|
-
.yield_self { |tuning| Representation::Guitar.new(tuning: tuning) }
|
33
|
-
end
|
34
|
-
|
35
|
-
def render
|
36
|
-
puts "\n" + Renderers::TextRenderer.render(
|
37
|
-
representation, **renderer_options
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def renderer_options
|
42
|
-
{}
|
43
|
-
end
|
44
|
-
|
45
|
-
class << self
|
46
|
-
|
47
|
-
def subclasses
|
48
|
-
@subclasses ||= []
|
49
|
-
end
|
50
|
-
|
51
|
-
def inherited(base)
|
52
|
-
subclasses << base
|
53
|
-
super(base)
|
54
|
-
end
|
55
|
-
|
56
|
-
def add_shared_option(option_name, mercenary_command)
|
57
|
-
mercenary_command.option(option_name, *COMMON_OPTIONS[option_name])
|
58
|
-
end
|
6
|
+
def self.run(*args)
|
7
|
+
new.run(*args)
|
59
8
|
end
|
60
9
|
end
|
61
10
|
end
|