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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG.md +6 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +88 -75
  8. data/bin/bundle +23 -14
  9. data/bin/console +24 -12
  10. data/bin/gambiarra +29 -0
  11. data/bin/old-coltrane +29 -0
  12. data/bin/setup +27 -6
  13. data/bin/thor +1 -1
  14. data/coltrane.gemspec +4 -4
  15. data/exe/coltrane +14 -55
  16. data/lib/.DS_Store +0 -0
  17. data/lib/coltrane/.DS_Store +0 -0
  18. data/lib/coltrane/commands.rb +4 -9
  19. data/lib/coltrane/commands/available_chord_representations.rb +9 -0
  20. data/lib/coltrane/commands/available_classic_scales.rb +9 -0
  21. data/lib/coltrane/commands/available_notable_progressions.rb +9 -0
  22. data/lib/coltrane/commands/available_representations.rb +9 -0
  23. data/lib/coltrane/commands/command.rb +3 -54
  24. data/lib/coltrane/commands/find_chord_by_notes.rb +9 -0
  25. data/lib/coltrane/commands/find_common_chords.rb +9 -0
  26. data/lib/coltrane/commands/find_progressions_from_chords.rb +9 -0
  27. data/lib/coltrane/commands/find_scale_by_chords.rb +9 -0
  28. data/lib/coltrane/commands/find_scale_by_notes.rb +9 -0
  29. data/lib/coltrane/commands/get_chords_from_notable_progression.rb +9 -0
  30. data/lib/coltrane/commands/get_chords_from_progression.rb +9 -0
  31. data/lib/coltrane/commands/get_chords_from_scale.rb +9 -0
  32. data/lib/coltrane/commands/get_chords_from_string.rb +11 -0
  33. data/lib/coltrane/commands/get_classic_scale.rb +9 -0
  34. data/lib/coltrane/commands/get_notes.rb +9 -0
  35. data/lib/coltrane/commands/get_notes_from_string.rb +9 -0
  36. data/lib/coltrane/commands/get_representation_chords.rb +18 -0
  37. data/lib/coltrane/commands/get_representation_notes.rb +12 -0
  38. data/lib/coltrane/commands/render.rb +9 -0
  39. data/lib/coltrane/renderers/text_renderer/hash_drawer.rb +1 -0
  40. data/lib/coltrane/renderers/text_renderer/representation_guitar_chord_drawer.rb +2 -2
  41. data/lib/coltrane/renderers/text_renderer/representation_piano_note_set_drawer.rb +1 -1
  42. data/lib/coltrane/renderers/text_renderer/theory_chord_drawer.rb +1 -2
  43. data/lib/coltrane/theory/classic_scales.rb +1 -1
  44. data/lib/coltrane/theory/interval.rb +1 -1
  45. data/lib/coltrane/ui.rb +8 -0
  46. data/lib/coltrane/ui/.DS_Store +0 -0
  47. data/lib/coltrane/ui/base_view.rb +9 -0
  48. data/lib/coltrane/ui/views/.DS_Store +0 -0
  49. data/lib/coltrane/ui/views/chords.rb +19 -0
  50. data/lib/coltrane/ui/views/custom_progression.rb +27 -0
  51. data/lib/coltrane/ui/views/find_chord_by_notes.rb +16 -0
  52. data/lib/coltrane/ui/views/find_chords_in_scale.rb +36 -0
  53. data/lib/coltrane/ui/views/find_common_chords_in_scales.rb +40 -0
  54. data/lib/coltrane/ui/views/find_progressions_from_chords.rb +14 -0
  55. data/lib/coltrane/ui/views/find_scale.rb +14 -0
  56. data/lib/coltrane/ui/views/find_scale_by_chords.rb +16 -0
  57. data/lib/coltrane/ui/views/find_scale_by_notes.rb +16 -0
  58. data/lib/coltrane/ui/views/index.rb +14 -0
  59. data/lib/coltrane/ui/views/notes.rb +20 -0
  60. data/lib/coltrane/ui/views/progressions.rb +18 -0
  61. data/lib/coltrane/ui/views/scales.rb +17 -0
  62. data/lib/coltrane/ui/views/show_chord.rb +21 -0
  63. data/lib/coltrane/ui/views/show_progression.rb +26 -0
  64. data/lib/coltrane/ui/views/show_scale.rb +26 -0
  65. data/lib/coltrane/version.rb +1 -1
  66. metadata +61 -26
  67. data/lib/coltrane/commands/chords.rb +0 -93
  68. data/lib/coltrane/commands/common_chords.rb +0 -33
  69. data/lib/coltrane/commands/errors.rb +0 -44
  70. data/lib/coltrane/commands/find_guitar_chord.rb +0 -25
  71. data/lib/coltrane/commands/find_progression.rb +0 -28
  72. data/lib/coltrane/commands/find_scale.rb +0 -39
  73. data/lib/coltrane/commands/notes.rb +0 -50
  74. data/lib/coltrane/commands/progression.rb +0 -28
  75. 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, 150) =~ /This file was generated by Bundler/
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.
@@ -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 'pedrozath-mercenary', '0.3.8'
40
- spec.add_development_dependency "bundler", '~> 1.14'
41
- spec.add_development_dependency "rake", '~> 10.0'
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
@@ -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 'paint'
7
- require 'color'
8
-
9
- require 'pedrozath-mercenary'
10
- require 'coltrane/commands'
11
-
12
- if ENV['COLORTERM'] == 'truecolor'
13
- Paint.mode = 0xFFFFFF
14
- else
15
- Paint.mode = 0
16
- puts "This terminal doesn't seem to support true color. " \
17
- "Try something like iTerm2 (for macOS), VTE or Konsole (for linux) or Hyper" \
18
- " (for Windows) and you'll see the true magic!"
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(' '))
Binary file
Binary file
@@ -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
- require 'coltrane/commands/notes'
9
- require 'coltrane/commands/chords'
10
- require 'coltrane/commands/scale'
11
- require 'coltrane/commands/progression'
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
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class AvailableChordRepresentations < Command
4
+ def run
5
+ return ['GuitarChordChart'] + AvailableRepresentations.run
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class AvailableClassicScales < Command
4
+ def run
5
+ Theory::Scale.known_scales
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class AvailableNotableProgressions < Command
4
+ def run
5
+ Theory::NotableProgressions::PROGRESSIONS.keys
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class AvailableRepresentations < Command
4
+ def run
5
+ ['Text'] + Representation.constants.map(&:to_s)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,61 +1,10 @@
1
1
  module Coltrane
2
2
  module Commands
3
3
  class Command
4
- COMMON_OPTIONS = {
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
- flavor: [
14
- '--flavor <FLAVOR>',
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,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindChordByNotes < Command
4
+ def run(notes)
5
+ Theory::Chord.new(notes: notes)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindCommonChords < Command
4
+ def run(*scales)
5
+ scales.map(&:chords).reduce(&:&)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindProgressionsFromChords < Command
4
+ def run(*chords)
5
+ Theory::Progression.find(*chords)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindScaleByChords < Command
4
+ def run(*chords)
5
+ Theory::Scale.having_chords(*chords)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class FindScaleByNotes < Command
4
+ def run(notes)
5
+ Theory::Scale.having_notes(*notes)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetChordsFromNotableProgression < Command
4
+ def run(progression, key)
5
+ Theory::Progression.send(progression.underscore, key).chords
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetChordsFromProgression < Command
4
+ def run(notation, key)
5
+ Theory::Progression.new(notation, key: key).chords
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetChordsFromScale < Command
4
+ def run(scale, type, size)
5
+ scale.send(type == 'tertians' ? :tertians : :chords)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetChordsFromString < Command
4
+ def run(string)
5
+ string.split(' ').map do |chord|
6
+ Theory::Chord.new(name: chord)
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetClassicScale < Command
4
+ def run(scale, tone)
5
+ Theory::Scale.fetch(scale, tone)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetNotes < Command
4
+ def run(*notes)
5
+ Theory::NoteSet[*notes]
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class GetNotesFromString < Command
4
+ def run(string)
5
+ GetNotes.run(*string.split(' '))
6
+ end
7
+ end
8
+ end
9
+ 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
@@ -0,0 +1,9 @@
1
+ module Coltrane
2
+ module Commands
3
+ class Render < Command
4
+ def run(object)
5
+ Renderers::TextRenderer.render(object)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -5,6 +5,7 @@ module Coltrane
5
5
  alias hash model
6
6
 
7
7
  def render
8
+ options = hash.delete(:options) || {}
8
9
  hash.map { |k, v|
9
10
  "#{k}: \n\n" +
10
11
  TextRenderer.render(v, **options)
@@ -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('') : base_color('│')
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, "\u266E")
43
+ when :notes then note.pretty_name.to_s.ljust(2, " ")
44
44
  end
45
45
  end
46
46
  end