JoergWMittag-akkordarbeit 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.rdoc +22 -0
- data/README.rdoc +38 -0
- data/bin/akkordarbeit +54 -0
- data/features/html_formatter.feature +172 -0
- data/features/parser.feature +63 -0
- data/features/step_definitions/akkordarbeit_steps.rb +53 -0
- data/features/text_formatter.feature +76 -0
- data/lib/akkordarbeit.rb +12 -0
- data/lib/akkordarbeit/html_formatter.rb +74 -0
- data/lib/akkordarbeit/parser.rb +26 -0
- data/lib/akkordarbeit/text_formatter.rb +32 -0
- data/spec/akkordarbeit_spec.rb +14 -0
- data/spec/akkordarbeit_suite.rb +12 -0
- data/spec/spec_helper.rb +13 -0
- metadata +126 -0
data/LICENSE.rdoc
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
= The MIT License
|
2
|
+
|
3
|
+
* Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
* Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
= Abstract
|
2
|
+
|
3
|
+
Akkordarbeit[https://JoergWMittag.GitHub.Com/akkordarbeit/] is a
|
4
|
+
program for formatting simple leadsheets in a simplified ChordPro
|
5
|
+
format to various other formats such as HTML or plaintext.
|
6
|
+
|
7
|
+
---
|
8
|
+
|
9
|
+
= What
|
10
|
+
|
11
|
+
This program converts leadsheets and songsheets written in a
|
12
|
+
subset of the widely used
|
13
|
+
ChordPro[http://Vromans.Org/johan/projects/Chordii/chordpro/]
|
14
|
+
file format into other formats, more suitable for printing or
|
15
|
+
publishing. Currently, the supported formats are plaintext and
|
16
|
+
HTML.
|
17
|
+
|
18
|
+
Akkordarbeit only supports a very small subset of the ChordPro
|
19
|
+
format. Specifically, it only supports song lines, no directives.
|
20
|
+
|
21
|
+
= Installation
|
22
|
+
|
23
|
+
gem install JoergWMittag-akkordarbeit
|
24
|
+
|
25
|
+
= Usage
|
26
|
+
|
27
|
+
akkordarbeit -f html -i input.cho -o output.html
|
28
|
+
|
29
|
+
= Acknowledgements
|
30
|
+
|
31
|
+
Akkordarbeit would not be possible without the original Chord
|
32
|
+
utility.
|
33
|
+
|
34
|
+
= License
|
35
|
+
|
36
|
+
Akkordarbeit is licensed under the {MIT X11 License}[https://GitHub.Com/JoergWMittag/Akkordarbeit/blob/master/LICENSE.rdoc].
|
37
|
+
|
38
|
+
:include: LICENSE.rdoc
|
data/bin/akkordarbeit
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
3
|
+
|
4
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
6
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
7
|
+
|
8
|
+
libdir = File.expand_path(File.join File.dirname(File.expand_path(__FILE__).gsub(/(.*)bin.*?/, '\1')), 'lib')
|
9
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
10
|
+
|
11
|
+
require 'optparse'
|
12
|
+
require 'akkordarbeit'
|
13
|
+
|
14
|
+
module Akkordarbeit
|
15
|
+
class Main
|
16
|
+
def initialize args
|
17
|
+
@args = args
|
18
|
+
@options = { :format => 'HTML', :input => $stdin, :output => $stdout }
|
19
|
+
@option_parser = OptionParser.new do |opts|
|
20
|
+
opts.banner = 'Usage: akkordarbeit -f <FORMAT> -i <INPUT> -o <OUTPUT>'
|
21
|
+
opts.on('-f', '--format [FORMAT]', 'Use output format <FORMAT> instead of HTML') do |format|
|
22
|
+
@options[:format] = format
|
23
|
+
end
|
24
|
+
opts.on('-i', '--input [INPUTFILE]', 'Use Filename instead of STDIN') do |file|
|
25
|
+
@options[:input] = open file
|
26
|
+
end
|
27
|
+
opts.on('-o', '--output [OUTPUTFILE]', 'Use Filename instead of STDOUT') do |file|
|
28
|
+
@options[:output] = open file, 'w'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def run!
|
34
|
+
@option_parser.parse! @args
|
35
|
+
parsetree = Parser.new.parse @options[:input].gets(nil)
|
36
|
+
output = case @options[:format]
|
37
|
+
when /html/i
|
38
|
+
HtmlFormatter.new.format parsetree
|
39
|
+
when /text/i
|
40
|
+
TextFormatter.new.format parsetree
|
41
|
+
end
|
42
|
+
@options[:output].puts output
|
43
|
+
ensure
|
44
|
+
@options[:input].close
|
45
|
+
@options[:output].close
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.run!
|
49
|
+
new(ARGV).run!
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
Main.run!
|
54
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
Feature: HTML Output
|
2
|
+
In order to view the chord files
|
3
|
+
As a user
|
4
|
+
I want to get HTML output
|
5
|
+
|
6
|
+
Scenario: HTML Output of a simple Song
|
7
|
+
Given the parsetree
|
8
|
+
"""
|
9
|
+
[
|
10
|
+
[
|
11
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
12
|
+
]
|
13
|
+
]
|
14
|
+
"""
|
15
|
+
|
16
|
+
When I format it as HTML
|
17
|
+
Then the output should be
|
18
|
+
"""
|
19
|
+
<!DOCTYPE html>
|
20
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
21
|
+
<head>
|
22
|
+
<meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
|
23
|
+
<title>Song-Sheet</title>
|
24
|
+
<meta http-equiv='content-language' content='en' />
|
25
|
+
<style>
|
26
|
+
p {
|
27
|
+
line-height: 300%;
|
28
|
+
max-width: 30em;
|
29
|
+
}
|
30
|
+
.chord {
|
31
|
+
position: relative;
|
32
|
+
}
|
33
|
+
.chord span {
|
34
|
+
position: absolute;
|
35
|
+
bottom: 40%;
|
36
|
+
font-size: 66%;
|
37
|
+
font-weight: bold;
|
38
|
+
}
|
39
|
+
.chord .brackets {
|
40
|
+
display: none;
|
41
|
+
}
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<header>
|
46
|
+
<h1>Song-Sheet</h1>
|
47
|
+
</header>
|
48
|
+
<section>
|
49
|
+
<p>
|
50
|
+
<span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
51
|
+
</p>
|
52
|
+
</section>
|
53
|
+
</body>
|
54
|
+
</html>
|
55
|
+
|
56
|
+
"""
|
57
|
+
|
58
|
+
Scenario: HTML Output of a simple Song with one Section and two lines
|
59
|
+
Given the parsetree
|
60
|
+
"""
|
61
|
+
[
|
62
|
+
[
|
63
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
64
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
65
|
+
]
|
66
|
+
]
|
67
|
+
"""
|
68
|
+
|
69
|
+
When I format it as HTML
|
70
|
+
Then the output should be
|
71
|
+
"""
|
72
|
+
<!DOCTYPE html>
|
73
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
74
|
+
<head>
|
75
|
+
<meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
|
76
|
+
<title>Song-Sheet</title>
|
77
|
+
<meta http-equiv='content-language' content='en' />
|
78
|
+
<style>
|
79
|
+
p {
|
80
|
+
line-height: 300%;
|
81
|
+
max-width: 30em;
|
82
|
+
}
|
83
|
+
.chord {
|
84
|
+
position: relative;
|
85
|
+
}
|
86
|
+
.chord span {
|
87
|
+
position: absolute;
|
88
|
+
bottom: 40%;
|
89
|
+
font-size: 66%;
|
90
|
+
font-weight: bold;
|
91
|
+
}
|
92
|
+
.chord .brackets {
|
93
|
+
display: none;
|
94
|
+
}
|
95
|
+
</style>
|
96
|
+
</head>
|
97
|
+
<body>
|
98
|
+
<header>
|
99
|
+
<h1>Song-Sheet</h1>
|
100
|
+
</header>
|
101
|
+
<section>
|
102
|
+
<p>
|
103
|
+
<span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
104
|
+
Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
105
|
+
</p>
|
106
|
+
</section>
|
107
|
+
</body>
|
108
|
+
</html>
|
109
|
+
|
110
|
+
"""
|
111
|
+
|
112
|
+
Scenario: HTML Output of a simple Song with two Section and two lines
|
113
|
+
Given the parsetree
|
114
|
+
"""
|
115
|
+
[
|
116
|
+
[
|
117
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
118
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
119
|
+
],
|
120
|
+
[
|
121
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
122
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
123
|
+
]
|
124
|
+
]
|
125
|
+
"""
|
126
|
+
|
127
|
+
When I format it as HTML
|
128
|
+
Then the output should be
|
129
|
+
"""
|
130
|
+
<!DOCTYPE html>
|
131
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
132
|
+
<head>
|
133
|
+
<meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
|
134
|
+
<title>Song-Sheet</title>
|
135
|
+
<meta http-equiv='content-language' content='en' />
|
136
|
+
<style>
|
137
|
+
p {
|
138
|
+
line-height: 300%;
|
139
|
+
max-width: 30em;
|
140
|
+
}
|
141
|
+
.chord {
|
142
|
+
position: relative;
|
143
|
+
}
|
144
|
+
.chord span {
|
145
|
+
position: absolute;
|
146
|
+
bottom: 40%;
|
147
|
+
font-size: 66%;
|
148
|
+
font-weight: bold;
|
149
|
+
}
|
150
|
+
.chord .brackets {
|
151
|
+
display: none;
|
152
|
+
}
|
153
|
+
</style>
|
154
|
+
</head>
|
155
|
+
<body>
|
156
|
+
<header>
|
157
|
+
<h1>Song-Sheet</h1>
|
158
|
+
</header>
|
159
|
+
<section>
|
160
|
+
<p>
|
161
|
+
<span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
162
|
+
Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
163
|
+
</p>
|
164
|
+
<p>
|
165
|
+
<span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>Do what I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
166
|
+
Do what <span class='chord'><span><span class='brackets'>[</span>D<span class='brackets'>]</span></span>I say, </span><span class='chord'><span><span class='brackets'>[</span>Em<span class='brackets'>]</span></span>or I will suffer</span><br />
|
167
|
+
</p>
|
168
|
+
</section>
|
169
|
+
</body>
|
170
|
+
</html>
|
171
|
+
|
172
|
+
"""
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Feature: Parsing
|
2
|
+
In order to seperate backend and frontend
|
3
|
+
As a backend writer
|
4
|
+
I want to get a parsetree
|
5
|
+
|
6
|
+
Scenario: Simple Song
|
7
|
+
Given the song
|
8
|
+
"""
|
9
|
+
[D]Do what I say, [Em]or I will suffer
|
10
|
+
"""
|
11
|
+
|
12
|
+
When I parse it
|
13
|
+
Then the parsetree should be
|
14
|
+
"""
|
15
|
+
[
|
16
|
+
[
|
17
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
18
|
+
]
|
19
|
+
]
|
20
|
+
"""
|
21
|
+
|
22
|
+
Scenario: Simple Song Multiline
|
23
|
+
Given the song
|
24
|
+
"""
|
25
|
+
[D]Do what I say, [Em]or I will suffer
|
26
|
+
[D]Do what I say, [Em]or I will suffer
|
27
|
+
"""
|
28
|
+
|
29
|
+
When I parse it
|
30
|
+
Then the parsetree should be
|
31
|
+
"""
|
32
|
+
[
|
33
|
+
[
|
34
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
35
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
36
|
+
]
|
37
|
+
]
|
38
|
+
"""
|
39
|
+
|
40
|
+
Scenario: Song with two sections
|
41
|
+
Given the song
|
42
|
+
"""
|
43
|
+
[D]Do what I say, [Em]or I will suffer
|
44
|
+
[D]Do what I say, [Em]or I will suffer
|
45
|
+
|
46
|
+
[D]Do what I say, [Em]or I will suffer
|
47
|
+
[D]Do what I say, [Em]or I will suffer
|
48
|
+
"""
|
49
|
+
|
50
|
+
When I parse it
|
51
|
+
Then the parsetree should be
|
52
|
+
"""
|
53
|
+
[
|
54
|
+
[
|
55
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
56
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
57
|
+
],
|
58
|
+
[
|
59
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
60
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
61
|
+
]
|
62
|
+
]
|
63
|
+
"""
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
require 'cucumber'
|
8
|
+
require 'spec/expectations'
|
9
|
+
|
10
|
+
stepsdir = File.expand_path(File.dirname __FILE__).gsub(/(.*step_definitions).*?/, '\1')
|
11
|
+
featuredir = File.expand_path File.join(stepsdir, '..')
|
12
|
+
libdir = File.expand_path File.join(featuredir, '..', 'lib')
|
13
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
14
|
+
|
15
|
+
require 'akkordarbeit'
|
16
|
+
|
17
|
+
Before do
|
18
|
+
@parser = Akkordarbeit::Parser.new
|
19
|
+
end
|
20
|
+
|
21
|
+
Given 'the song' do |song|
|
22
|
+
@song = song
|
23
|
+
end
|
24
|
+
|
25
|
+
When 'I parse it' do
|
26
|
+
@result = @parser.parse @song
|
27
|
+
end
|
28
|
+
|
29
|
+
Then 'the parsetree should be' do |parsetree|
|
30
|
+
@result.should == eval(parsetree)
|
31
|
+
end
|
32
|
+
|
33
|
+
Before do
|
34
|
+
@text_formatter = Akkordarbeit::TextFormatter.new
|
35
|
+
@html_formatter = Akkordarbeit::HtmlFormatter.new
|
36
|
+
end
|
37
|
+
|
38
|
+
Given 'the parsetree' do |parsetree|
|
39
|
+
@parsetree = eval(parsetree)
|
40
|
+
end
|
41
|
+
|
42
|
+
When 'I format it as (.*)' do |format|
|
43
|
+
@result = case format
|
44
|
+
when /html/i
|
45
|
+
@html_formatter.format @parsetree
|
46
|
+
when /text/i
|
47
|
+
@text_formatter.format @parsetree
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Then 'the output should be' do |output|
|
52
|
+
@result.should == output
|
53
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
Feature: Text Output
|
2
|
+
In order to view the chord files
|
3
|
+
As a user
|
4
|
+
I want to get a text output
|
5
|
+
|
6
|
+
Scenario: Text Output of a simple Song
|
7
|
+
Given the parsetree
|
8
|
+
"""
|
9
|
+
[
|
10
|
+
[
|
11
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer']
|
12
|
+
]
|
13
|
+
]
|
14
|
+
"""
|
15
|
+
|
16
|
+
When I format it as text
|
17
|
+
Then the output should be
|
18
|
+
"""
|
19
|
+
[D] [Em]
|
20
|
+
Do what I say, or I will suffer
|
21
|
+
|
22
|
+
|
23
|
+
"""
|
24
|
+
|
25
|
+
Scenario: Text Output of a simple Song with one Section and two lines
|
26
|
+
Given the parsetree
|
27
|
+
"""
|
28
|
+
[
|
29
|
+
[
|
30
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
31
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
32
|
+
]
|
33
|
+
]
|
34
|
+
"""
|
35
|
+
|
36
|
+
When I format it as text
|
37
|
+
Then the output should be
|
38
|
+
"""
|
39
|
+
[D] [Em]
|
40
|
+
Do what I say, or I will suffer
|
41
|
+
[D] [Em]
|
42
|
+
Do what I say, or I will suffer
|
43
|
+
|
44
|
+
|
45
|
+
"""
|
46
|
+
|
47
|
+
Scenario: Text Output of a simple Song with two Section and two lines
|
48
|
+
Given the parsetree
|
49
|
+
"""
|
50
|
+
[
|
51
|
+
[
|
52
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
53
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
54
|
+
],
|
55
|
+
[
|
56
|
+
['[D]', 'Do what I say, ', '[Em]', 'or I will suffer'],
|
57
|
+
['Do what ', '[D]', 'I say, ', '[Em]', 'or I will suffer']
|
58
|
+
]
|
59
|
+
]
|
60
|
+
"""
|
61
|
+
|
62
|
+
When I format it as text
|
63
|
+
Then the output should be
|
64
|
+
"""
|
65
|
+
[D] [Em]
|
66
|
+
Do what I say, or I will suffer
|
67
|
+
[D] [Em]
|
68
|
+
Do what I say, or I will suffer
|
69
|
+
|
70
|
+
[D] [Em]
|
71
|
+
Do what I say, or I will suffer
|
72
|
+
[D] [Em]
|
73
|
+
Do what I say, or I will suffer
|
74
|
+
|
75
|
+
|
76
|
+
"""
|
data/lib/akkordarbeit.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
8
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
9
|
+
|
10
|
+
require 'akkordarbeit/parser'
|
11
|
+
require 'akkordarbeit/text_formatter'
|
12
|
+
require 'akkordarbeit/html_formatter'
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 J�rg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
module Akkordarbeit
|
10
|
+
class HtmlFormatter
|
11
|
+
def format(parsetree)
|
12
|
+
output = <<-'HERE'
|
13
|
+
<!DOCTYPE html>
|
14
|
+
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
|
15
|
+
<head>
|
16
|
+
<meta http-equiv='Content-type' content='text/html; charset=UTF-8' />
|
17
|
+
<title>Song-Sheet</title>
|
18
|
+
<meta http-equiv='content-language' content='en' />
|
19
|
+
<style>
|
20
|
+
p {
|
21
|
+
line-height: 300%;
|
22
|
+
max-width: 30em;
|
23
|
+
}
|
24
|
+
.chord {
|
25
|
+
position: relative;
|
26
|
+
}
|
27
|
+
.chord span {
|
28
|
+
position: absolute;
|
29
|
+
bottom: 40%;
|
30
|
+
font-size: 66%;
|
31
|
+
font-weight: bold;
|
32
|
+
}
|
33
|
+
.chord .brackets {
|
34
|
+
display: none;
|
35
|
+
}
|
36
|
+
</style>
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<header>
|
40
|
+
<h1>Song-Sheet</h1>
|
41
|
+
</header>
|
42
|
+
<section>
|
43
|
+
HERE
|
44
|
+
parsetree.each do |section|
|
45
|
+
output << "\t"*3 << "<p>\n"
|
46
|
+
section.each do |line|
|
47
|
+
output << "\t"*4
|
48
|
+
last_chord = nil
|
49
|
+
line.each do |token|
|
50
|
+
regex = /(?:\[(.*?)\])/
|
51
|
+
if regex.match(token)
|
52
|
+
last_chord = $1
|
53
|
+
else
|
54
|
+
unless last_chord
|
55
|
+
output << token
|
56
|
+
else
|
57
|
+
token = ' ' if token =~ /^\s$/
|
58
|
+
output << "<span class='chord'><span><span class='brackets'>[</span>#{last_chord}<span class='brackets'>]</span></span>#{token}</span>"
|
59
|
+
last_chord = nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
output << "<br />\n"
|
64
|
+
end
|
65
|
+
output << "\t"*3 << "</p>\n"
|
66
|
+
end
|
67
|
+
return output << <<-'HERE'
|
68
|
+
</section>
|
69
|
+
</body>
|
70
|
+
</html>
|
71
|
+
HERE
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
8
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
9
|
+
|
10
|
+
module Akkordarbeit
|
11
|
+
class Parser
|
12
|
+
def parse(songstr)
|
13
|
+
chordpattern = /(\[.*?\])/
|
14
|
+
seperatorpattern = /\n\n+/
|
15
|
+
song = []
|
16
|
+
songstr.split(seperatorpattern).each do |sectionstr|
|
17
|
+
section = []
|
18
|
+
sectionstr.each_line do |line|
|
19
|
+
section << line.chomp.split(chordpattern).reject { |str| str.empty? }
|
20
|
+
end
|
21
|
+
song << section
|
22
|
+
end
|
23
|
+
return song
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
5
|
+
|
6
|
+
libdir = File.expand_path(File.dirname __FILE__).gsub(/(.*lib).*?/, '\1')
|
7
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
8
|
+
|
9
|
+
module Akkordarbeit
|
10
|
+
class TextFormatter
|
11
|
+
def format(parsetree)
|
12
|
+
output = ''
|
13
|
+
parsetree.each do |section|
|
14
|
+
section.each do |line|
|
15
|
+
chords, lyrics = '', ''
|
16
|
+
line.each do |token|
|
17
|
+
regex = /(\[.*?\])/
|
18
|
+
if regex.match(token)
|
19
|
+
chords << token
|
20
|
+
else
|
21
|
+
lyrics << token
|
22
|
+
chords << " " * (lyrics.length - chords.length)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
output << chords.rstrip << "\n" << lyrics.rstrip << "\n"
|
26
|
+
end
|
27
|
+
output << "\n"
|
28
|
+
end
|
29
|
+
return output
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
require File.expand_path File.join(File.dirname(__FILE__), 'spec_helper')
|
8
|
+
|
9
|
+
require 'akkordarbeit'
|
10
|
+
|
11
|
+
describe Akkordarbeit do
|
12
|
+
it do
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
specdir = File.expand_path(File.dirname __FILE__).gsub(/(.*spec).*?/, '\1')
|
8
|
+
$LOAD_PATH.unshift specdir unless $LOAD_PATH.include? specdir
|
9
|
+
|
10
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
Dir[File.join specdir, '**', '*_spec.rb'].each { |spec| require spec }
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# vim: fileencoding=UTF-8 ft=ruby syn=ruby ts=2 sw=2 ai eol et si
|
2
|
+
|
3
|
+
# Copyright (c) 2009 Jörg W Mittag <mailto:JoergWMittag+Akkordarbeit@GoogleMail.Com>
|
4
|
+
# Copyright (c) 2009 Marc Rummel <mailto:Marc.Rummel+Akkordarbeit@GoogleMail.Com>
|
5
|
+
# This code is licensed under the terms of the MIT License (see LICENSE.rdoc)
|
6
|
+
|
7
|
+
require 'spec'
|
8
|
+
|
9
|
+
libdir = File.expand_path File.join(File.dirname(__FILE__), 'lib').gsub(/(.*)spec.*?/, '\1')
|
10
|
+
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include? libdir
|
11
|
+
|
12
|
+
specdir = File.expand_path(File.dirname __FILE__).gsub(/(.*spec).*?/, '\1')
|
13
|
+
$LOAD_PATH.unshift specdir unless $LOAD_PATH.include? specdir
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: JoergWMittag-akkordarbeit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "J\xC3\xB6rg W Mittag"
|
8
|
+
- Marc Rummel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-03-21 00:00:00 -07:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: tagz
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 5.0.1
|
25
|
+
version:
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: cucumber
|
28
|
+
type: :development
|
29
|
+
version_requirement:
|
30
|
+
version_requirements: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.2.2
|
35
|
+
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jscruggs-metric_fu
|
38
|
+
type: :development
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.9.0
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mislav-hanna
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.7
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ~>
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 1.2.2
|
65
|
+
version:
|
66
|
+
description: Akkordarbeit is a program for formatting simple leadsheets in a simplified ChordPro format to various other formats such as HTML or plaintext.
|
67
|
+
email: JoergWMittag+Akkordarbeit@GoogleMail.Com
|
68
|
+
executables:
|
69
|
+
- akkordarbeit
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files:
|
73
|
+
- LICENSE.rdoc
|
74
|
+
- README.rdoc
|
75
|
+
files:
|
76
|
+
- features/html_formatter.feature
|
77
|
+
- features/parser.feature
|
78
|
+
- features/text_formatter.feature
|
79
|
+
- features/step_definitions/akkordarbeit_steps.rb
|
80
|
+
- spec/akkordarbeit_spec.rb
|
81
|
+
- spec/akkordarbeit_suite.rb
|
82
|
+
- spec/spec_helper.rb
|
83
|
+
- LICENSE.rdoc
|
84
|
+
- README.rdoc
|
85
|
+
- bin/akkordarbeit
|
86
|
+
- lib/akkordarbeit.rb
|
87
|
+
- lib/akkordarbeit/html_formatter.rb
|
88
|
+
- lib/akkordarbeit/parser.rb
|
89
|
+
- lib/akkordarbeit/text_formatter.rb
|
90
|
+
has_rdoc: true
|
91
|
+
homepage: https://JoergWMittag.GitHub.Com/akkordarbeit/
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options:
|
94
|
+
- --all
|
95
|
+
- --charset=UTF-8
|
96
|
+
- --line-numbers
|
97
|
+
- --webcvs=https://GitHub.Com/JoergWMittag/Akkordarbeit/blob/master/%s
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ~>
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.8.6
|
105
|
+
version:
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: "0"
|
111
|
+
version:
|
112
|
+
requirements: []
|
113
|
+
|
114
|
+
rubyforge_project: Akkordarbeit
|
115
|
+
rubygems_version: 1.2.0
|
116
|
+
signing_key:
|
117
|
+
specification_version: 2
|
118
|
+
summary: Formats ChordPro leadsheets as HTML or plaintext
|
119
|
+
test_files:
|
120
|
+
- features/html_formatter.feature
|
121
|
+
- features/parser.feature
|
122
|
+
- features/text_formatter.feature
|
123
|
+
- features/step_definitions/akkordarbeit_steps.rb
|
124
|
+
- spec/akkordarbeit_spec.rb
|
125
|
+
- spec/akkordarbeit_suite.rb
|
126
|
+
- spec/spec_helper.rb
|