transcore 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rubocop.yml +57 -0
- data/Gemfile +2 -24
- data/README.md +12 -6
- data/Rakefile +5 -73
- data/bin/transcore +3 -3
- data/lib/transcore.rb +9 -9
- data/lib/transcore/command/convert.rb +78 -42
- data/lib/transcore/command/default.rb +2 -13
- data/lib/transcore/command/transpose.rb +34 -36
- data/lib/transcore/version.rb +3 -0
- data/spec/bin/transcore_spec.rb +20 -21
- data/spec/lib/transcore/command/convert_spec.rb +41 -43
- data/spec/lib/transcore/command/transpose_spec.rb +15 -17
- data/spec/lib/transcore_spec.rb +2 -2
- data/spec/spec_helper.rb +3 -37
- data/transcore.gemspec +20 -78
- metadata +88 -186
- data/VERSION +0 -1
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cb27def93ffbc709e212a15b048e5c8429ebdd95
|
4
|
+
data.tar.gz: c540837b47b9ba442a4f0adeda5a98c53a644432
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 044f4a1b8a3527827cf5cd076e5d36789dec54229bf1e7d47443abd07f85dd7186fe0b379e49517586fa4aef21ce879140223c57467d8c9e9b5fd66530898fb7
|
7
|
+
data.tar.gz: 557f8b9317f1439f3cc92d207d56329ba4f2c88a4e5d36eb9da5ad8aa7ce01df84ab6020095a87dd9c1ed83a89853cb55c2d24cbb8535ed1255214718196518e
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
AllCops:
|
2
|
+
RunRailsCops: true
|
3
|
+
Exclude:
|
4
|
+
- vendor/**/*
|
5
|
+
- db/schema.rb
|
6
|
+
- app/models/legacy/**
|
7
|
+
- db/migrate/2013*
|
8
|
+
- db/migrate/20140[1-8]*
|
9
|
+
- config/initializers/*patch*
|
10
|
+
|
11
|
+
LineLength:
|
12
|
+
Max: 120
|
13
|
+
|
14
|
+
MethodLength:
|
15
|
+
Max: 15
|
16
|
+
|
17
|
+
Documentation:
|
18
|
+
Enabled: false
|
19
|
+
|
20
|
+
AsciiComments:
|
21
|
+
Enabled: false
|
22
|
+
|
23
|
+
ClassAndModuleChildren:
|
24
|
+
EnforcedStyle: nested
|
25
|
+
|
26
|
+
NumericLiterals:
|
27
|
+
MinDigits: 7
|
28
|
+
|
29
|
+
StringLiterals:
|
30
|
+
EnforcedStyle: single_quotes
|
31
|
+
|
32
|
+
SpaceBeforeBlockBraces:
|
33
|
+
EnforcedStyle: space
|
34
|
+
|
35
|
+
SpaceInsideBlockBraces:
|
36
|
+
EnforcedStyle: space
|
37
|
+
EnforcedStyleForEmptyBraces: no_space
|
38
|
+
SpaceBeforeBlockParameters: true
|
39
|
+
|
40
|
+
SpaceInsideHashLiteralBraces:
|
41
|
+
EnforcedStyle: no_space
|
42
|
+
EnforcedStyleForEmptyBraces: no_space
|
43
|
+
|
44
|
+
DotPosition:
|
45
|
+
EnforcedStyle: trailing
|
46
|
+
|
47
|
+
RaiseArgs:
|
48
|
+
EnforcedStyle: exploded
|
49
|
+
|
50
|
+
SignalException:
|
51
|
+
EnforcedStyle: semantic
|
52
|
+
|
53
|
+
Style/IndentationConsistency:
|
54
|
+
Enabled: true
|
55
|
+
|
56
|
+
Style/DoubleNegation:
|
57
|
+
Enabled: false
|
data/Gemfile
CHANGED
@@ -1,25 +1,3 @@
|
|
1
|
-
source
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
1
|
+
source 'https://rubygems.org'
|
5
2
|
|
6
|
-
|
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
|
3
|
+
gemspec
|
data/README.md
CHANGED
@@ -5,9 +5,7 @@ Music score converter.
|
|
5
5
|
## Supported Ruby versions and implementations
|
6
6
|
Lapidary should work identically on:
|
7
7
|
|
8
|
-
* Ruby 1.
|
9
|
-
* Ruby 1.9.2
|
10
|
-
* Ruby 1.8.7
|
8
|
+
* Ruby 2.1.4
|
11
9
|
|
12
10
|
## Install
|
13
11
|
|
@@ -24,13 +22,21 @@ You can install transcore by gem.
|
|
24
22
|
B G#m E F#7
|
25
23
|
|
26
24
|
### Convert sharp to flat
|
27
|
-
$ echo "F Dm A# C7" | transcore flat
|
25
|
+
$ echo "F Dm A# C7" | transcore to-flat
|
28
26
|
F Dm B♭ C7
|
29
27
|
|
30
28
|
### Convert flat to sharp
|
31
|
-
$ echo "A G♭m D E7" | transcore sharp
|
29
|
+
$ echo "A G♭m D E7" | transcore to-sharp
|
32
30
|
A F#m D E7
|
33
31
|
|
32
|
+
### Convert from doremi
|
33
|
+
$ echo "doremifa solatido" | transcore from-doremi
|
34
|
+
CDEF GABC
|
35
|
+
|
36
|
+
### Convert to japanese
|
37
|
+
$ echo "CDEF GABC" | transcore to-japanese
|
38
|
+
ドレミファ ソラシド
|
39
|
+
|
34
40
|
### Convert html-score to text-score
|
35
41
|
$ cat score.html
|
36
42
|
<span>C</span>
|
@@ -40,7 +46,7 @@ You can install transcore by gem.
|
|
40
46
|
<br/>
|
41
47
|
<span>G7</span>
|
42
48
|
<span>lalala...</span>
|
43
|
-
$ cat score.html | transcore
|
49
|
+
$ cat score.html | transcore from-html
|
44
50
|
C Lalala F lala
|
45
51
|
G7 lalala...
|
46
52
|
|
data/Rakefile
CHANGED
@@ -1,76 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
|
-
require "rubygems"
|
4
|
-
require "bundler"
|
5
3
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
exit e.status_code
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
rescue LoadError
|
7
|
+
raise
|
11
8
|
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/bin/transcore
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'transcore'
|
4
4
|
|
5
5
|
command = ARGV[0]
|
6
6
|
|
7
7
|
exit_code = 0
|
8
8
|
|
9
9
|
case command
|
10
|
-
when
|
10
|
+
when 'transpose'
|
11
11
|
ARGV.shift
|
12
12
|
exit_code = Transcore::Command::Transpose.run(ARGV) || 0
|
13
|
-
when
|
13
|
+
when 'convert'
|
14
14
|
ARGV.shift
|
15
15
|
exit_code = Transcore::Command::Convert.run(ARGV) || 0
|
16
16
|
else
|
data/lib/transcore.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'logger'
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'transcore/command/convert'
|
4
|
+
require 'transcore/command/default'
|
5
|
+
require 'transcore/command/transpose'
|
6
6
|
|
7
7
|
module Transcore
|
8
8
|
# Reader method for the logger of Lapidary
|
@@ -10,18 +10,18 @@ module Transcore
|
|
10
10
|
def self.logger
|
11
11
|
if @logger.nil?
|
12
12
|
@logger = (rails_logger || default_logger)
|
13
|
-
@logger.formatter = proc { |severity, datetime,
|
13
|
+
@logger.formatter = proc { |severity, datetime, _progname, msg|
|
14
14
|
datetime.strftime("[%Y-%m-%d %H:%M:%S](#{severity}) #{msg}\n")
|
15
15
|
}
|
16
16
|
end
|
17
|
-
|
17
|
+
@logger
|
18
18
|
end
|
19
19
|
|
20
20
|
# Reader method for the rails logger of Lapidary
|
21
21
|
# @return [Logger] Logger object
|
22
22
|
def self.rails_logger
|
23
23
|
(defined?(Rails) && Rails.respond_to?(:logger) && Rails.logger) ||
|
24
|
-
|
24
|
+
(defined?(RAILS_DEFAULT_LOGGER) && RAILS_DEFAULT_LOGGER.respond_to?(:debug) && RAILS_DEFAULT_LOGGER)
|
25
25
|
end
|
26
26
|
|
27
27
|
# Reader method for the default logger of Lapidary
|
@@ -34,7 +34,7 @@ module Transcore
|
|
34
34
|
|
35
35
|
# Writer method for the logger of Lapidary
|
36
36
|
# @param logger [Logger]
|
37
|
-
|
38
|
-
|
37
|
+
class << self
|
38
|
+
attr_writer :logger
|
39
39
|
end
|
40
40
|
end
|
@@ -1,58 +1,94 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
module Transcore
|
3
2
|
module Command
|
4
3
|
module Convert
|
5
|
-
def self.parse_opts(
|
6
|
-
|
4
|
+
def self.parse_opts(_argv)
|
5
|
+
{}
|
7
6
|
end
|
8
|
-
|
9
|
-
def self.run(argv, input_stream
|
10
|
-
params = self.parse_opts(argv)
|
7
|
+
|
8
|
+
def self.run(argv, input_stream = $stdin, output_stream = $stdout)
|
11
9
|
command = argv.shift
|
12
10
|
input = input_stream.read
|
13
|
-
|
14
|
-
input.gsub!(/ /,
|
15
|
-
|
11
|
+
|
12
|
+
input.gsub!(/ /, ' ')
|
13
|
+
|
16
14
|
case command
|
17
|
-
when
|
18
|
-
input.gsub!(/(^|\s|\/|on)A♭/,
|
19
|
-
input.gsub!(/(^|\s|\/|on)B♭/,
|
20
|
-
input.gsub!(/(^|\s|\/|on)D♭/,
|
21
|
-
input.gsub!(/(^|\s|\/|on)E♭/,
|
22
|
-
input.gsub!(/(^|\s|\/|on)G♭/,
|
23
|
-
when
|
24
|
-
input.gsub!(/(^|\s|\/|on)G#/,
|
25
|
-
input.gsub!(/(^|\s|\/|on)A#/,
|
26
|
-
input.gsub!(/(^|\s|\/|on)C#/,
|
27
|
-
input.gsub!(/(^|\s|\/|on)D#/,
|
28
|
-
input.gsub!(/(^|\s|\/|on)F#/,
|
29
|
-
when
|
30
|
-
input.gsub!(/A/,
|
31
|
-
input.gsub!(/B/,
|
32
|
-
input.gsub!(/C/,
|
33
|
-
input.gsub!(/D/,
|
34
|
-
input.gsub!(/E/,
|
35
|
-
input.gsub!(/F/,
|
36
|
-
input.gsub!(/G/,
|
37
|
-
when
|
38
|
-
input.gsub!(
|
15
|
+
when 'to-sharp', 'sharp'
|
16
|
+
input.gsub!(/(^|\s|\/|on)A♭/, '\\1G#')
|
17
|
+
input.gsub!(/(^|\s|\/|on)B♭/, '\\1A#')
|
18
|
+
input.gsub!(/(^|\s|\/|on)D♭/, '\\1C#')
|
19
|
+
input.gsub!(/(^|\s|\/|on)E♭/, '\\1D#')
|
20
|
+
input.gsub!(/(^|\s|\/|on)G♭/, '\\1F#')
|
21
|
+
when 'to-flat', 'flat'
|
22
|
+
input.gsub!(/(^|\s|\/|on)G#/, '\\1A♭')
|
23
|
+
input.gsub!(/(^|\s|\/|on)A#/, '\\1B♭')
|
24
|
+
input.gsub!(/(^|\s|\/|on)C#/, '\\1D♭')
|
25
|
+
input.gsub!(/(^|\s|\/|on)D#/, '\\1E♭')
|
26
|
+
input.gsub!(/(^|\s|\/|on)F#/, '\\1G♭')
|
27
|
+
when 'to-japanese', 'doremi'
|
28
|
+
input.gsub!(/A/, 'ラ')
|
29
|
+
input.gsub!(/B/, 'シ')
|
30
|
+
input.gsub!(/C/, 'ド')
|
31
|
+
input.gsub!(/D/, 'レ')
|
32
|
+
input.gsub!(/E/, 'ミ')
|
33
|
+
input.gsub!(/F/, 'ファ')
|
34
|
+
input.gsub!(/G/, 'ソ')
|
35
|
+
when 'to-doremi', 'doremi'
|
36
|
+
input.gsub!(/A#/, 'li')
|
37
|
+
input.gsub!(/C#/, 'di')
|
38
|
+
input.gsub!(/D#/, 'ri')
|
39
|
+
input.gsub!(/F#/, 'fi')
|
40
|
+
input.gsub!(/G#/, 'si')
|
41
|
+
input.gsub!(/A♭/, 'le')
|
42
|
+
input.gsub!(/B♭/, 'te')
|
43
|
+
input.gsub!(/D♭/, 're')
|
44
|
+
input.gsub!(/E♭/, 'me')
|
45
|
+
input.gsub!(/G♭/, 'se')
|
46
|
+
input.gsub!(/A/, 'la')
|
47
|
+
input.gsub!(/B/, 'ti')
|
48
|
+
input.gsub!(/C/, 'do')
|
49
|
+
input.gsub!(/D/, 're')
|
50
|
+
input.gsub!(/E/, 'mi')
|
51
|
+
input.gsub!(/F/, 'fa')
|
52
|
+
input.gsub!(/G/, 'so')
|
53
|
+
when 'from-doremi'
|
54
|
+
input.gsub!(/la/i, 'A')
|
55
|
+
input.gsub!(/ti/i, 'B')
|
56
|
+
input.gsub!(/do/i, 'C')
|
57
|
+
input.gsub!(/re/i, 'D')
|
58
|
+
input.gsub!(/mi/i, 'E')
|
59
|
+
input.gsub!(/fa/i, 'F')
|
60
|
+
input.gsub!(/so/i, 'G')
|
61
|
+
input.gsub!(/li/i, 'A#')
|
62
|
+
input.gsub!(/di/i, 'C#')
|
63
|
+
input.gsub!(/ri/i, 'D#')
|
64
|
+
input.gsub!(/fi/i, 'F#')
|
65
|
+
input.gsub!(/si/i, 'G#')
|
66
|
+
input.gsub!(/le/i, 'A♭')
|
67
|
+
input.gsub!(/te/i, 'B♭')
|
68
|
+
input.gsub!(/re/i, 'D♭')
|
69
|
+
input.gsub!(/me/i, 'E♭')
|
70
|
+
input.gsub!(/se/i, 'G♭')
|
71
|
+
when 'from-html', 'text-score'
|
72
|
+
input.gsub!(/\n/, '')
|
39
73
|
input.gsub!(/<br\/?>/, "\n")
|
40
74
|
input.gsub!(/<\/p>/, "\n")
|
41
|
-
input.gsub!(/<[^>]+>/,
|
42
|
-
input.gsub!(/ /,
|
43
|
-
input.gsub!(/ /,
|
44
|
-
input.gsub!(/^ +/,
|
45
|
-
input.gsub!(/ +$/,
|
46
|
-
input.gsub!(///,
|
47
|
-
input.gsub!(/#/,
|
48
|
-
input.gsub!(/ /,
|
75
|
+
input.gsub!(/<[^>]+>/, ' ')
|
76
|
+
input.gsub!(/ /, ' ')
|
77
|
+
input.gsub!(/ /, ' ')
|
78
|
+
input.gsub!(/^ +/, '')
|
79
|
+
input.gsub!(/ +$/, '')
|
80
|
+
input.gsub!(///, '|')
|
81
|
+
input.gsub!(/#/, '#')
|
82
|
+
input.gsub!(/ /, ' ')
|
49
83
|
input.gsub!(/\n\n\n/, "\n\n")
|
84
|
+
else
|
85
|
+
return 2
|
50
86
|
end
|
51
87
|
result = input
|
52
|
-
|
88
|
+
|
53
89
|
output_stream.puts result
|
54
|
-
|
90
|
+
0
|
55
91
|
end
|
56
92
|
end
|
57
93
|
end
|
58
|
-
end
|
94
|
+
end
|
@@ -1,23 +1,12 @@
|
|
1
1
|
module Transcore
|
2
2
|
module Command
|
3
3
|
module Default
|
4
|
-
def self.run(argv, input_stream
|
4
|
+
def self.run(argv, input_stream = $stdin, output_stream = $stdout)
|
5
5
|
command = argv[0]
|
6
6
|
if /^[+\-]?[0-9]+$/ =~ command
|
7
7
|
return Transcore::Command::Transpose.run(argv, input_stream, output_stream)
|
8
8
|
else
|
9
|
-
|
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
|
9
|
+
return Transcore::Command::Convert.run(argv, input_stream, output_stream)
|
21
10
|
end
|
22
11
|
end
|
23
12
|
end
|