transcore 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/transcore +8 -3
- data/lib/transcore.rb +1 -0
- data/lib/transcore/command/convert.rb +1 -16
- data/lib/transcore/command/default.rb +25 -0
- data/spec/bin/transcore_spec.rb +23 -0
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/bin/transcore
CHANGED
@@ -2,18 +2,23 @@
|
|
2
2
|
|
3
3
|
require "transcore"
|
4
4
|
|
5
|
-
command = ARGV
|
5
|
+
command = ARGV[0]
|
6
6
|
|
7
7
|
exit_code = 0
|
8
8
|
|
9
9
|
case command
|
10
10
|
when "transpose"
|
11
|
+
ARGV.shift
|
11
12
|
exit_code = Transcore::Command::Transpose.run(ARGV) || 0
|
12
13
|
when "convert"
|
14
|
+
ARGV.shift
|
13
15
|
exit_code = Transcore::Command::Convert.run(ARGV) || 0
|
14
16
|
else
|
15
|
-
|
16
|
-
exit_code
|
17
|
+
exit_code = Transcore::Command::Default.run(ARGV) || 0
|
18
|
+
if exit_code == 2
|
19
|
+
STDERR.puts "Invalid command: '#{command}'"
|
20
|
+
exit_code = 1
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
24
|
exit exit_code
|
data/lib/transcore.rb
CHANGED
@@ -2,22 +2,7 @@ module Transcore
|
|
2
2
|
module Command
|
3
3
|
module Convert
|
4
4
|
def self.parse_opts(argv)
|
5
|
-
|
6
|
-
while 0 < argv.size do
|
7
|
-
val = argv.shift
|
8
|
-
case val
|
9
|
-
when '--sharp'
|
10
|
-
flat_flag = true
|
11
|
-
when '--flat'
|
12
|
-
flat_flag = false
|
13
|
-
when '--doremi'
|
14
|
-
doremi_flag = false
|
15
|
-
else
|
16
|
-
next_argv.push val
|
17
|
-
end
|
18
|
-
end
|
19
|
-
argv.push(*next_argv)
|
20
|
-
return {:flat_flag => flat_flag, }
|
5
|
+
return {}
|
21
6
|
end
|
22
7
|
|
23
8
|
def self.run(argv, input_stream=$stdin, output_stream=$stdout)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Transcore
|
2
|
+
module Command
|
3
|
+
module Default
|
4
|
+
def self.run(argv, input_stream=$stdin, output_stream=$stdout)
|
5
|
+
command = argv[0]
|
6
|
+
if /^[+\-]?[0-9]+$/ =~ command
|
7
|
+
return Transcore::Command::Transpose.run(argv, input_stream, output_stream)
|
8
|
+
else
|
9
|
+
case command
|
10
|
+
when "sharp"
|
11
|
+
return Transcore::Command::Convert.run(argv, input_stream, output_stream)
|
12
|
+
when "flat"
|
13
|
+
return Transcore::Command::Convert.run(argv, input_stream, output_stream)
|
14
|
+
when "doremi"
|
15
|
+
return Transcore::Command::Convert.run(argv, input_stream, output_stream)
|
16
|
+
when "text-score"
|
17
|
+
return Transcore::Command::Convert.run(argv, input_stream, output_stream)
|
18
|
+
else
|
19
|
+
return 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/bin/transcore_spec.rb
CHANGED
@@ -26,4 +26,27 @@ describe "bin/transcore" do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
context "when command = +1" do
|
31
|
+
input = "C Am F G7"
|
32
|
+
context "when input is '#{input}'" do
|
33
|
+
it "should output #{"C# A#m F# G#7".inspect}" do
|
34
|
+
result = `echo '#{input}' | ruby -I lib ./bin/transcore +1`
|
35
|
+
result.chomp!
|
36
|
+
result.should == "C# A#m F# G#7"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "when command = flat" do
|
42
|
+
input = "F Dm A# C"
|
43
|
+
context "when input is '#{input}'" do
|
44
|
+
it "should output \"#{"F Dm B♭ C"}\"" do
|
45
|
+
result = `echo '#{input}' | ruby -I lib ./bin/transcore flat`
|
46
|
+
result.chomp!
|
47
|
+
result.should == "F Dm B♭ C"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
29
52
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: transcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kenji Hara
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- bin/transcore
|
181
181
|
- lib/transcore.rb
|
182
182
|
- lib/transcore/command/convert.rb
|
183
|
+
- lib/transcore/command/default.rb
|
183
184
|
- lib/transcore/command/transpose.rb
|
184
185
|
- spec/bin/transcore_spec.rb
|
185
186
|
- spec/lib/transcore/command/convert_spec.rb
|