song_pro 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d13f7f76dd430f25293eab52b8ebb42c1a6ed45eb5a5dedbd117cb4b0206b80
4
- data.tar.gz: b13503808204e547d71b958d8ac7691bb040a3b1f3f7c8029e3dc9638753ca58
3
+ metadata.gz: a60d1b3170f1c93d6715aaf1e6ac32d4f7ea36279fd6337332e548f0d0b27ead
4
+ data.tar.gz: d6f071f7c7be13424e9861279ddae1cc5edf5f7264dfad1a2bbd9ee66cfcd542
5
5
  SHA512:
6
- metadata.gz: 234fdde6636efb454f57b9bd12c9a25a087aad982ca732e04114c2dbf9166b118bc39a69d2371064ffe88064bf0760157ee632f84aa8f2ff490f4d4f90e2baa7
7
- data.tar.gz: 31d1cafad5793a282bf37705794239d03a1eb8e4a0f7a273db153cef170ed29bf2acd685c6a7c93fcaa0860a8e5c98ee90277a04646066abc351d5e6a4adbe45
6
+ metadata.gz: 92826523e6724d3f5b94904302a0e2d037af838c6d0d0b5761de1b8a88241bccbd6c2a6be30b18c1eeca7b0e012119584204d7c33d72ffc79c574571ed8cddff
7
+ data.tar.gz: e63ddc6b96e8538d74b6158fa6ddfa9f7688d9a3b374f82beec5a6381cb8729e41437ee26ea68335114b235ea9d41ff44896435fe31062c2e0a5667b1f68e03f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.6.3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- song_pro (0.1.3)
4
+ song_pro (0.1.4)
5
5
  markaby
6
6
 
7
7
  GEM
data/lib/song_pro/line.rb CHANGED
@@ -2,15 +2,21 @@
2
2
 
3
3
  module SongPro
4
4
  class Line
5
- attr_accessor :parts, :tablature
5
+ attr_accessor :parts, :tablature, :measures
6
6
 
7
7
  def initialize
8
8
  @parts = []
9
9
  @tablature = nil
10
+ @measures = nil
10
11
  end
11
12
 
12
13
  def tablature?
13
14
  return @tablature != nil
14
15
  end
16
+
17
+ def measures?
18
+ return @measures != nil
19
+ end
20
+
15
21
  end
16
22
  end
@@ -0,0 +1,9 @@
1
+ module SongPro
2
+ class Measure
3
+ attr_accessor :chords
4
+
5
+ def initialize
6
+ @chords = []
7
+ end
8
+ end
9
+ end
data/lib/song_pro/song.rb CHANGED
@@ -66,6 +66,16 @@ module SongPro
66
66
  div.tablature do
67
67
  line.tablature
68
68
  end
69
+ elsif line.measures?
70
+ div.measures do
71
+ line.measures.each do |measure|
72
+ div.measure do
73
+ measure.chords.each do |chord|
74
+ div.chord chord
75
+ end
76
+ end
77
+ end
78
+ end
69
79
  else
70
80
  div.line do
71
81
  line.parts.each do |part|
@@ -1,3 +1,3 @@
1
1
  module SongPro
2
- VERSION = '0.1.3'.freeze
2
+ VERSION = '0.1.4'.freeze
3
3
  end
data/lib/song_pro.rb CHANGED
@@ -5,12 +5,15 @@ require 'song_pro/song'
5
5
  require 'song_pro/section'
6
6
  require 'song_pro/line'
7
7
  require 'song_pro/part'
8
+ require 'song_pro/measure'
8
9
 
9
10
  module SongPro
10
11
  SECTION_REGEX = /#\s*([^$]*)/
11
12
  ATTRIBUTE_REGEX = /@(\w*)=([^%]*)/
12
13
  CUSTOM_ATTRIBUTE_REGEX = /!(\w*)=([^%]*)/
13
- CHORDS_AND_LYRICS_REGEX = /(\[[\w#b\/]+\])?([\w\s',.!\(\)_\-"]*)/i
14
+ CHORDS_AND_LYRICS_REGEX = %r{(\[[\w#b\/]+\])?([\w\s',.!()_\-"]*)}i
15
+ MEASURES_REGEX = %r{([\[[\w#b\/]+\]\s]+)[|]*}i
16
+ CHORDS_REGEX = %r{\[([\w#b\/]+)\]?}i
14
17
 
15
18
  def self.parse(lines)
16
19
  song = Song.new
@@ -60,7 +63,6 @@ module SongPro
60
63
  song.set_custom(key, value)
61
64
  end
62
65
 
63
-
64
66
  def self.process_lyrics_and_chords(song, current_section, text)
65
67
  return if text == ''
66
68
 
@@ -71,16 +73,29 @@ module SongPro
71
73
 
72
74
  line = Line.new
73
75
 
74
- if text.start_with?('|')
76
+ if text.start_with?('|-')
75
77
  line.tablature = text
78
+ elsif text.start_with?('| ')
79
+ captures = text.scan(MEASURES_REGEX).flatten
80
+
81
+ measures = []
82
+
83
+ captures.each do |capture|
84
+ chords = capture.scan(CHORDS_REGEX).flatten
85
+ measure = Measure.new
86
+ measure.chords = chords
87
+ measures << measure
88
+ end
89
+
90
+ line.measures = measures
76
91
  else
77
92
  captures = text.scan(CHORDS_AND_LYRICS_REGEX).flatten
78
93
 
79
- captures.each_slice(2) do |pair|
80
- part = Part.new
81
- chord = pair[0]&.strip || ''
82
- part.chord = chord.delete('[').delete(']')
83
- part.lyric = pair[1]&.strip || ''
94
+ captures.each_slice(2) do |pair|
95
+ part = Part.new
96
+ chord = pair[0]&.strip || ''
97
+ part.chord = chord.delete('[').delete(']')
98
+ part.lyric = pair[1]&.strip || ''
84
99
 
85
100
  line.parts << part unless (part.chord == '') && (part.lyric == '')
86
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: song_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Kelly
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-08 00:00:00.000000000 Z
11
+ date: 2019-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: markaby
@@ -100,6 +100,7 @@ files:
100
100
  - bin/setup
101
101
  - lib/song_pro.rb
102
102
  - lib/song_pro/line.rb
103
+ - lib/song_pro/measure.rb
103
104
  - lib/song_pro/part.rb
104
105
  - lib/song_pro/section.rb
105
106
  - lib/song_pro/song.rb
@@ -125,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
126
  - !ruby/object:Gem::Version
126
127
  version: '0'
127
128
  requirements: []
128
- rubygems_version: 3.0.1
129
+ rubygems_version: 3.0.3
129
130
  signing_key:
130
131
  specification_version: 4
131
132
  summary: Converts SongPro files to HTML