coltrane 0.0.2 → 1.0.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 (64) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +15 -10
  5. data/Gemfile.lock +47 -128
  6. data/README.md +30 -8
  7. data/Rakefile +0 -4
  8. data/bin/bundle +105 -0
  9. data/bin/byebug +29 -0
  10. data/bin/coderay +12 -0
  11. data/bin/coltrane +25 -7
  12. data/bin/htmldiff +12 -0
  13. data/bin/kill-pry-rescue +12 -0
  14. data/bin/ldiff +12 -0
  15. data/bin/pry +12 -0
  16. data/bin/rake +12 -0
  17. data/bin/rescue +12 -0
  18. data/bin/rspec +12 -0
  19. data/bin/rubocop +12 -0
  20. data/bin/ruby-parse +12 -0
  21. data/bin/ruby-rewrite +12 -0
  22. data/exe/coltrane +173 -0
  23. data/lib/cli/bass_guitar.rb +9 -0
  24. data/lib/cli/chord.rb +24 -0
  25. data/lib/cli/errors.rb +28 -0
  26. data/lib/cli/guitar.rb +55 -0
  27. data/lib/cli/notes.rb +18 -0
  28. data/lib/cli/piano.rb +54 -0
  29. data/lib/cli/representation.rb +47 -0
  30. data/lib/cli/scale.rb +48 -0
  31. data/lib/cli/text.rb +13 -0
  32. data/lib/cli/ukulele.rb +11 -0
  33. data/lib/coltrane-cli.rb +12 -0
  34. data/lib/coltrane.rb +16 -31
  35. data/lib/coltrane/cache.rb +34 -0
  36. data/lib/coltrane/chord.rb +28 -41
  37. data/lib/coltrane/chord_quality.rb +14 -39
  38. data/lib/coltrane/classic_progressions.rb +37 -0
  39. data/lib/coltrane/classic_scales.rb +92 -118
  40. data/lib/coltrane/errors.rb +54 -0
  41. data/lib/coltrane/interval.rb +25 -17
  42. data/lib/coltrane/interval_sequence.rb +57 -27
  43. data/lib/coltrane/note.rb +44 -30
  44. data/lib/coltrane/note_set.rb +37 -22
  45. data/lib/coltrane/piano_representation.rb +0 -58
  46. data/lib/coltrane/pitch.rb +12 -3
  47. data/lib/coltrane/progression.rb +31 -0
  48. data/lib/coltrane/qualities.rb +115 -114
  49. data/lib/coltrane/roman_chord.rb +36 -0
  50. data/lib/coltrane/scale.rb +85 -77
  51. data/lib/coltrane/version.rb +1 -1
  52. data/lib/core_ext.rb +12 -0
  53. data/pkg/coltrane-0.0.2.gem +0 -0
  54. metadata +27 -14
  55. data/lib/coltrane/essential_guitar_chords.rb +0 -82
  56. data/lib/coltrane/fret_set.rb +0 -0
  57. data/lib/coltrane/guitar.rb +0 -15
  58. data/lib/coltrane/guitar_chord.rb +0 -50
  59. data/lib/coltrane/guitar_chord_finder.rb +0 -98
  60. data/lib/coltrane/guitar_note.rb +0 -50
  61. data/lib/coltrane/guitar_note_set.rb +0 -61
  62. data/lib/coltrane/guitar_representation.rb +0 -96
  63. data/lib/coltrane/guitar_string.rb +0 -52
  64. data/lib/coltrane/scale_cache.rb +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0d89db41e5429721884671402e8cf17f2b25c461
4
- data.tar.gz: 2d17e5909962dd7c1c737f55cb216bd426602311
2
+ SHA256:
3
+ metadata.gz: 512414fa0854b3ef1215953cbea3d5c545da0cef7978f098b4fbb945ea490ef0
4
+ data.tar.gz: a9b854252e121e7f1a3a74b3c51b9470cdb8205f7f6328247a6b213e3e60f1c3
5
5
  SHA512:
6
- metadata.gz: 2717d0aa492aefc42486ec1548aab3d7ad1c4ac236c33f26201d9bd19b29357681da70acd721b4c05455852a1fd9192550a47e05e1f8c805a65855ecdbd5bc17
7
- data.tar.gz: eeee10c3e63d7bc8b94d11b4f1cbf4adac076b375d7bc800bc4b43b56b416ed5dcb10c012a65c07798a5d0971d7754f876e51268c989c6752d64148d6e30b1e1
6
+ metadata.gz: fa8eb9cc7e52398c4566717d86ff2291fc2793b1a5348c5f495acb7dc932ad1956f584791a5f0992e7e8cf5edb6bfc6f014fff9a20e34f69280319427dbcbf63
7
+ data.tar.gz: '09eb103f1df2e6c7294b74c2f21e9690fa1a21d1ce8c6da5ea7b9407614c44643d093241f0b5d964849c32972b05db57ab59579f8b6549ff2243bdb4422646cf'
@@ -0,0 +1,2 @@
1
+ coverage
2
+ cache
@@ -0,0 +1 @@
1
+ 2.5.0
data/Gemfile CHANGED
@@ -2,16 +2,21 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
- gem 'sqlite3'
6
- gem 'standalone_migrations', '5.2.0'
5
+ gem 'facets', require: false
7
6
 
8
- gem 'guard'
9
- gem 'guard-rspec'
10
- gem 'paint'
11
- gem 'pry'
12
- gem 'pry-stack_explorer'
13
- gem 'pry-rescue'
14
- gem 'rspec'
15
- gem 'rubocop', require: false
7
+ group :cli do
8
+ gem 'paint'
9
+ gem 'chroma'
10
+ gem 'mercenary'
11
+ end
12
+
13
+ group :test do
14
+ gem 'rspec'
15
+ gem 'pry'
16
+ gem 'pry-byebug'
17
+ gem 'pry-rescue'
18
+ gem 'simplecov', require: false
19
+ gem 'rubocop', require: false
20
+ end
16
21
 
17
22
  gemspec
@@ -1,164 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coltrane (0.0.2)
4
+ coltrane (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (5.1.0)
10
- actionview (= 5.1.0)
11
- activesupport (= 5.1.0)
12
- rack (~> 2.0)
13
- rack-test (~> 0.6.3)
14
- rails-dom-testing (~> 2.0)
15
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
16
- actionview (5.1.0)
17
- activesupport (= 5.1.0)
18
- builder (~> 3.1)
19
- erubi (~> 1.4)
20
- rails-dom-testing (~> 2.0)
21
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
22
- activemodel (5.1.0)
23
- activesupport (= 5.1.0)
24
- activerecord (5.1.0)
25
- activemodel (= 5.1.0)
26
- activesupport (= 5.1.0)
27
- arel (~> 8.0)
28
- activesupport (5.1.0)
29
- concurrent-ruby (~> 1.0, >= 1.0.2)
30
- i18n (~> 0.7)
31
- minitest (~> 5.1)
32
- tzinfo (~> 1.1)
33
- arel (8.0.0)
34
9
  ast (2.3.0)
35
- binding_of_caller (0.7.2)
36
- debug_inspector (>= 0.0.1)
37
- builder (3.2.3)
38
- coderay (1.1.1)
39
- concurrent-ruby (1.0.5)
40
- debug_inspector (0.0.2)
10
+ byebug (9.1.0)
11
+ chroma (0.2.0)
12
+ coderay (1.1.2)
41
13
  diff-lcs (1.3)
42
- erubi (1.6.0)
43
- ffi (1.9.18)
44
- formatador (0.2.5)
45
- guard (2.14.1)
46
- formatador (>= 0.2.4)
47
- listen (>= 2.7, < 4.0)
48
- lumberjack (~> 1.0)
49
- nenv (~> 0.1)
50
- notiffany (~> 0.0)
51
- pry (>= 0.9.12)
52
- shellany (~> 0.0)
53
- thor (>= 0.18.1)
54
- guard-compat (1.2.1)
55
- guard-rspec (4.7.3)
56
- guard (~> 2.1)
57
- guard-compat (~> 1.1)
58
- rspec (>= 2.99.0, < 4.0)
59
- i18n (0.8.1)
14
+ docile (1.1.5)
15
+ facets (3.1.0)
60
16
  interception (0.5)
61
- listen (3.1.5)
62
- rb-fsevent (~> 0.9, >= 0.9.4)
63
- rb-inotify (~> 0.9, >= 0.9.7)
64
- ruby_dep (~> 1.2)
65
- loofah (2.0.3)
66
- nokogiri (>= 1.5.9)
67
- lumberjack (1.0.11)
68
- method_source (0.8.2)
69
- mini_portile2 (2.1.0)
70
- minitest (5.10.1)
71
- nenv (0.3.0)
72
- nokogiri (1.7.1)
73
- mini_portile2 (~> 2.1.0)
74
- notiffany (0.1.1)
75
- nenv (~> 0.1)
76
- shellany (~> 0.0)
77
- paint (2.0.0)
78
- parser (2.4.0.0)
79
- ast (~> 2.2)
17
+ json (2.1.0)
18
+ mercenary (0.3.6)
19
+ method_source (0.9.0)
20
+ paint (2.0.1)
21
+ parallel (1.12.1)
22
+ parser (2.4.0.2)
23
+ ast (~> 2.3)
80
24
  powerpack (0.1.1)
81
- pry (0.10.4)
25
+ pry (0.11.3)
82
26
  coderay (~> 1.1.0)
83
- method_source (~> 0.8.1)
84
- slop (~> 3.4)
27
+ method_source (~> 0.9.0)
28
+ pry-byebug (3.5.1)
29
+ byebug (~> 9.1)
30
+ pry (~> 0.10)
85
31
  pry-rescue (1.4.5)
86
32
  interception (>= 0.5)
87
33
  pry
88
- pry-stack_explorer (0.4.9.2)
89
- binding_of_caller (>= 0.7)
90
- pry (>= 0.9.11)
91
- rack (2.0.1)
92
- rack-test (0.6.3)
93
- rack (>= 1.0)
94
- rails-dom-testing (2.0.2)
95
- activesupport (>= 4.2.0, < 6.0)
96
- nokogiri (~> 1.6)
97
- rails-html-sanitizer (1.0.3)
98
- loofah (~> 2.0)
99
- railties (5.1.0)
100
- actionpack (= 5.1.0)
101
- activesupport (= 5.1.0)
102
- method_source
103
- rake (>= 0.8.7)
104
- thor (>= 0.18.1, < 2.0)
105
- rainbow (2.2.2)
106
- rake
34
+ rainbow (3.0.0)
107
35
  rake (10.5.0)
108
- rb-fsevent (0.9.8)
109
- rb-inotify (0.9.8)
110
- ffi (>= 0.5.0)
111
- rspec (3.6.0)
112
- rspec-core (~> 3.6.0)
113
- rspec-expectations (~> 3.6.0)
114
- rspec-mocks (~> 3.6.0)
115
- rspec-core (3.6.0)
116
- rspec-support (~> 3.6.0)
117
- rspec-expectations (3.6.0)
36
+ rspec (3.7.0)
37
+ rspec-core (~> 3.7.0)
38
+ rspec-expectations (~> 3.7.0)
39
+ rspec-mocks (~> 3.7.0)
40
+ rspec-core (3.7.1)
41
+ rspec-support (~> 3.7.0)
42
+ rspec-expectations (3.7.0)
118
43
  diff-lcs (>= 1.2.0, < 2.0)
119
- rspec-support (~> 3.6.0)
120
- rspec-mocks (3.6.0)
44
+ rspec-support (~> 3.7.0)
45
+ rspec-mocks (3.7.0)
121
46
  diff-lcs (>= 1.2.0, < 2.0)
122
- rspec-support (~> 3.6.0)
123
- rspec-support (3.6.0)
124
- rubocop (0.48.1)
125
- parser (>= 2.3.3.1, < 3.0)
47
+ rspec-support (~> 3.7.0)
48
+ rspec-support (3.7.0)
49
+ rubocop (0.52.1)
50
+ parallel (~> 1.10)
51
+ parser (>= 2.4.0.2, < 3.0)
126
52
  powerpack (~> 0.1)
127
- rainbow (>= 1.99.1, < 3.0)
53
+ rainbow (>= 2.2.2, < 4.0)
128
54
  ruby-progressbar (~> 1.7)
129
55
  unicode-display_width (~> 1.0, >= 1.0.1)
130
- ruby-progressbar (1.8.1)
131
- ruby_dep (1.5.0)
132
- shellany (0.0.1)
133
- slop (3.6.0)
134
- sqlite3 (1.3.13)
135
- standalone_migrations (5.2.0)
136
- activerecord (>= 4.2.7, < 5.2.0)
137
- railties (>= 4.2.7, < 5.2.0)
138
- rake (~> 10.0)
139
- thor (0.19.4)
140
- thread_safe (0.3.6)
141
- tzinfo (1.2.3)
142
- thread_safe (~> 0.1)
143
- unicode-display_width (1.2.1)
56
+ ruby-progressbar (1.9.0)
57
+ simplecov (0.15.1)
58
+ docile (~> 1.1.0)
59
+ json (>= 1.8, < 3)
60
+ simplecov-html (~> 0.10.0)
61
+ simplecov-html (0.10.2)
62
+ unicode-display_width (1.3.0)
144
63
 
145
64
  PLATFORMS
146
65
  ruby
147
66
 
148
67
  DEPENDENCIES
149
68
  bundler (~> 1.14)
69
+ chroma
150
70
  coltrane!
151
- guard
152
- guard-rspec
71
+ facets
72
+ mercenary
153
73
  paint
154
74
  pry
75
+ pry-byebug
155
76
  pry-rescue
156
- pry-stack_explorer
157
77
  rake (~> 10.0)
158
78
  rspec
159
79
  rubocop
160
- sqlite3
161
- standalone_migrations (= 5.2.0)
80
+ simplecov
162
81
 
163
82
  BUNDLED WITH
164
- 1.15.0
83
+ 1.16.1
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # Coltrane
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/coltrane`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A musical abacus written in ruby.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ More info, story and purpose of the library:
6
+ https://medium.com/@pedrozath/so-i-wrote-a-library-to-help-me-compose-music-ddb4ae7c8227
6
7
 
7
8
  ## Installation
8
9
 
@@ -20,20 +21,41 @@ Or install it yourself as:
20
21
 
21
22
  $ gem install coltrane
22
23
 
23
- ## Usage
24
+ ## CLI (Command Line Interface)
24
25
 
25
- TODO: Write usage instructions here
26
+ When you install the gem on your system, you automatically gain access to the
27
+ CLI.
26
28
 
27
- ## Development
29
+ You can run it on terminal:
28
30
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ ```bash
32
+ $ coltrane help
33
+ ```
34
+
35
+ ## Roadmap
30
36
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
+ There's a lot of things that need to be done on this library, specially on the CLI:
38
+
39
+ + Refactor the CLI into a more succinct and elegantly organized architecture
40
+ + Amplify the test coverage
41
+ + Move Scale#chords method to NoteSet
42
+ + Write tests for the caching
43
+ + Write up a caching cleaning command
44
+ + Include CLI commands to output chord progressions
45
+ + Include a command to output a pretty HTML document containing the query
32
46
 
33
47
  ## Contributing
34
48
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/coltrane. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
49
+ Install the test suite (RSpec) by running good old `bundle` command
50
+
51
+ Fork the code, make your changes and maybe write a test or two. Then run:
52
+
53
+ Then run:
54
+ ```
55
+ bundle exec rspec spec
56
+ ```
36
57
 
58
+ Make sure the specs pass and submit a PR.
37
59
 
38
60
  ## License
39
61
 
data/Rakefile CHANGED
@@ -1,6 +1,2 @@
1
- ENV['RAILS_ENV'] = 'production'
2
- ENV['DISABLE_DATABASE_ENVIRONMENT_CHECK'] = '1'
3
- require 'standalone_migrations'
4
- StandaloneMigrations::Tasks.load_tasks
5
1
  require "bundler/gem_tasks"
6
2
  task :default => :spec
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1 || ">= 0.a"
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||= begin
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version || "#{Gem::Requirement.default}.a"
67
+ end
68
+ end
69
+
70
+ def load_bundler!
71
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
72
+
73
+ # must dup string for RG < 1.8 compatibility
74
+ activate_bundler(bundler_version.dup)
75
+ end
76
+
77
+ def activate_bundler(bundler_version)
78
+ if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
+ bundler_version = "< 2"
80
+ end
81
+ gem_error = activation_error_handling do
82
+ gem "bundler", bundler_version
83
+ end
84
+ return if gem_error.nil?
85
+ require_error = activation_error_handling do
86
+ require "bundler/version"
87
+ end
88
+ return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
+ warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
+ exit 42
91
+ end
92
+
93
+ def activation_error_handling
94
+ yield
95
+ nil
96
+ rescue StandardError, LoadError => e
97
+ e
98
+ end
99
+ end
100
+
101
+ m.load_bundler!
102
+
103
+ if m.invoked_as_script?
104
+ load Gem.bin_path("bundler", "bundle")
105
+ end
@@ -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 'byebug' 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("byebug", "byebug")