coltrane 3.4.2 → 4.1.0
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/.DS_Store +0 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +88 -75
- data/bin/bundle +23 -14
- data/bin/console +24 -12
- data/bin/gambiarra +29 -0
- data/bin/old-coltrane +29 -0
- data/bin/setup +27 -6
- data/bin/thor +1 -1
- data/coltrane.gemspec +4 -4
- data/exe/coltrane +14 -55
- 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/representation_guitar_chord_drawer.rb +2 -2
- data/lib/coltrane/renderers/text_renderer/representation_piano_note_set_drawer.rb +1 -1
- data/lib/coltrane/renderers/text_renderer/theory_chord_drawer.rb +1 -2
- data/lib/coltrane/theory/classic_scales.rb +1 -1
- data/lib/coltrane/theory/interval.rb +1 -1
- data/lib/coltrane/ui.rb +8 -0
- data/lib/coltrane/ui/.DS_Store +0 -0
- data/lib/coltrane/ui/base_view.rb +9 -0
- data/lib/coltrane/ui/views/.DS_Store +0 -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 +36 -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/version.rb +1 -1
- metadata +61 -26
- 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
data/bin/thor
CHANGED
@@ -15,7 +15,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
|
15
15
|
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
16
|
|
17
17
|
if File.file?(bundle_binstub)
|
18
|
-
if File.read(bundle_binstub,
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
19
|
load(bundle_binstub)
|
20
20
|
else
|
21
21
|
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
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'
|
36
|
+
spec.add_runtime_dependency 'gambiarra', '~> 0'
|
37
37
|
spec.add_runtime_dependency 'paint', '~> 2.0'
|
38
38
|
spec.add_runtime_dependency 'color', '~> 1.8'
|
39
|
-
spec.add_runtime_dependency '
|
40
|
-
spec.add_development_dependency "bundler",
|
41
|
-
spec.add_development_dependency "rake",
|
39
|
+
spec.add_runtime_dependency 'activesupport', '> 5.2'
|
40
|
+
spec.add_development_dependency "bundler", '~> 2.2.5'
|
41
|
+
spec.add_development_dependency "rake", '~> 10.0'
|
42
42
|
end
|
data/exe/coltrane
CHANGED
@@ -1,65 +1,24 @@
|
|
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
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
if ENV['COLORTERM'] == 'truecolor'
|
13
|
-
|
14
|
-
else
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
Mercenary.program(:Coltrane) do |p|
|
22
|
-
p.version Coltrane::VERSION
|
23
|
-
p.description <<~DESC
|
24
|
-
A music querying interface
|
25
|
-
by Pedro Maciel (pedro@pedromaciel.com)
|
26
|
-
|
27
|
-
Check the chat room for project help/discussion/contribution: https://coltrane-ruby.herokuapp.com
|
28
|
-
DESC
|
29
|
-
p.syntax 'coltrane <subcommand> [options]'
|
30
|
-
|
31
|
-
Coltrane::Commands::Command.subclasses.each do |command|
|
32
|
-
command.mercenary_init(p)
|
33
|
-
end
|
34
|
-
|
35
|
-
p.command(:about) do |c|
|
36
|
-
c.description 'Shows this screen'
|
37
|
-
c.action { puts p }
|
38
|
-
end
|
39
|
-
|
40
|
-
p.command(:shell) do |c|
|
41
|
-
c.description 'Starts an interactive shell'
|
42
|
-
c.action do
|
43
|
-
system File.expand_path('../../bin', __FILE__) + "/coltrane-interactive"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
p.command(:help) do |c|
|
48
|
-
c.description 'May give you some help.'
|
49
|
-
c.syntax 'help <command> [subcommand, sub-subcommand, ...]'
|
50
|
-
c.action do |(*command_path), _options|
|
51
|
-
if command_path.empty?
|
52
|
-
puts p
|
53
|
-
else
|
54
|
-
puts begin
|
55
|
-
command_path.reduce(p) do |memo, key|
|
56
|
-
memo.commands.delete(key.to_sym)
|
57
|
-
end || "\n Sorry, command found."
|
5
|
+
require 'coltrane/ui'
|
6
|
+
|
7
|
+
module Coltrane
|
8
|
+
module UI
|
9
|
+
class App < Gambiarra::App
|
10
|
+
def setup
|
11
|
+
if ENV['COLORTERM'] == 'truecolor'
|
12
|
+
Paint.mode = 0xFFFFFF
|
13
|
+
else
|
14
|
+
Paint.mode = 0
|
15
|
+
puts "This terminal doesn't seem to support true color. " \
|
16
|
+
"Try something like iTerm2 (for macOS), VTE or Konsole (for linux) or Hyper" \
|
17
|
+
" (for Windows) and you'll see the true magic!"
|
58
18
|
end
|
59
19
|
end
|
60
20
|
end
|
61
21
|
end
|
62
|
-
|
63
|
-
p.default_command(:shell)
|
64
22
|
end
|
65
23
|
|
24
|
+
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
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Coltrane
|
2
|
+
module Commands
|
3
|
+
class GetRepresentationChords < Command
|
4
|
+
def run(representation, chords)
|
5
|
+
chords.map do |chord|
|
6
|
+
if representation == 'GuitarChordChart'
|
7
|
+
{
|
8
|
+
chord.name => Representation::Guitar.find_chords(chord).first(4),
|
9
|
+
options: { layout: :horizontal, per_row: 4 }
|
10
|
+
}
|
11
|
+
else
|
12
|
+
{ chord.name => GetRepresentationNotes.run(representation, chord.notes) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Coltrane
|
2
|
+
module Commands
|
3
|
+
class GetRepresentationNotes < Command
|
4
|
+
def run(representation, notes)
|
5
|
+
return notes if representation == 'Text'
|
6
|
+
Object
|
7
|
+
.const_get("Coltrane::Representation::#{representation}")
|
8
|
+
.find_notes(notes)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -77,7 +77,7 @@ module Coltrane
|
|
77
77
|
memo +
|
78
78
|
if chord.guitar_notes.select do |n|
|
79
79
|
n.string == s && n.fret == 0 end.any?
|
80
|
-
highlight '
|
80
|
+
highlight '• '
|
81
81
|
elsif chord.guitar_notes.select { |n| n.string == s && n.fret.nil? }.any?
|
82
82
|
alt 'x '
|
83
83
|
else
|
@@ -87,7 +87,7 @@ module Coltrane
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def render_note(found)
|
90
|
-
found ? highlight('
|
90
|
+
found ? highlight('•') : base_color('│')
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -40,7 +40,7 @@ module Coltrane
|
|
40
40
|
when :intervals then (note_set.root - note).name
|
41
41
|
when :marks then '◼ '
|
42
42
|
when :degrees then note_set.notes.degree(note).to_s.rjust(2, '0')
|
43
|
-
when :notes then note.pretty_name.to_s.ljust(2, "
|
43
|
+
when :notes then note.pretty_name.to_s.ljust(2, " ")
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|