coltrane 1.0.2 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Coltrane
4
- # It deals with chords in roman notation
5
2
  class RomanChord
6
3
  DIGITS = {
7
4
  'I' => 1,
8
- 'V' => 5
9
- }.freeze
5
+ 'V' => 5,
6
+ }
10
7
 
11
8
  def initialize(scale, roman_numeral)
12
9
  @scale = scale
@@ -29,11 +26,11 @@ module Coltrane
29
26
  end
30
27
 
31
28
  def quality
32
- ChordQuality.new(name: major? ? 'M' : 'm')
29
+ ChordQuality.new(name: is_major? ? 'M' : 'm')
33
30
  end
34
31
 
35
- def major?
32
+ def is_major?
36
33
  @roman_numeral[0] =~ /[[:upper]]/
37
34
  end
38
35
  end
39
- end
36
+ end
@@ -1,22 +1,18 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Coltrane
4
- # Musical scale creation and manipulation
5
2
  class Scale
6
3
  extend ClassicScales
7
4
  attr_reader :interval_sequence, :tone
8
5
 
9
6
  def initialize(*distances, tone: 'C', mode: 1, name: nil, notes: nil)
10
- @name = name
7
+ @name = name
11
8
  if !distances.nil? && !tone.nil?
12
9
  @tone = Note[tone]
13
- distances = distances.rotate(mode - 1)
10
+ distances = distances.rotate(mode-1)
14
11
  @interval_sequence = IntervalSequence.new(distances: distances)
15
12
  elsif !notes.nil?
16
13
  ds = NoteSet[*notes].interval_sequence.distances
17
- new(*ds, tone: notes.first)
18
- else
19
- raise WrongKeywordsError, '[*distances, tone: "C", mode: 1] || [notes:]'
14
+ self.new(*ds, tone: notes.first)
15
+ else raise WrongKeywords.new('[*distances, (tone: "C", mode: 1)] || [notes:]')
20
16
  end
21
17
  end
22
18
 
@@ -26,7 +22,7 @@ module Coltrane
26
22
 
27
23
  def name
28
24
  @name = begin
29
- is = interval_sequence.distances
25
+ is = self.interval_sequence.distances
30
26
  (0...is.size).each do |i|
31
27
  if (scale_name = Coltrane::ClassicScales::SCALES.key(is.rotate(i)))
32
28
  return scale_name
@@ -40,22 +36,26 @@ module Coltrane
40
36
  "#{tone.name} #{name}"
41
37
  end
42
38
 
43
- alias full_name pretty_name
39
+ alias_method :full_name, :pretty_name
44
40
 
45
41
  def degree(d)
46
- raise WrongDegreeError, d if d < 1 || d > size
42
+ if d < 1 || d > size
43
+ raise WrongDegree.new(d)
44
+ end
45
+
47
46
  tone + interval_sequence[d - 1].semitones
48
47
  end
49
48
 
50
- alias [] degree
49
+ alias_method :[], :degree
51
50
 
52
51
  def degrees
53
52
  (1..size)
54
53
  end
55
54
 
56
55
  def degree_of_chord(chord)
57
- return if chords(chord.size).map(&:name).include?(chord.name)
58
- degree_of_note(chord.root_note)
56
+ if chords(chord.size).map(&:name).include?(chord.name)
57
+ degree_of_note(chord.root_note)
58
+ end
59
59
  end
60
60
 
61
61
  def degree_of_note(note)
@@ -63,9 +63,9 @@ module Coltrane
63
63
  return note + 1 unless note.nil?
64
64
  end
65
65
 
66
- def &(other)
67
- raise HasNoNotesError unless other.respond_to?(:notes)
68
- notes & other
66
+ def &(something)
67
+ raise HasNoNotes unless something.respond_to?(:notes)
68
+ notes & something
69
69
  end
70
70
 
71
71
  def include_notes?(arg)
@@ -73,25 +73,27 @@ module Coltrane
73
73
  (self & noteset).size == noteset.size
74
74
  end
75
75
 
76
- alias include? include_notes?
76
+ alias_method :include?, :include_notes?
77
77
 
78
78
  def notes
79
- Coltrane::Cache.find_or_record(cache_key('notes')) do
79
+ Coltrane::Cache.find_or_record(cache_key("notes")) do
80
80
  NoteSet[*degrees.map { |d| degree(d) }]
81
81
  end
82
82
  end
83
83
 
84
84
  def interval(i)
85
- interval_sequence[(i - 1) % size]
85
+ interval_sequence[(i-1) % size]
86
86
  end
87
87
 
88
88
  def size
89
89
  interval_sequence.size
90
90
  end
91
91
 
92
- def tertians(n = 3)
92
+ def tertians(n=3)
93
93
  degrees.size.times.reduce([]) do |memo, d|
94
- ns = NoteSet[ *Array.new(n) { |i| notes[(d + (i * 2)) % size] } ]
94
+ ns = NoteSet[
95
+ *n.times.map { |i| notes[(d + (i*2)) % (size)]}
96
+ ]
95
97
  chord = Chord.new(notes: ns)
96
98
  chord.named? ? memo + [chord] : memo
97
99
  end
@@ -114,11 +116,17 @@ module Coltrane
114
116
  end
115
117
 
116
118
  def cache_key(extra)
117
- [@tone.name, @interval_sequence.intervals_semitones.join, extra].join('-')
119
+ [
120
+ @tone.name,
121
+ @interval_sequence.intervals_semitones.join(),
122
+ extra
123
+ ].join('-')
118
124
  end
119
125
 
120
126
  def all_chords
121
- (3..size).reduce([]) { |memo, s| memo + chords(s) }
127
+ (3..size).reduce([]) do |memo, s|
128
+ memo + chords(s)
129
+ end
122
130
  end
123
131
 
124
132
  def chords(size)
@@ -136,4 +144,4 @@ module Coltrane
136
144
  end
137
145
  end
138
146
  end
139
- end
147
+ end
@@ -0,0 +1,4 @@
1
+ class ScaleChord < ActiveRecord::Base
2
+ belongs_to :chord_cache
3
+ belongs_to :scale_cache
4
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Coltrane
4
- VERSION = '1.0.2'
2
+ VERSION = "1.0.11"
5
3
  end
data/lib/core_ext.rb CHANGED
@@ -1,15 +1,12 @@
1
- # frozen_string_literal: true
2
-
3
- # Stolen from Active Support and changed a bit
4
- # may in the future be substituted by facets version
5
1
  class String
2
+ # Stolen from Active Support and changed a bit
6
3
  def underscore
7
4
  return self unless /[A-Z-]|::/.match?(self)
8
- word = to_s.gsub('::', '/')
5
+ word = self.to_s.gsub("::", "/")
9
6
  word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
10
7
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
11
- word.tr!('- ', '_')
8
+ word.tr!("-", "_")
12
9
  word.downcase!
13
10
  word
14
11
  end
15
- end
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coltrane
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Maciel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-29 00:00:00.000000000 Z
11
+ date: 2018-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: facets
@@ -39,19 +39,19 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: color
42
+ name: chroma
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.8'
47
+ version: 0.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.8'
54
+ version: 0.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mercenary
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -105,7 +105,6 @@ files:
105
105
  - ".bundle/config"
106
106
  - ".gitignore"
107
107
  - ".rspec"
108
- - ".rubocop.yml"
109
108
  - ".ruby-version"
110
109
  - CODE_OF_CONDUCT.md
111
110
  - Gemfile
@@ -147,6 +146,7 @@ files:
147
146
  - db/cache.sqlite3
148
147
  - db/cache_test.sqlite3
149
148
  - db/config.yml
149
+ - db/schema.rb
150
150
  - exe/coltrane
151
151
  - img/coltrane-logo.png
152
152
  - img/screen-1.png
@@ -159,7 +159,6 @@ files:
159
159
  - img/screen-7.png
160
160
  - img/screen-8.png
161
161
  - img/screen-9.png
162
- - lib/cli.rb
163
162
  - lib/cli/bass_guitar.rb
164
163
  - lib/cli/chord.rb
165
164
  - lib/cli/errors.rb
@@ -170,10 +169,12 @@ files:
170
169
  - lib/cli/scale.rb
171
170
  - lib/cli/text.rb
172
171
  - lib/cli/ukulele.rb
172
+ - lib/coltrane-cli.rb
173
173
  - lib/coltrane.rb
174
174
  - lib/coltrane/cache.rb
175
175
  - lib/coltrane/cadence.rb
176
176
  - lib/coltrane/chord.rb
177
+ - lib/coltrane/chord_cache.rb
177
178
  - lib/coltrane/chord_quality.rb
178
179
  - lib/coltrane/classic_progressions.rb
179
180
  - lib/coltrane/classic_scales.rb
@@ -190,8 +191,10 @@ files:
190
191
  - lib/coltrane/qualities.rb
191
192
  - lib/coltrane/roman_chord.rb
192
193
  - lib/coltrane/scale.rb
194
+ - lib/coltrane/scale_chord.rb
193
195
  - lib/coltrane/version.rb
194
196
  - lib/core_ext.rb
197
+ - pkg/coltrane-0.0.2.gem
195
198
  homepage: http://github.com/pedrozath/coltrane
196
199
  licenses:
197
200
  - MIT
data/.rubocop.yml DELETED
@@ -1,19 +0,0 @@
1
- AllCops:
2
- Include:
3
- - 'lib/**/*'
4
- Exclude:
5
- - 'bin/**/*'
6
- - '*'
7
-
8
- Metrics/AbcSize:
9
- Enabled: false
10
- Metrics/ClassLength:
11
- Enabled: false
12
- Metrics/MethodLength:
13
- Enabled: false
14
- Metrics/ModuleLength:
15
- Enabled: false
16
- Lint/UnneededSplatExpansion:
17
- Enabled: false
18
- Security/MarshalLoad:
19
- Enabled: false