transcore 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +25 -0
- data/LICENSE.txt +20 -0
- data/README.md +17 -0
- data/Rakefile +76 -0
- data/VERSION +1 -0
- data/bin/transcore +19 -0
- data/lib/transcore.rb +39 -0
- data/lib/transcore/command/convert.rb +72 -0
- data/lib/transcore/command/transpose.rb +57 -0
- data/spec/bin/transcore_spec.rb +29 -0
- data/spec/lib/transcore/command/convert_spec.rb +111 -0
- data/spec/lib/transcore/command/transpose_spec.rb +38 -0
- data/spec/lib/transcore_spec.rb +6 -0
- data/spec/spec_helper.rb +37 -0
- metadata +223 -0
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.12.0"
|
12
|
+
gem "yard", "~> 0.8.3"
|
13
|
+
gem "redcarpet", "~> 2.2.2"
|
14
|
+
gem "rdoc", "~> 3.12"
|
15
|
+
gem "bundler", "~> 1.2.3"
|
16
|
+
gem "jeweler", "~> 1.8.4"
|
17
|
+
if RUBY_VERSION <= '1.8.7'
|
18
|
+
gem "rcov", "~> 1.0.0"
|
19
|
+
else
|
20
|
+
gem "simplecov", "~> 0.7.1"
|
21
|
+
gem "simplecov-rcov", "~> 0.2.3"
|
22
|
+
end
|
23
|
+
gem "ci_reporter", "~> 1.8.3"
|
24
|
+
gem "flog", "~> 3.2.1"
|
25
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Kenji Hara
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# transcore
|
2
|
+
|
3
|
+
transcore RubyGem.
|
4
|
+
|
5
|
+
## Contributing to transcore
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
## Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Kenji Hara. See LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler"
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require "rake"
|
13
|
+
|
14
|
+
require "jeweler"
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "transcore"
|
18
|
+
gem.homepage = "http://github.com/haracane/transcore"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "transcore RubyGem"
|
21
|
+
gem.description = "transcore RubyGem"
|
22
|
+
gem.email = "haracane@gmail.com"
|
23
|
+
gem.authors = ["Kenji Hara"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
## RSpec
|
29
|
+
require "rspec/core"
|
30
|
+
require "rspec/core/rake_task"
|
31
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
32
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
33
|
+
end
|
34
|
+
|
35
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
36
|
+
spec.pattern = "spec/**/*_spec.rb"
|
37
|
+
spec.rcov = true
|
38
|
+
end
|
39
|
+
|
40
|
+
## RDoc
|
41
|
+
require "rdoc/task"
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?("VERSION") ? File.read("VERSION") : ""
|
44
|
+
rdoc.rdoc_dir = "rdoc"
|
45
|
+
rdoc.title = "lapidary #{version}"
|
46
|
+
rdoc.rdoc_files.include("README*")
|
47
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
48
|
+
end
|
49
|
+
|
50
|
+
## YARD
|
51
|
+
require "yard"
|
52
|
+
require "yard/rake/yardoc_task"
|
53
|
+
YARD::Rake::YardocTask.new do |t|
|
54
|
+
t.files = ["lib/**/*.rb"]
|
55
|
+
t.options = []
|
56
|
+
t.options << "--debug" << "--verbose" if $trace
|
57
|
+
end
|
58
|
+
|
59
|
+
# CI::Reporter
|
60
|
+
require "ci/reporter/rake/rspec"
|
61
|
+
|
62
|
+
## RCov
|
63
|
+
if RUBY_VERSION <= "1.8.7"
|
64
|
+
require "rcov"
|
65
|
+
RSpec::Core::RakeTask.new("spec:rcov") do |t|
|
66
|
+
t.rcov = true
|
67
|
+
t.rspec_opts = ["-c"]
|
68
|
+
t.rcov_opts = ["-x", "spec"]
|
69
|
+
end
|
70
|
+
else
|
71
|
+
RSpec::Core::RakeTask.new("spec:rcov") do |t|
|
72
|
+
t.rspec_opts = ["-v"]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
task :default => :spec
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/transcore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "transcore"
|
4
|
+
|
5
|
+
command = ARGV.shift
|
6
|
+
|
7
|
+
exit_code = 0
|
8
|
+
|
9
|
+
case command
|
10
|
+
when "transpose"
|
11
|
+
exit_code = Transcore::Command::Transpose.run(ARGV) || 0
|
12
|
+
when "convert"
|
13
|
+
exit_code = Transcore::Command::Convert.run(ARGV) || 0
|
14
|
+
else
|
15
|
+
STDERR.puts "Invalid command: '#{command}'"
|
16
|
+
exit_code = 1
|
17
|
+
end
|
18
|
+
|
19
|
+
exit exit_code
|
data/lib/transcore.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require "logger"
|
2
|
+
|
3
|
+
require "transcore/command/convert"
|
4
|
+
require "transcore/command/transpose"
|
5
|
+
|
6
|
+
module Transcore
|
7
|
+
# Reader method for the logger of Lapidary
|
8
|
+
# @return [Logger] Logger object
|
9
|
+
def self.logger
|
10
|
+
if @logger.nil?
|
11
|
+
@logger = (rails_logger || default_logger)
|
12
|
+
@logger.formatter = proc { |severity, datetime, progname, msg|
|
13
|
+
datetime.strftime("[%Y-%m-%d %H:%M:%S](#{severity}) #{msg}\n")
|
14
|
+
}
|
15
|
+
end
|
16
|
+
return @logger
|
17
|
+
end
|
18
|
+
|
19
|
+
# Reader method for the rails logger of Lapidary
|
20
|
+
# @return [Logger] Logger object
|
21
|
+
def self.rails_logger
|
22
|
+
(defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
|
23
|
+
(defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Reader method for the default logger of Lapidary
|
27
|
+
# @return [Logger] Logger object
|
28
|
+
def self.default_logger
|
29
|
+
l = Logger.new(STDERR)
|
30
|
+
l.level = Logger::INFO
|
31
|
+
l
|
32
|
+
end
|
33
|
+
|
34
|
+
# Writer method for the logger of Lapidary
|
35
|
+
# @param logger [Logger]
|
36
|
+
def self.logger=(logger)
|
37
|
+
@logger = logger
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Transcore
|
2
|
+
module Command
|
3
|
+
module Convert
|
4
|
+
def self.parse_opts(argv)
|
5
|
+
next_argv = []
|
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, }
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run(argv, input_stream=$stdin, output_stream=$stdout)
|
24
|
+
params = self.parse_opts(argv)
|
25
|
+
command = argv.shift
|
26
|
+
input = input_stream.read
|
27
|
+
|
28
|
+
input.gsub!(/ /, " ")
|
29
|
+
|
30
|
+
case command
|
31
|
+
when "sharp"
|
32
|
+
input.gsub!(/(^|\s|\/|on)A♭/, "\\1G#")
|
33
|
+
input.gsub!(/(^|\s|\/|on)B♭/, "\\1A#")
|
34
|
+
input.gsub!(/(^|\s|\/|on)D♭/, "\\1C#")
|
35
|
+
input.gsub!(/(^|\s|\/|on)E♭/, "\\1D#")
|
36
|
+
input.gsub!(/(^|\s|\/|on)G♭/, "\\1F#")
|
37
|
+
when "flat"
|
38
|
+
input.gsub!(/(^|\s|\/|on)G#/, "\\1A♭")
|
39
|
+
input.gsub!(/(^|\s|\/|on)A#/, "\\1B♭")
|
40
|
+
input.gsub!(/(^|\s|\/|on)C#/, "\\1D♭")
|
41
|
+
input.gsub!(/(^|\s|\/|on)D#/, "\\1E♭")
|
42
|
+
input.gsub!(/(^|\s|\/|on)F#/, "\\1G♭")
|
43
|
+
when "doremi"
|
44
|
+
input.gsub!(/A/, "ラ")
|
45
|
+
input.gsub!(/B/, "シ")
|
46
|
+
input.gsub!(/C/, "ド")
|
47
|
+
input.gsub!(/D/, "レ")
|
48
|
+
input.gsub!(/E/, "ミ")
|
49
|
+
input.gsub!(/F/, "ファ")
|
50
|
+
input.gsub!(/G/, "ソ")
|
51
|
+
when "text-score"
|
52
|
+
input.gsub!(/\n/, "")
|
53
|
+
input.gsub!(/<br\/?>/, "\n")
|
54
|
+
input.gsub!(/<\/p>/, "\n")
|
55
|
+
input.gsub!(/<[^>]+>/, " ")
|
56
|
+
input.gsub!(/ /, " ")
|
57
|
+
input.gsub!(/ /, " ")
|
58
|
+
input.gsub!(/^ +/, "")
|
59
|
+
input.gsub!(/ +$/, "")
|
60
|
+
input.gsub!(///, "|")
|
61
|
+
input.gsub!(/#/, "#")
|
62
|
+
input.gsub!(/ /, " ")
|
63
|
+
input.gsub!(/\n\n\n/, "\n\n")
|
64
|
+
end
|
65
|
+
result = input
|
66
|
+
|
67
|
+
output_stream.puts result
|
68
|
+
return 0
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Transcore
|
2
|
+
module Command
|
3
|
+
module Transpose
|
4
|
+
NEXT_TONE = {
|
5
|
+
"A"=>"A#",
|
6
|
+
"A#"=>"B",
|
7
|
+
"B"=>"C",
|
8
|
+
"C"=>"C#",
|
9
|
+
"C#"=>"D",
|
10
|
+
"D"=>"D#",
|
11
|
+
"D#"=>"E",
|
12
|
+
"E"=>"F",
|
13
|
+
"F"=>"F#",
|
14
|
+
"F#"=>"G",
|
15
|
+
"G"=>"G#",
|
16
|
+
"G#"=>"A"
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.parse_opts(argv)
|
20
|
+
return {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run(argv, input_stream=$stdin, output_stream=$stdout)
|
24
|
+
params = self.parse_opts(argv)
|
25
|
+
step = (argv.shift || 1).to_i
|
26
|
+
input = input_stream.read
|
27
|
+
# input.tr!("A-G", "A-G")
|
28
|
+
input.gsub!(/ /, " ")
|
29
|
+
input.gsub!(/ +$/, "")
|
30
|
+
input.gsub!(/(^|\s|\/|on)([ACDFG])#/, "\\1\\2#")
|
31
|
+
# input.gsub!(/([ABDEG])b/, "\\1♭")
|
32
|
+
input.gsub!(/(^|\s|\/|on)A♭/, "\\1G#")
|
33
|
+
input.gsub!(/(^|\s|\/|on)B♭/, "\\1A#")
|
34
|
+
input.gsub!(/(^|\s|\/|on)D♭/, "\\1C#")
|
35
|
+
input.gsub!(/(^|\s|\/|on)E♭/, "\\1D#")
|
36
|
+
input.gsub!(/(^|\s|\/|on)G♭/, "\\1F#")
|
37
|
+
step %= 12
|
38
|
+
rest = input
|
39
|
+
step.times do |i|
|
40
|
+
next_str = ""
|
41
|
+
while /(^|\s|\/|on)(A#|A|B|C#|C|D#|D|E|F#|F|G#|G)([^\s]*)/ =~ rest
|
42
|
+
next_str += $` + $1
|
43
|
+
match_str = $2
|
44
|
+
post_str = $3
|
45
|
+
rest = $'
|
46
|
+
next_str += NEXT_TONE[match_str] + post_str
|
47
|
+
end
|
48
|
+
rest = next_str + rest
|
49
|
+
end
|
50
|
+
result = rest
|
51
|
+
|
52
|
+
output_stream.puts result
|
53
|
+
return 0
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "bin/transcore" do
|
4
|
+
context "when command = transpose" do
|
5
|
+
input = "C Am F G7"
|
6
|
+
context "when parameter = 1" do
|
7
|
+
context "when input is '#{input}'" do
|
8
|
+
it "should output #{"C# A#m F# G#7".inspect}" do
|
9
|
+
result = `echo '#{input}' | ruby -I lib ./bin/transcore transpose 1`
|
10
|
+
result.chomp!
|
11
|
+
result.should == "C# A#m F# G#7"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when command = convert" do
|
18
|
+
context "when sub-command = flat" do
|
19
|
+
input = "F Dm A# C"
|
20
|
+
context "when input is '#{input}'" do
|
21
|
+
it "should output \"#{"F Dm B♭ C"}\"" do
|
22
|
+
result = `echo '#{input}' | ruby -I lib ./bin/transcore convert flat`
|
23
|
+
result.chomp!
|
24
|
+
result.should == "F Dm B♭ C"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Transcore::Command::Convert do
|
4
|
+
describe ".run(argv, input_stream, output_stream)" do
|
5
|
+
context "when argv = #{["flat"].inspect}" do
|
6
|
+
context "when input = #{"F Dm A# C".inspect}" do
|
7
|
+
it "should output \"#{"F Dm B♭ C"}\"" do
|
8
|
+
input = "F Dm A# C"
|
9
|
+
input_read, input_write = *IO.pipe
|
10
|
+
output_read, output_write = *IO.pipe
|
11
|
+
input_write.puts input
|
12
|
+
input_write.close
|
13
|
+
Transcore::Command::Convert.run(["flat"], input_read, output_write)
|
14
|
+
output_write.close
|
15
|
+
result = output_read.read
|
16
|
+
result.chomp.should == "F Dm B♭ C"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when argv = #{["sharp"].inspect}" do
|
22
|
+
context "when input = \"#{"F Dm B♭ C"}\"" do
|
23
|
+
it "should output #{"F Dm A# C".inspect}" do
|
24
|
+
input = "F Dm B♭ C"
|
25
|
+
input_read, input_write = *IO.pipe
|
26
|
+
output_read, output_write = *IO.pipe
|
27
|
+
input_write.puts input
|
28
|
+
input_write.close
|
29
|
+
Transcore::Command::Convert.run(["sharp"], input_read, output_write)
|
30
|
+
output_write.close
|
31
|
+
result = output_read.read
|
32
|
+
result.chomp.should == "F Dm A# C"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when argv = #{["doremi"].inspect}" do
|
38
|
+
context "when input = #{"CDEFGAB".inspect}" do
|
39
|
+
it "should output \"#{"ドレミファソラシド"}\"" do
|
40
|
+
input = "CDEFGAB"
|
41
|
+
input_read, input_write = *IO.pipe
|
42
|
+
output_read, output_write = *IO.pipe
|
43
|
+
input_write.puts input
|
44
|
+
input_write.close
|
45
|
+
Transcore::Command::Convert.run(["doremi"], input_read, output_write)
|
46
|
+
output_write.close
|
47
|
+
result = output_read.read
|
48
|
+
result.chomp.should == "ドレミファソラシ"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when argv = #{["text-score"].inspect}" do
|
54
|
+
context "when input is inline-chord html" do
|
55
|
+
it "should output inline-chord score" do
|
56
|
+
input = <<-EOF
|
57
|
+
<p>
|
58
|
+
<span class="chord">C</span><span class="word">word1</span><span>Am</span><span>word2</span>
|
59
|
+
</p>
|
60
|
+
<p>
|
61
|
+
<span>word3</span><span>F</span><span>word4</span><span>G7</span><span>word5</span>
|
62
|
+
</p>
|
63
|
+
EOF
|
64
|
+
input_read, input_write = *IO.pipe
|
65
|
+
output_read, output_write = *IO.pipe
|
66
|
+
input_write.puts input
|
67
|
+
input_write.close
|
68
|
+
Transcore::Command::Convert.run(["text-score"], input_read, output_write)
|
69
|
+
output_write.close
|
70
|
+
result = output_read.read
|
71
|
+
# STDERR.puts result
|
72
|
+
result = result.split(/\r?\n/)
|
73
|
+
# result.each do |line| STDERR.puts line.inspect end
|
74
|
+
result.shift.should == "C word1 Am word2"
|
75
|
+
result.shift.should == "word3 F word4 G7 word5"
|
76
|
+
result.size.should == 0
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "when argv = #{["text-score"].inspect}" do
|
82
|
+
context "when input is super-chord html" do
|
83
|
+
it "should output super-chord score" do
|
84
|
+
input = <<-EOF
|
85
|
+
<p><span>C</span></p>
|
86
|
+
<p>word1</p>
|
87
|
+
<p><span>Am F G7</span></p>
|
88
|
+
<p>word2 word3 word4</p>
|
89
|
+
EOF
|
90
|
+
input_read, input_write = *IO.pipe
|
91
|
+
output_read, output_write = *IO.pipe
|
92
|
+
input_write.puts input
|
93
|
+
input_write.close
|
94
|
+
Transcore::Command::Convert.run(["text-score"], input_read, output_write)
|
95
|
+
output_write.close
|
96
|
+
result = output_read.read
|
97
|
+
# STDERR.puts result
|
98
|
+
result = result.split(/\r?\n/)
|
99
|
+
# result.each do |line| STDERR.puts line.inspect end
|
100
|
+
result.shift.should == "C"
|
101
|
+
result.shift.should == "word1"
|
102
|
+
result.shift.should == "Am F G7"
|
103
|
+
result.shift.should == "word2 word3 word4"
|
104
|
+
result.size.should == 0
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Transcore::Command::Transpose do
|
4
|
+
describe ".run(argv, input_stream, output_stream)" do
|
5
|
+
context "when argv = #{["1"].inspect}" do
|
6
|
+
context "when input = #{"C Am F G".inspect}" do
|
7
|
+
it "should output #{"C# A#m F# G#".inspect}" do
|
8
|
+
input = "C Am F G"
|
9
|
+
input_read, input_write = *IO.pipe
|
10
|
+
output_read, output_write = *IO.pipe
|
11
|
+
input_write.puts input
|
12
|
+
input_write.close
|
13
|
+
Transcore::Command::Transpose.run(["1"], input_read, output_write)
|
14
|
+
output_write.close
|
15
|
+
result = output_read.read
|
16
|
+
result.chomp.should == "C# A#m F# G#"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when argv = #{["-1"].inspect}" do
|
22
|
+
context "when input = #{"C Am F G".inspect}" do
|
23
|
+
it "should output #{"B G#m E F#".inspect}" do
|
24
|
+
input = "C Am F G"
|
25
|
+
input_read, input_write = *IO.pipe
|
26
|
+
output_read, output_write = *IO.pipe
|
27
|
+
input_write.puts input
|
28
|
+
input_write.close
|
29
|
+
Transcore::Command::Transpose.run(["-1"], input_read, output_write)
|
30
|
+
output_write.close
|
31
|
+
result = output_read.read
|
32
|
+
result.chomp.should == "B G#m E F#"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
if RUBY_VERSION <= '1.8.7'
|
2
|
+
else
|
3
|
+
require "simplecov"
|
4
|
+
require "simplecov-rcov"
|
5
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
6
|
+
SimpleCov.start
|
7
|
+
end
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
require "rspec"
|
12
|
+
require "transcore"
|
13
|
+
require "tempfile"
|
14
|
+
|
15
|
+
# Requires supporting files with custom matchers and macros, etc,
|
16
|
+
# in ./support/ and its subdirectories.
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
module Transcore
|
24
|
+
TRANSCORE_HOME = File.expand_path(File.dirname(__FILE__) + "/..")
|
25
|
+
REDIRECT = {}
|
26
|
+
end
|
27
|
+
|
28
|
+
Transcore.logger = Logger.new(STDERR)
|
29
|
+
if File.exist?('/tmp/transcore.debug') then
|
30
|
+
Transcore.logger.level = Logger::DEBUG
|
31
|
+
Transcore::REDIRECT[:stdout] = nil
|
32
|
+
Transcore::REDIRECT[:stderr] = nil
|
33
|
+
else
|
34
|
+
Transcore.logger.level = Logger::ERROR
|
35
|
+
Transcore::REDIRECT[:stdout] = "> /dev/null"
|
36
|
+
Transcore::REDIRECT[:stderr] = "2> /dev/null"
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,223 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: transcore
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Kenji Hara
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-01-14 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 63
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 12
|
31
|
+
- 0
|
32
|
+
version: 2.12.0
|
33
|
+
type: :development
|
34
|
+
name: rspec
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 57
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 8
|
47
|
+
- 3
|
48
|
+
version: 0.8.3
|
49
|
+
type: :development
|
50
|
+
name: yard
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ~>
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 2
|
62
|
+
- 2
|
63
|
+
- 2
|
64
|
+
version: 2.2.2
|
65
|
+
type: :development
|
66
|
+
name: redcarpet
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 31
|
76
|
+
segments:
|
77
|
+
- 3
|
78
|
+
- 12
|
79
|
+
version: "3.12"
|
80
|
+
type: :development
|
81
|
+
name: rdoc
|
82
|
+
version_requirements: *id004
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
prerelease: false
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ~>
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 25
|
91
|
+
segments:
|
92
|
+
- 1
|
93
|
+
- 2
|
94
|
+
- 3
|
95
|
+
version: 1.2.3
|
96
|
+
type: :development
|
97
|
+
name: bundler
|
98
|
+
version_requirements: *id005
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
prerelease: false
|
101
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ~>
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
hash: 63
|
107
|
+
segments:
|
108
|
+
- 1
|
109
|
+
- 8
|
110
|
+
- 4
|
111
|
+
version: 1.8.4
|
112
|
+
type: :development
|
113
|
+
name: jeweler
|
114
|
+
version_requirements: *id006
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
prerelease: false
|
117
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 23
|
123
|
+
segments:
|
124
|
+
- 1
|
125
|
+
- 0
|
126
|
+
- 0
|
127
|
+
version: 1.0.0
|
128
|
+
type: :development
|
129
|
+
name: rcov
|
130
|
+
version_requirements: *id007
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
prerelease: false
|
133
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
135
|
+
requirements:
|
136
|
+
- - ~>
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 49
|
139
|
+
segments:
|
140
|
+
- 1
|
141
|
+
- 8
|
142
|
+
- 3
|
143
|
+
version: 1.8.3
|
144
|
+
type: :development
|
145
|
+
name: ci_reporter
|
146
|
+
version_requirements: *id008
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
prerelease: false
|
149
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ~>
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 13
|
155
|
+
segments:
|
156
|
+
- 3
|
157
|
+
- 2
|
158
|
+
- 1
|
159
|
+
version: 3.2.1
|
160
|
+
type: :development
|
161
|
+
name: flog
|
162
|
+
version_requirements: *id009
|
163
|
+
description: transcore RubyGem
|
164
|
+
email: haracane@gmail.com
|
165
|
+
executables:
|
166
|
+
- transcore
|
167
|
+
extensions: []
|
168
|
+
|
169
|
+
extra_rdoc_files:
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.md
|
172
|
+
files:
|
173
|
+
- .document
|
174
|
+
- .rspec
|
175
|
+
- Gemfile
|
176
|
+
- LICENSE.txt
|
177
|
+
- README.md
|
178
|
+
- Rakefile
|
179
|
+
- VERSION
|
180
|
+
- bin/transcore
|
181
|
+
- lib/transcore.rb
|
182
|
+
- lib/transcore/command/convert.rb
|
183
|
+
- lib/transcore/command/transpose.rb
|
184
|
+
- spec/bin/transcore_spec.rb
|
185
|
+
- spec/lib/transcore/command/convert_spec.rb
|
186
|
+
- spec/lib/transcore/command/transpose_spec.rb
|
187
|
+
- spec/lib/transcore_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
homepage: http://github.com/haracane/transcore
|
190
|
+
licenses:
|
191
|
+
- MIT
|
192
|
+
post_install_message:
|
193
|
+
rdoc_options: []
|
194
|
+
|
195
|
+
require_paths:
|
196
|
+
- lib
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
+
none: false
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
hash: 3
|
203
|
+
segments:
|
204
|
+
- 0
|
205
|
+
version: "0"
|
206
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
207
|
+
none: false
|
208
|
+
requirements:
|
209
|
+
- - ">="
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
hash: 3
|
212
|
+
segments:
|
213
|
+
- 0
|
214
|
+
version: "0"
|
215
|
+
requirements: []
|
216
|
+
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 1.8.24
|
219
|
+
signing_key:
|
220
|
+
specification_version: 3
|
221
|
+
summary: transcore RubyGem
|
222
|
+
test_files: []
|
223
|
+
|