transpose_chords 0.0.1 → 0.0.2
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.
- data/README.rdoc +3 -0
- data/VERSION +1 -1
- data/lib/transpose_chords.rb +27 -9
- data/spec/lib/transpose_chords_spec.rb +17 -0
- data/transpose_chords.gemspec +3 -3
- metadata +4 -4
- data/spec/lib/transpose_chords.rb +0 -9
data/README.rdoc
CHANGED
@@ -7,6 +7,9 @@ Ruby library for transposing chords
|
|
7
7
|
TransposeChords::Chord.transpose(['C','F','Am','G']).to('D')
|
8
8
|
['D','G','Bm','A']
|
9
9
|
|
10
|
+
TransposeChords::Chord.transpose(['C','D','G']).capo(2)
|
11
|
+
['D','E','A']
|
12
|
+
|
10
13
|
== Contributing to transpose_chords
|
11
14
|
|
12
15
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/transpose_chords.rb
CHANGED
@@ -10,19 +10,37 @@ module TransposeChords
|
|
10
10
|
|
11
11
|
def table
|
12
12
|
{
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
to_key: {
|
14
|
+
c: ['C', 'Dm', 'Em', 'F', 'G', 'Am', 'Bdim'],
|
15
|
+
d: ['D', 'Em', 'F#m', 'G', 'A', 'Bm', 'C#dim'],
|
16
|
+
e: ['E', 'F#m', 'G#m', 'A', 'B', 'C#m', 'D#dim'],
|
17
|
+
f: ['F', 'Gm', 'Am', 'Bb', 'C', 'Dm', 'Edim'],
|
18
|
+
g: ['G', 'Am', 'Bm', 'C', 'D', 'Em', 'F#dim'],
|
19
|
+
a: ['A', 'Bm', 'C#m', 'D', 'E', 'F#m', 'G#dim'],
|
20
|
+
b: ['B', 'C#m', 'D#m', 'E', 'F#', 'G#m', 'A#dim']
|
21
|
+
},
|
22
|
+
to_capo: {
|
23
|
+
c: ['C', 'C#/Db', 'D', 'D#/Eb', 'E', 'F', 'F#/Gb', 'G'],
|
24
|
+
d: ['D', 'D#/Eb', 'E', 'F', 'F#/Gb', 'G', 'Gb/Ab', 'A'],
|
25
|
+
e: ['E', 'F', 'F#/Gb', 'G', 'G#/Ab', 'A', 'A#/Bb', 'B'],
|
26
|
+
f: ['F', 'F#/Gb', 'G', 'G#/Ab', 'A', 'A#/Bb', 'B', 'C'],
|
27
|
+
g: ['G', 'G#/Ab', 'A', 'A#/Bb', 'B', 'C', 'C#/Db', 'D'],
|
28
|
+
a: ['A', 'A#/Bb', 'B', 'C', 'C#/Db', 'D', 'D#/Eb', 'E'],
|
29
|
+
b: ['B', 'C', 'C#/Db', 'D', 'D#/Eb', 'E', 'F', 'F#/Gb']
|
30
|
+
}
|
20
31
|
}
|
21
32
|
end
|
22
33
|
|
23
34
|
def to(key)
|
24
35
|
key = table_key_for(key)
|
25
|
-
key_indexes.map { |k| table[key][k] }
|
36
|
+
key_indexes.map { |k| table[:to_key][key][k] }
|
37
|
+
end
|
38
|
+
|
39
|
+
def capo(fret)
|
40
|
+
@keys.map do |k|
|
41
|
+
key = table_key_for(k)
|
42
|
+
table[:to_capo][key][fret]
|
43
|
+
end
|
26
44
|
end
|
27
45
|
|
28
46
|
def table_key_for(key)
|
@@ -34,7 +52,7 @@ module TransposeChords
|
|
34
52
|
end
|
35
53
|
|
36
54
|
def keys_for(key)
|
37
|
-
Hash[table[key].map.with_index{|*ki| ki}]
|
55
|
+
Hash[table[:to_key][key].map.with_index{|*ki| ki}]
|
38
56
|
end
|
39
57
|
end
|
40
58
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../../lib/transpose_chords'
|
2
|
+
|
3
|
+
module TransposeChords
|
4
|
+
describe Chord do
|
5
|
+
context 'transposing to a new key' do
|
6
|
+
it 'transposes a chord progression' do
|
7
|
+
Chord.transpose(['C','F','Am','G']).to('D').should == ['D','G','Bm','A']
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'transposing with a capo' do
|
12
|
+
it 'transposes the chords' do
|
13
|
+
Chord.transpose(['C','D','G']).capo(2).should == ['D','E','A']
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/transpose_chords.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "transpose_chords"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Richard Patching"]
|
12
|
-
s.date = "2012-06-
|
12
|
+
s.date = "2012-06-17"
|
13
13
|
s.description = "Ruby library for transposing chords"
|
14
14
|
s.email = "richard@justaddpixels.com"
|
15
15
|
s.extra_rdoc_files = [
|
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"lib/transpose_chords.rb",
|
28
|
-
"spec/lib/
|
28
|
+
"spec/lib/transpose_chords_spec.rb",
|
29
29
|
"transpose_chords.gemspec"
|
30
30
|
]
|
31
31
|
s.homepage = "http://github.com/patchfx/transpose_chords"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transpose_chords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: shoulda
|
@@ -123,7 +123,7 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- VERSION
|
125
125
|
- lib/transpose_chords.rb
|
126
|
-
- spec/lib/
|
126
|
+
- spec/lib/transpose_chords_spec.rb
|
127
127
|
- transpose_chords.gemspec
|
128
128
|
homepage: http://github.com/patchfx/transpose_chords
|
129
129
|
licenses:
|
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
segments:
|
142
142
|
- 0
|
143
|
-
hash:
|
143
|
+
hash: 3721842906326010125
|
144
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|