chords 0.3 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,7 +49,7 @@ module Chords
49
49
  @tuning = Chords::Fretboard::TUNINGS[t.to_sym]
50
50
  end
51
51
 
52
- @opts.on("--pdf", "Output to pdf. Requires Prawn") do
52
+ @opts.on("--pdf", "Output to pdf. Requires Prawn.") do
53
53
  begin
54
54
  require 'chords/pdf_formatter'
55
55
  rescue LoadError => e
@@ -59,7 +59,7 @@ module Chords
59
59
  @formatter = Chords::PDFFormatter
60
60
  end
61
61
 
62
- @opts.on("--html", "Output to html. Requires RMagick") do
62
+ @opts.on("--html", "Output to html. Requires RMagick.") do
63
63
  begin
64
64
  require 'chords/html_formatter'
65
65
  rescue LoadError => e
@@ -25,11 +25,14 @@ module Chords
25
25
  html += get_element(fingering)
26
26
  end
27
27
 
28
- File.open('chords.html', 'w') do |file|
29
- file.write html
28
+ if opts[:inline]
29
+ html
30
+ else
31
+ File.open('chords.html', 'w') do |file|
32
+ file.write html
33
+ end
34
+ puts "Wrote chords.html"
30
35
  end
31
-
32
- puts "Wrote chords.html"
33
36
  end
34
37
 
35
38
  private
@@ -25,8 +25,12 @@ module Chords
25
25
  end
26
26
  end
27
27
 
28
- @pdf.render_file('chords.pdf')
29
- puts "Wrote chords.pdf"
28
+ if opts[:inline]
29
+ @pdf.render
30
+ else
31
+ @pdf.render_file('chords.pdf')
32
+ puts "Wrote chords.pdf"
33
+ end
30
34
  end
31
35
 
32
36
  private
@@ -17,16 +17,24 @@ module Chords
17
17
  end
18
18
 
19
19
  idx = 0
20
+ output = ''
21
+
20
22
  while rows.first.length > idx
21
23
  parts = []
22
24
  rows.each_with_index do |row, i|
23
25
  parts << "#{@fretboard.open_notes[i].title.rjust(2, ' ')}: " + row[idx...(idx+75)]
24
26
  end
25
- puts "\n" + (parts.reverse.join("\n")) + "\n\n"
27
+ output += "\n" + (parts.reverse.join("\n")) + "\n\n"
26
28
  idx += 75
27
29
  end
28
30
 
29
- puts "Total #{fingerings.size} fingerings."
31
+ output += "Total #{fingerings.size} fingerings."
32
+
33
+ if opts[:inline]
34
+ output
35
+ else
36
+ puts output
37
+ end
30
38
  end
31
39
 
32
40
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chords
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- version: "0.3"
9
+ - 1
10
+ version: 0.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Antti Hakala