coltrane 1.2.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -1
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +48 -3
  5. data/Rakefile +1 -1
  6. data/bin/erubis +12 -0
  7. data/bin/flay +29 -0
  8. data/bin/gitlab +29 -0
  9. data/bin/httparty +29 -0
  10. data/bin/pronto +29 -0
  11. data/bin/ruby_parse +29 -0
  12. data/bin/ruby_parse_extract_error +29 -0
  13. data/bin/thor +12 -0
  14. data/exe/coltrane +8 -6
  15. data/lib/cli/guitar.rb +7 -7
  16. data/lib/cli/representation.rb +1 -1
  17. data/lib/coltrane.rb +22 -1
  18. data/lib/coltrane/cadence.rb +0 -1
  19. data/lib/coltrane/changes.rb +5 -7
  20. data/lib/coltrane/chord.rb +7 -7
  21. data/lib/coltrane/chord_quality.rb +17 -17
  22. data/lib/coltrane/chord_substitutions.rb +3 -1
  23. data/lib/coltrane/classic_scales.rb +7 -7
  24. data/lib/coltrane/errors.rb +26 -1
  25. data/lib/coltrane/frequency.rb +50 -0
  26. data/lib/coltrane/interval.rb +23 -86
  27. data/lib/coltrane/interval_class.rb +106 -0
  28. data/lib/coltrane/interval_sequence.rb +14 -13
  29. data/lib/coltrane/notable_progressions.rb +8 -3
  30. data/lib/coltrane/note.rb +44 -73
  31. data/lib/coltrane/note_set.rb +4 -4
  32. data/lib/coltrane/pitch.rb +43 -22
  33. data/lib/coltrane/pitch_class.rb +113 -0
  34. data/lib/coltrane/progression.rb +6 -9
  35. data/lib/coltrane/roman_chord.rb +14 -14
  36. data/lib/coltrane/scale.rb +8 -10
  37. data/lib/coltrane/unordered_interval_class.rb +7 -0
  38. data/lib/coltrane/version.rb +1 -1
  39. data/lib/coltrane_instruments.rb +4 -0
  40. data/lib/coltrane_instruments/guitar.rb +7 -0
  41. data/lib/coltrane_instruments/guitar/base.rb +14 -0
  42. data/lib/coltrane_instruments/guitar/chord.rb +41 -0
  43. data/lib/coltrane_instruments/guitar/note.rb +8 -0
  44. data/lib/coltrane_instruments/guitar/string.rb +8 -0
  45. data/lib/core_ext.rb +16 -27
  46. metadata +18 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b269a0644501532a2c011d225caf6432669d42682a1183d3be2f898dc32556c5
4
- data.tar.gz: 7bdd218db4a3dfa93f8e7284790f46ba82c741fab325634f6de8e98400f911b3
3
+ metadata.gz: 80404f5ec9c45b649eae4fb0dd47bbb5b9349ca344a8d72b06561f689f9d9c56
4
+ data.tar.gz: 9e733b52b1f1d4466849fa5ef724ad4947ab93b1b60dee01475e3f9abeac043f
5
5
  SHA512:
6
- metadata.gz: 766256cb10eabb774666cf04ddc30a9a96bb537cdd50cfd982bda1726402b001ad371718a5cde6da759c68527715a72eaac4d1d9504696b34c2e17d9dd89828a
7
- data.tar.gz: e2f235be7b7c7901e8cc4967bd695528009aed2bd8af1a51ea3900cf7724a219a6a01a071a6368633eb7a9f3f3d5de3fadbf116f00d200f2889291a797cebc7f
6
+ metadata.gz: 87cab0e8294560a0185b9d2d960d36690208112b775b36002381e98bf5a93c2e6e215c00332dc0f7fd55b17dbda6a268c4069951237732b4b44dd53c2f517bbb
7
+ data.tar.gz: e3b5c7fdb14798100386449aab19bbf34442247bda37364df7601ddcf6d2196234876c0e7f27dd2af435bcd8453d1fdd24ed2e928ae2607088eebfbed1fa237c
data/CHANGELOG.md CHANGED
@@ -2,7 +2,20 @@
2
2
 
3
3
  ## [Unreleased]
4
4
  - Correct Flat/Sharp on scales
5
- - Refactor notes and add pitch frequencies, pitch classes
5
+
6
+ ## [2.0.0]
7
+
8
+ ### Changes
9
+
10
+ - Code has been completely refactored. Things are organized around frequencies.
11
+ Intervals are backed by cents, which is an logarithmic measure used to measure
12
+ the distance between 2 frequencies.
13
+
14
+ We have now a distinction between PitchClass and Note. The first is a generic
15
+ concept of Notes while the latter deals with sharps and flats logic.
16
+
17
+ That refactor will allow us to in the next versions refactor scales so that
18
+ they output proper sharps and flats (https://github.com/pedrozath/coltrane/issues/3).
6
19
 
7
20
  ## [1.2.3]
8
21
 
data/Gemfile CHANGED
@@ -6,6 +6,9 @@ group :test, :development do
6
6
  gem 'pry'
7
7
  gem 'pry-byebug'
8
8
  gem 'pry-rescue'
9
+ gem 'pronto'
10
+ gem 'pronto-flay'
11
+ gem 'pronto-rubocop'
9
12
  end
10
13
 
11
14
  group :test do
data/Gemfile.lock CHANGED
@@ -1,31 +1,62 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coltrane (1.1.3)
4
+ coltrane (1.2.4)
5
5
  color (~> 1.8)
6
6
  facets (~> 3.1)
7
- mercenary (~> 0.3)
8
7
  paint (~> 2.0)
8
+ pedrozath-mercenary (~> 0.3)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
+ addressable (2.5.2)
14
+ public_suffix (>= 2.0.2, < 4.0)
13
15
  ast (2.3.0)
14
16
  byebug (9.1.0)
15
17
  coderay (1.1.2)
16
18
  color (1.8)
17
19
  diff-lcs (1.3)
18
20
  docile (1.1.5)
21
+ erubis (2.7.0)
19
22
  facets (3.1.0)
23
+ faraday (0.14.0)
24
+ multipart-post (>= 1.2, < 3)
25
+ flay (2.10.0)
26
+ erubis (~> 2.7.0)
27
+ path_expander (~> 1.0)
28
+ ruby_parser (~> 3.0)
29
+ sexp_processor (~> 4.0)
30
+ gitlab (3.6.1)
31
+ httparty
32
+ terminal-table
33
+ httparty (0.16.0)
34
+ multi_xml (>= 0.5.2)
20
35
  interception (0.5)
21
36
  json (2.1.0)
22
- mercenary (0.3.6)
23
37
  method_source (0.9.0)
38
+ multi_xml (0.6.0)
39
+ multipart-post (2.0.0)
40
+ octokit (4.8.0)
41
+ sawyer (~> 0.8.0, >= 0.5.3)
24
42
  paint (2.0.1)
25
43
  parallel (1.12.1)
26
44
  parser (2.4.0.2)
27
45
  ast (~> 2.3)
46
+ path_expander (1.0.2)
47
+ pedrozath-mercenary (0.3.6)
28
48
  powerpack (0.1.1)
49
+ pronto (0.6.0)
50
+ gitlab (~> 3.6, >= 3.4.0)
51
+ octokit (~> 4.3, >= 4.1.0)
52
+ rugged (~> 0.24, >= 0.23.0)
53
+ thor (~> 0.19.0)
54
+ pronto-flay (0.6.2)
55
+ flay (~> 2.8)
56
+ pronto (~> 0.6.0)
57
+ pronto-rubocop (0.6.2)
58
+ pronto (~> 0.6.0)
59
+ rubocop (~> 0.38, >= 0.35.0)
29
60
  pry (0.11.3)
30
61
  coderay (~> 1.1.0)
31
62
  method_source (~> 0.9.0)
@@ -35,6 +66,7 @@ GEM
35
66
  pry-rescue (1.4.5)
36
67
  interception (>= 0.5)
37
68
  pry
69
+ public_suffix (3.0.2)
38
70
  rainbow (3.0.0)
39
71
  rake (10.5.0)
40
72
  rspec (3.7.0)
@@ -58,11 +90,21 @@ GEM
58
90
  ruby-progressbar (~> 1.7)
59
91
  unicode-display_width (~> 1.0, >= 1.0.1)
60
92
  ruby-progressbar (1.9.0)
93
+ ruby_parser (3.11.0)
94
+ sexp_processor (~> 4.9)
95
+ rugged (0.26.0)
96
+ sawyer (0.8.1)
97
+ addressable (>= 2.3.5, < 2.6)
98
+ faraday (~> 0.8, < 1.0)
99
+ sexp_processor (4.10.1)
61
100
  simplecov (0.15.1)
62
101
  docile (~> 1.1.0)
63
102
  json (>= 1.8, < 3)
64
103
  simplecov-html (~> 0.10.0)
65
104
  simplecov-html (0.10.2)
105
+ terminal-table (1.8.0)
106
+ unicode-display_width (~> 1.1, >= 1.1.1)
107
+ thor (0.19.4)
66
108
  unicode-display_width (1.3.0)
67
109
 
68
110
  PLATFORMS
@@ -71,6 +113,9 @@ PLATFORMS
71
113
  DEPENDENCIES
72
114
  bundler (~> 1.14)
73
115
  coltrane!
116
+ pronto
117
+ pronto-flay
118
+ pronto-rubocop
74
119
  pry
75
120
  pry-byebug
76
121
  pry-rescue
data/Rakefile CHANGED
@@ -1,2 +1,2 @@
1
- require "bundler/gem_tasks"
1
+ # require "bundler/gem_tasks"
2
2
  task :default => :spec
data/bin/erubis CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # This file was generated by Bundler.
5
6
  #
@@ -11,6 +12,17 @@ require "pathname"
11
12
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
13
  Pathname.new(__FILE__).realpath)
13
14
 
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /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
+
14
26
  require "rubygems"
15
27
  require "bundler/setup"
16
28
 
data/bin/flay 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 'flay' 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, 150) =~ /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("flay", "flay")
data/bin/gitlab 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 'gitlab' 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, 150) =~ /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("gitlab", "gitlab")
data/bin/httparty 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 'httparty' 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, 150) =~ /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("httparty", "httparty")
data/bin/pronto 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 'pronto' 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, 150) =~ /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("pronto", "pronto")
data/bin/ruby_parse 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 'ruby_parse' 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, 150) =~ /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("ruby_parser", "ruby_parse")
@@ -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 'ruby_parse_extract_error' 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, 150) =~ /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("ruby_parser", "ruby_parse_extract_error")
data/bin/thor CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
+
3
4
  #
4
5
  # This file was generated by Bundler.
5
6
  #
@@ -11,6 +12,17 @@ require "pathname"
11
12
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
12
13
  Pathname.new(__FILE__).realpath)
13
14
 
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 150) =~ /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
+
14
26
  require "rubygems"
15
27
  require "bundler/setup"
16
28
 
data/exe/coltrane CHANGED
@@ -40,7 +40,8 @@ Mercenary.program(:Coltrane) do |p|
40
40
  'Chooses which <additional></additional> information to display: marks, notes, intervals or degrees'
41
41
  ]
42
42
 
43
- p.command(:notes) do |c|
43
+ p.command(:note) do |c|
44
+ c.alias(:notes)
44
45
  c.syntax 'notes <notes separated by space> [--on <instrument>]'
45
46
  c.description 'Shows the given notes.'
46
47
  c.option(*@instrument_option)
@@ -53,6 +54,7 @@ Mercenary.program(:Coltrane) do |p|
53
54
  end
54
55
 
55
56
  p.command(:chord) do |c|
57
+ c.alias(:chords)
56
58
  c.syntax 'chord <chord-name> [--on <instrument>]'
57
59
  c.description 'Shows the given chord. Ex: coltrane chord Cmaj7 --on piano'
58
60
  c.option(*@instrument_option)
@@ -108,9 +110,9 @@ Mercenary.program(:Coltrane) do |p|
108
110
  c.option(*@instrument_option)
109
111
  c.option(*@flavor_option)
110
112
  c.action do |(prog, _, key), on: 'text', flavor: 'notes'|
111
- possible_method = prog.gsub('-', '_')
113
+ possible_method = prog.tr('-', '_')
112
114
  progression = if Coltrane::Progression.respond_to?(possible_method)
113
- Coltrane::Progression.send(possible_method, note)
115
+ Coltrane::Progression.send(possible_method, key)
114
116
  else
115
117
  Coltrane::Progression.new(prog, key: key)
116
118
  end
@@ -126,7 +128,7 @@ Mercenary.program(:Coltrane) do |p|
126
128
  progressions = Coltrane::Progression.find(*chord_notation.split('-'))
127
129
  notation_width = progressions.map(&:notation).map(&:size).max
128
130
  progressions.each do |progression|
129
- puts "#{progression.notation.ljust(notation_width+1,' ')} in #{progression.scale} (#{progression.notes_out.size} notes out)"
131
+ puts "#{progression.notation.ljust(notation_width + 1, ' ')} in #{progression.scale} (#{progression.notes_out.size} notes out)"
130
132
  end
131
133
  end
132
134
  end
@@ -139,7 +141,7 @@ Mercenary.program(:Coltrane) do |p|
139
141
  when 'scales' then Coltrane::Scale.known_scales
140
142
  when 'flavors' then %w[marks notes intervals degrees]
141
143
  when 'instruments' then %w[guitar bass ukulele piano text]
142
- when 'chords', 'chord-qualities' then Coltrane::Qualities::CHORD_QUALITIES.keys.sort.join(' ')
144
+ when 'chords', 'chord-qualities' then Coltrane::ChordQuality.intervals_per_name.keys.join(' ')
143
145
  end
144
146
  end
145
147
  end
@@ -197,7 +199,7 @@ Mercenary.program(:Coltrane) do |p|
197
199
  puts "\n"
198
200
  print Paint['coltrane ', '#F88550']
199
201
  cmd = gets.chomp
200
- return if ['exit', 'exit', 'q', 'quit', 'stop'].include?(cmd)
202
+ return if %w[exit exit q quit stop].include?(cmd)
201
203
  puts "\n"
202
204
  p.go(cmd.split(' '))
203
205
  rescue Exception