chordproko 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +80 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/chordproko.gemspec +38 -0
- data/lib/chordproko/chord.rb +40 -0
- data/lib/chordproko/chord_group.rb +20 -0
- data/lib/chordproko/comment.rb +15 -0
- data/lib/chordproko/directive.rb +16 -0
- data/lib/chordproko/line.rb +36 -0
- data/lib/chordproko/lyric.rb +14 -0
- data/lib/chordproko/newline.rb +14 -0
- data/lib/chordproko/parser.rb +41 -0
- data/lib/chordproko/plain_song.rb +48 -0
- data/lib/chordproko/sheet.rb +16 -0
- data/lib/chordproko/transform.rb +15 -0
- data/lib/chordproko/version.rb +3 -0
- data/lib/chordproko.rb +21 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d96af770f5a7ae0615269a3b09207a6a3d2dd8f0
|
4
|
+
data.tar.gz: 9608370884791fd3bb1a1feeab07fdc9056ce345
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b91a886179279f72ade0e3de9ed5cf9ab588208de27095e04283ec708517438cfe73b275872f335c3d7ed0efe3c1b5ec358e41518a69dcbd52932c7b0546d3d
|
7
|
+
data.tar.gz: 36b3c3427068a64239b2e8febf458a8d5effde2f786b6dd324b8b7298d68ec763f3011f4b534436cd327fb07c0ecc242e80769002aa451375cfd54de285c6872
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at valerosjoseph@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Joseph Nelson Valeros
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Chordproko
|
2
|
+
|
3
|
+
Chordproko is a parser for ruby. It converts chordpro format to a readable text format.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'chordproko'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install chordproko
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Suppose you have a song sheet written in ChordPro format:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
sheet = "Th[C]is is a sam[G]ple lyr[Em]ic with ch[D]ord"
|
27
|
+
readable_sheet = Chordproko.text(sheet)
|
28
|
+
```
|
29
|
+
|
30
|
+
Or load from file
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
file = File.new("file_location")
|
34
|
+
readable_sheet = Chordproko.text(file.read)
|
35
|
+
```
|
36
|
+
### Transposing
|
37
|
+
|
38
|
+
You can transpose a song by adding ```transpose``` option.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
readable_sheet = Chordproko.text(file.read, transpose: 2)
|
42
|
+
```
|
43
|
+
Negative value means transpose down, otherwise, transpose up.
|
44
|
+
|
45
|
+
### Using raw data
|
46
|
+
|
47
|
+
Create your own algorithm using the result of Chordproko **Parser**. It uses parslet so you have to learn parslet first. You can check the source code for rules.
|
48
|
+
```ruby
|
49
|
+
parsed = Chordproko::Parser.new.parse(file.read)
|
50
|
+
```
|
51
|
+
Then, create your own **Transform** class.
|
52
|
+
|
53
|
+
## TODO
|
54
|
+
|
55
|
+
+ Enable you to extend PlainSong class
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
class MySongFormat < Chordproko::PlainSong
|
59
|
+
...
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
PlainSong is responsible in formatting the ChordPro format to a readable plain text format.
|
64
|
+
|
65
|
+
+ Improve specs
|
66
|
+
+ Improve documentations
|
67
|
+
+ Improve source (so many unnecessary lines. It works, so it's fine for now.)
|
68
|
+
+ Support ```b``` flat sign
|
69
|
+
+ Implement PlainSong methods with block (Might help a lot in customizing contents.)
|
70
|
+
+ Add settings and customization
|
71
|
+
+ Learns sheet key.
|
72
|
+
|
73
|
+
## Contributing
|
74
|
+
|
75
|
+
I'm certain that you have reached this section haha. This is my first gem, I still have a lot to learn. You can report errors, suggest features and create pull requests here, https://github.com/neume/chordproko.
|
76
|
+
|
77
|
+
|
78
|
+
## License
|
79
|
+
|
80
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "chordproko"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/chordproko.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chordproko/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chordproko"
|
8
|
+
spec.version = Chordproko::VERSION
|
9
|
+
spec.authors = ["Joseph Nelson Valeros"]
|
10
|
+
spec.email = ["valerosjoseph@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Ruby ChordPro parser"
|
13
|
+
spec.description = "It converts ChordPro File to a readable plain text chord sheet"
|
14
|
+
spec.homepage = "https://github.com/neume/chordproko"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_dependency 'parslet','~> 1.8'
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 1.14"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Chordproko
|
2
|
+
|
3
|
+
class Chord
|
4
|
+
attr_accessor :content, :key
|
5
|
+
def initialize content
|
6
|
+
@content = content
|
7
|
+
@chord_list = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"]
|
8
|
+
@chord_indexes = {
|
9
|
+
"C" => 0,
|
10
|
+
"D" => 2,
|
11
|
+
"E" => 4,
|
12
|
+
"F" => 5,
|
13
|
+
"G" => 7,
|
14
|
+
"A" => 9,
|
15
|
+
"B" => 11,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
def each(&block)
|
19
|
+
[self].each(&block)
|
20
|
+
end
|
21
|
+
def to_s
|
22
|
+
"#{transpose_key}"
|
23
|
+
end
|
24
|
+
def transpose_key
|
25
|
+
return @content.to_s if @key == 0
|
26
|
+
chord_value = @chord_indexes[@content.to_s[0]]
|
27
|
+
@content.to_s[1..-1].each_char do |mod|
|
28
|
+
case mod
|
29
|
+
when "#"
|
30
|
+
chord_value += 1
|
31
|
+
when "b"
|
32
|
+
chord_value -= 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
chord_index = (chord_value + @key)% 12
|
36
|
+
res = @chord_list[chord_index]
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class ChordGroup
|
3
|
+
attr_accessor :content, :key
|
4
|
+
def initialize content
|
5
|
+
@content = content
|
6
|
+
@key = 0
|
7
|
+
end
|
8
|
+
def each(&block)
|
9
|
+
[self].each(&block)
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
@content.each do |c|
|
13
|
+
if c.class.to_s == "Chordproko::Chord"
|
14
|
+
c.key = @key
|
15
|
+
end
|
16
|
+
c.to_s
|
17
|
+
end.join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class Directive
|
3
|
+
attr_accessor :key, :value
|
4
|
+
|
5
|
+
def each(&block)
|
6
|
+
[self].each(&block)
|
7
|
+
end
|
8
|
+
def initialize key, value
|
9
|
+
@key = key
|
10
|
+
@value = value
|
11
|
+
end
|
12
|
+
def to_s
|
13
|
+
"#{@key.to_s.capitalize}: #{@value}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class Line
|
3
|
+
attr_accessor :content
|
4
|
+
def initialize content
|
5
|
+
@content = content
|
6
|
+
end
|
7
|
+
|
8
|
+
def each(&block)
|
9
|
+
@content.each(&block) rescue [@content]
|
10
|
+
end
|
11
|
+
def to_s
|
12
|
+
case @content.class.to_s
|
13
|
+
when "Chordproko::Comment"
|
14
|
+
@content.to_s
|
15
|
+
when "Chordproko::Directive"
|
16
|
+
@content.to_s
|
17
|
+
when "String"
|
18
|
+
""
|
19
|
+
else
|
20
|
+
chords = ""
|
21
|
+
lyrics = ""
|
22
|
+
prev_lyrics = ""
|
23
|
+
@content.each do |c|
|
24
|
+
case c.class.to_s
|
25
|
+
when "Chordproko::ChordGroup"
|
26
|
+
chords += " " * prev_lyrics.size + "#{c}"
|
27
|
+
when "Chordproko::Lyric"
|
28
|
+
prev_lyrics = "#{c}"
|
29
|
+
lyrics += "#{c}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
"#{chords}\n#{lyrics}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'parslet'
|
2
|
+
require 'parslet/convenience'
|
3
|
+
module Chordproko
|
4
|
+
class Parser < Parslet::Parser
|
5
|
+
# Characters
|
6
|
+
rule(:space) { match('\s').repeat }
|
7
|
+
rule(:newline) { str("\n")}
|
8
|
+
rule(:lbrace) { str('{') }
|
9
|
+
rule(:rbrace) { str('}') }
|
10
|
+
rule(:lbracket) { str('[') }
|
11
|
+
rule(:rbracket) { str(']') }
|
12
|
+
rule(:colon) { str(':')}
|
13
|
+
rule(:sharp) { str('#') }
|
14
|
+
rule(:flat) { str('b') }
|
15
|
+
rule(:chord_modifier) { sharp.maybe >> flat.maybe}
|
16
|
+
rule(:chord_base) {match('[ABCDEFG]')}
|
17
|
+
rule(:chord) { (chord_base >> chord_modifier.maybe).as(:chord) }
|
18
|
+
rule(:chord_delim) { (rbracket.absent? >> chord_base.absent? >> any).repeat(0).as(:chord_delim) }
|
19
|
+
rule(:chords) { (lbracket >> ((rbracket.absent? >> (chord | chord_delim)).repeat(1)).as(:chords) >> rbracket) }
|
20
|
+
rule(:lyric) { (lbracket.absent? >> newline.absent? >> any).repeat(1).as(:lyric)}
|
21
|
+
rule(:comments) do
|
22
|
+
(sharp >> (newline.absent? >> any).repeat).as(:comment)
|
23
|
+
end
|
24
|
+
rule(:lyrics) do
|
25
|
+
( (newline.absent? >> ( chords | lyric )).repeat(1))
|
26
|
+
end
|
27
|
+
rule(:key) { match["a-z"].repeat(1).as(:key)}
|
28
|
+
rule(:value) { ((rbrace.absent? >> any).repeat(1)).as(:value)}
|
29
|
+
rule(:directive) do
|
30
|
+
(key >> space.maybe >> colon >> space.maybe >> value).as(:directive)
|
31
|
+
end
|
32
|
+
rule(:directives) do
|
33
|
+
(lbrace >> space.maybe >> (rbrace.absent? >> directive) >> rbrace)
|
34
|
+
end
|
35
|
+
rule(:line) { ((comments | directives | lyrics | newline.as(:newline)) >> newline.maybe).as(:line)}
|
36
|
+
rule(:lines) { line.repeat(1)}
|
37
|
+
rule(:sheet) { lines.as(:sheet) }
|
38
|
+
|
39
|
+
root(:sheet)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class PlainSong
|
3
|
+
def initialize sheet, options={transpose: 1}
|
4
|
+
@sheet = sheet
|
5
|
+
@options = options
|
6
|
+
end
|
7
|
+
def to_s
|
8
|
+
content
|
9
|
+
end
|
10
|
+
def content
|
11
|
+
@content ||= generate
|
12
|
+
end
|
13
|
+
def generate
|
14
|
+
textified = ""
|
15
|
+
@sheet.each do |line|
|
16
|
+
chords = ""
|
17
|
+
lyrics = ""
|
18
|
+
prev_lyrics = ""
|
19
|
+
prev_chord = ""
|
20
|
+
line.each do |element|
|
21
|
+
element.each do |item|
|
22
|
+
case item.class.to_s
|
23
|
+
when "Chordproko::Comment"
|
24
|
+
textified += item.to_s
|
25
|
+
when "Chordproko::Directive"
|
26
|
+
textified += item.to_s
|
27
|
+
when "Chordproko::ChordGroup"
|
28
|
+
item.key = @options[:transpose] if @options[:transpose] rescue 0
|
29
|
+
chord_group = item.to_s
|
30
|
+
chords += (" " * (prev_lyrics.size - prev_chord.size).abs)+ chord_group
|
31
|
+
prev_chord = chord_group
|
32
|
+
|
33
|
+
when "Chordproko::Lyric"
|
34
|
+
prev_lyrics = item.to_s
|
35
|
+
lyrics += item.to_s
|
36
|
+
end
|
37
|
+
end #case
|
38
|
+
end #line
|
39
|
+
chord_lyrics = []
|
40
|
+
chord_lyrics << chords if chords.size > 0
|
41
|
+
chord_lyrics << lyrics if lyrics.size > 0
|
42
|
+
textified += chord_lyrics.join("\n")
|
43
|
+
textified += "\n"
|
44
|
+
end #sheet
|
45
|
+
textified
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class Sheet
|
3
|
+
attr_accessor :content, :transpose
|
4
|
+
def initialize content
|
5
|
+
@content = content
|
6
|
+
end
|
7
|
+
def each(&block)
|
8
|
+
@content.each(&block)
|
9
|
+
end
|
10
|
+
def to_s
|
11
|
+
@content.each do |line|
|
12
|
+
"#{line}"
|
13
|
+
end.join("\n")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Chordproko
|
2
|
+
class Transform < Parslet::Transform
|
3
|
+
rule(newline: simple(:x)) { "" }
|
4
|
+
rule(comment: simple(:x)) { Chordproko::Comment.new(x)}
|
5
|
+
rule(chord: simple(:x)) { Chordproko::Chord.new(x)}
|
6
|
+
rule(chord_delim: simple(:delim)) { "#{delim}" }
|
7
|
+
rule(lyric: simple(:x)) { Chordproko::Lyric.new(x)}
|
8
|
+
rule(directive: { key: simple(:key), value: simple(:value) }) do
|
9
|
+
Chordproko::Directive.new(key, value)
|
10
|
+
end
|
11
|
+
rule(chords: subtree(:chords)) { Chordproko::ChordGroup.new(chords)}
|
12
|
+
rule(line: subtree(:line)) { Chordproko::Line.new(line) }
|
13
|
+
rule(sheet: sequence(:sheet)) { Chordproko::Sheet.new(sheet) }
|
14
|
+
end
|
15
|
+
end
|
data/lib/chordproko.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
require "chordproko/chord"
|
3
|
+
require "chordproko/chord_group"
|
4
|
+
require "chordproko/comment"
|
5
|
+
require "chordproko/directive"
|
6
|
+
require "chordproko/line"
|
7
|
+
require "chordproko/lyric"
|
8
|
+
require "chordproko/newline"
|
9
|
+
require "chordproko/parser"
|
10
|
+
require "chordproko/plain_song"
|
11
|
+
require "chordproko/sheet"
|
12
|
+
require "chordproko/transform"
|
13
|
+
require "chordproko/version"
|
14
|
+
module Chordproko
|
15
|
+
def self.text song, options={}
|
16
|
+
parsed = Chordproko::Parser.new.parse(song)
|
17
|
+
transformed = Transform.new.apply(parsed)
|
18
|
+
sheet = PlainSong.new(transformed, options)
|
19
|
+
sheet.to_s
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chordproko
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Nelson Valeros
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: parslet
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: It converts ChordPro File to a readable plain text chord sheet
|
70
|
+
email:
|
71
|
+
- valerosjoseph@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".ruby-version"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- chordproko.gemspec
|
88
|
+
- lib/chordproko.rb
|
89
|
+
- lib/chordproko/chord.rb
|
90
|
+
- lib/chordproko/chord_group.rb
|
91
|
+
- lib/chordproko/comment.rb
|
92
|
+
- lib/chordproko/directive.rb
|
93
|
+
- lib/chordproko/line.rb
|
94
|
+
- lib/chordproko/lyric.rb
|
95
|
+
- lib/chordproko/newline.rb
|
96
|
+
- lib/chordproko/parser.rb
|
97
|
+
- lib/chordproko/plain_song.rb
|
98
|
+
- lib/chordproko/sheet.rb
|
99
|
+
- lib/chordproko/transform.rb
|
100
|
+
- lib/chordproko/version.rb
|
101
|
+
homepage: https://github.com/neume/chordproko
|
102
|
+
licenses:
|
103
|
+
- MIT
|
104
|
+
metadata: {}
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.5.1
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Ruby ChordPro parser
|
125
|
+
test_files: []
|