song_pro 0.1.10 → 0.1.12

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: 3d51559bf23b8581a8dcba60800e39aab562439dc6e46ddce858feb46a4b86be
4
- data.tar.gz: 496d9b028ace33732b0a420b271feaa2cdf274f06e725fc5747968cd033ea325
3
+ metadata.gz: c06c0b9f50bce6995726f812e4472defeb00cb4b37af5e5498b043fa1c9ed8a1
4
+ data.tar.gz: 955eec40e9481a7de7e4b0a46369f7e8c717e1919d653ec8aeb2b90d3eed1db2
5
5
  SHA512:
6
- metadata.gz: 89ba491f7a8468cbe8746539b682461d00542d52bb17f6b68c622381c0e2399ed57b2714faa78e8496c24244bf5f623e867c51264f4a042c2f836e9162f29ca9
7
- data.tar.gz: 36b35726800500b43630430e0b17a0cbe93a8657936eef2b8ebc19878887b9d280b8647f520efbfa8afe79b47055da6c95144cbb4faa1851b2a06f58db04ebed
6
+ metadata.gz: 28b10e4bc6531745b33dd01b5cb59c48210e8bc1ba635e333232bf4ea5b89fb537c9b8ecc18e02509be429841dd4e8adcb66ccd85966e1e798264afe807b0b2e
7
+ data.tar.gz: 217c7f14d9b13d34b066886ae9f14d1ff0a92d5ccfe3fd699e0e63ce448586572a92da8ca2fc00f8446829cce7f01511c8f9e3bdb4166c220c6c3aadbcaf9e12
@@ -2,20 +2,24 @@ name: Build
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ master ]
5
+ branches: [ main ]
6
6
  pull_request:
7
- branches: [ master ]
7
+ branches: [ main ]
8
8
 
9
9
  jobs:
10
10
  test:
11
11
  runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [3.0, 3.1, 3.2, 3.3]
16
+
12
17
  steps:
13
- - uses: actions/checkout@v2
14
- - name: Set up Ruby
18
+ - uses: actions/checkout@v4
19
+ - name: Set up Ruby ${{ matrix.ruby-version }}
15
20
  uses: ruby/setup-ruby@v1
16
21
  with:
17
- ruby-version: 2.7
18
- - name: Install dependencies
19
- run: bundle install
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true
20
24
  - name: Run tests
21
25
  run: bundle exec rake
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.3
1
+ 3.3.3
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.3.3
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
6
 
data/Gemfile.lock CHANGED
@@ -1,39 +1,82 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- song_pro (0.1.9)
5
- markaby
4
+ song_pro (0.1.12)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  specs:
10
- builder (3.2.4)
11
- diff-lcs (1.4.4)
12
- markaby (0.9.0)
13
- builder
14
- rake (13.0.3)
15
- rspec (3.10.0)
16
- rspec-core (~> 3.10.0)
17
- rspec-expectations (~> 3.10.0)
18
- rspec-mocks (~> 3.10.0)
19
- rspec-core (3.10.1)
20
- rspec-support (~> 3.10.0)
21
- rspec-expectations (3.10.1)
9
+ ast (2.4.2)
10
+ diff-lcs (1.5.1)
11
+ json (2.7.2)
12
+ language_server-protocol (3.17.0.3)
13
+ lint_roller (1.1.0)
14
+ parallel (1.25.1)
15
+ parser (3.3.3.0)
16
+ ast (~> 2.4.1)
17
+ racc
18
+ racc (1.8.0)
19
+ rainbow (3.1.1)
20
+ rake (13.2.1)
21
+ regexp_parser (2.9.2)
22
+ rexml (3.3.3)
23
+ strscan
24
+ rspec (3.13.0)
25
+ rspec-core (~> 3.13.0)
26
+ rspec-expectations (~> 3.13.0)
27
+ rspec-mocks (~> 3.13.0)
28
+ rspec-core (3.13.0)
29
+ rspec-support (~> 3.13.0)
30
+ rspec-expectations (3.13.1)
22
31
  diff-lcs (>= 1.2.0, < 2.0)
23
- rspec-support (~> 3.10.0)
24
- rspec-mocks (3.10.2)
32
+ rspec-support (~> 3.13.0)
33
+ rspec-mocks (3.13.1)
25
34
  diff-lcs (>= 1.2.0, < 2.0)
26
- rspec-support (~> 3.10.0)
27
- rspec-support (3.10.2)
35
+ rspec-support (~> 3.13.0)
36
+ rspec-support (3.13.1)
37
+ rubocop (1.64.1)
38
+ json (~> 2.3)
39
+ language_server-protocol (>= 3.17.0)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.3.0.2)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.31.1, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 2.4.0, < 3.0)
48
+ rubocop-ast (1.31.3)
49
+ parser (>= 3.3.1.0)
50
+ rubocop-performance (1.21.0)
51
+ rubocop (>= 1.48.1, < 2.0)
52
+ rubocop-ast (>= 1.31.1, < 2.0)
53
+ ruby-progressbar (1.13.0)
54
+ standard (1.37.0)
55
+ language_server-protocol (~> 3.17.0.2)
56
+ lint_roller (~> 1.0)
57
+ rubocop (~> 1.64.0)
58
+ standard-custom (~> 1.0.0)
59
+ standard-performance (~> 1.4)
60
+ standard-custom (1.0.2)
61
+ lint_roller (~> 1.0)
62
+ rubocop (~> 1.50)
63
+ standard-performance (1.4.0)
64
+ lint_roller (~> 1.1)
65
+ rubocop-performance (~> 1.21.0)
66
+ standardrb (1.0.1)
67
+ standard
68
+ strscan (3.1.0)
69
+ unicode-display_width (2.5.0)
28
70
 
29
71
  PLATFORMS
30
72
  ruby
31
73
 
32
74
  DEPENDENCIES
33
- bundler (>= 2.2.19)
34
- rake (~> 13.0)
35
- rspec (~> 3.8)
75
+ bundler
76
+ rake
77
+ rspec
36
78
  song_pro!
79
+ standardrb
37
80
 
38
81
  BUNDLED WITH
39
- 2.2.21
82
+ 2.4.16
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # SongPro for Ruby ![Build](https://github.com/SongProOrg/songpro-ruby/workflows/Build/badge.svg?branch=master)
1
+ # SongPro for Ruby ![Build](https://github.com/SongProOrg/songpro-ruby/workflows/Build/badge.svg?branch=main)
2
2
 
3
3
  [SongPro](https://songpro.org) is a text format for transcribing songs.
4
4
 
@@ -60,8 +60,11 @@ puts song.title
60
60
  puts song.artist
61
61
  # Brian Kelly
62
62
 
63
- puts song.sections[1].title
63
+ puts song.sections[1].name
64
64
  # Chorus 1
65
+
66
+ p song.chords
67
+ # ["D", "A", "Bm", "F#m", "G", "Asus4", "A7", "F#"]
65
68
  ```
66
69
 
67
70
  ## Development
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "standard/rake"
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
8
- task default: :spec
9
+ task default: [:spec, :standard]
data/lib/song_pro/part.rb CHANGED
@@ -4,4 +4,4 @@ module SongPro
4
4
  class Part
5
5
  attr_accessor :lyric, :chord
6
6
  end
7
- end
7
+ end
@@ -4,9 +4,9 @@ module SongPro
4
4
  class Section
5
5
  attr_accessor :name, :lines
6
6
 
7
- def initialize(name: '')
7
+ def initialize(name: "")
8
8
  @name = name
9
9
  @lines = []
10
10
  end
11
11
  end
12
- end
12
+ end
data/lib/song_pro/song.rb CHANGED
@@ -1,19 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'markaby'
4
-
5
3
  module SongPro
6
4
  class Song
7
5
  attr_accessor :title,
8
- :artist,
9
- :capo,
10
- :key,
11
- :tempo,
12
- :year,
13
- :album,
14
- :tuning,
15
- :sections,
16
- :custom
6
+ :artist,
7
+ :capo,
8
+ :key,
9
+ :tempo,
10
+ :year,
11
+ :album,
12
+ :tuning,
13
+ :sections,
14
+ :custom
17
15
 
18
16
  def initialize
19
17
  @sections = []
@@ -35,76 +33,5 @@ module SongPro
35
33
  end
36
34
  end.flatten.uniq.reject(&:empty?)
37
35
  end
38
-
39
- def to_html
40
- mab = Markaby::Builder.new(song: self)
41
- mab.div.song do
42
- h1.title song.title if song.title
43
- h2.artist song.artist if song.artist
44
-
45
- dl.information do
46
- if song.tuning
47
- dt.tuning 'Tuning'
48
- dd.tuning song.tuning
49
- end
50
- if song.capo
51
- dt.capo 'Capo'
52
- dd.capo song.capo
53
- end
54
- if song.key
55
- dt.key 'Key'
56
- dd.key song.key
57
- end
58
- if song.tempo
59
- dt.tempo 'Tempo'
60
- dd.tempo song.tempo
61
- end
62
- if song.year
63
- dt.year 'Year'
64
- dd.year song.year
65
- end
66
- if song.album
67
- dt.album 'Album'
68
- dd.album song.album
69
- end
70
- end
71
-
72
- song.sections.each do |section|
73
- div.section do
74
- div.name section.name
75
- div.lines do
76
- section.lines.each do |line|
77
- if line.tablature?
78
- div.tablature do
79
- line.tablature
80
- end
81
- elsif line.measures?
82
- div.measures do
83
- line.measures.each do |measure|
84
- div.measure do
85
- measure.chords.each do |chord|
86
- div.chord chord
87
- end
88
- end
89
- end
90
- end
91
- else
92
- div.line do
93
- line.parts.each do |part|
94
- div.part do
95
- div.chord part.chord
96
- div.lyric part.lyric
97
- end
98
- end
99
- end
100
- end
101
- end
102
- end
103
- end
104
- end
105
- end
106
-
107
- mab.to_s
108
- end
109
36
  end
110
37
  end
@@ -1,3 +1,3 @@
1
1
  module SongPro
2
- VERSION = '0.1.10'.freeze
2
+ VERSION = "0.1.12".freeze
3
3
  end
data/lib/song_pro.rb CHANGED
@@ -1,32 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'song_pro/version'
4
- require 'song_pro/song'
5
- require 'song_pro/section'
6
- require 'song_pro/line'
7
- require 'song_pro/part'
8
- require 'song_pro/measure'
3
+ require "song_pro/version"
4
+ require "song_pro/song"
5
+ require "song_pro/section"
6
+ require "song_pro/line"
7
+ require "song_pro/part"
8
+ require "song_pro/measure"
9
9
 
10
10
  module SongPro
11
11
  SECTION_REGEX = /#\s*([^$]*)/
12
12
  ATTRIBUTE_REGEX = /@(\w*)=([^%]*)/
13
13
  CUSTOM_ATTRIBUTE_REGEX = /!(\w*)=([^%]*)/
14
- CHORDS_AND_LYRICS_REGEX = %r{(\[[\w#b+\/]+\])?([^\[]*)}i
14
+ CHORDS_AND_LYRICS_REGEX = %r{(\[[\w#b+/]+\])?([^\[]*)}i
15
15
 
16
- MEASURES_REGEX = %r{([\[[\w#b\/]+\]\s]+)[|]*}i
17
- CHORDS_REGEX = %r{\[([\w#b+\/]+)\]?}i
16
+ MEASURES_REGEX = %r{([\[[\w#b/]+\]\s]+)[|]*}i
17
+ CHORDS_REGEX = %r{\[([\w#b+/]+)\]?}i
18
18
  COMMENT_REGEX = />\s*([^$]*)/
19
+ TABLATURE_REGEX = /^\s?[a-zA-Z]?#?b?\|-/
19
20
 
20
21
  def self.parse(lines)
21
22
  song = Song.new
22
23
  current_section = nil
23
24
 
24
25
  lines.split("\n").each do |text|
25
- if text.start_with?('@')
26
+ if text.start_with?("@")
26
27
  process_attribute(song, text)
27
- elsif text.start_with?('!')
28
+ elsif text.start_with?("!")
28
29
  process_custom_attribute(song, text)
29
- elsif text.start_with?('#')
30
+ elsif text.start_with?("#")
30
31
  current_section = process_section(song, text)
31
32
  else
32
33
  process_lyrics_and_chords(song, current_section, text)
@@ -50,8 +51,8 @@ module SongPro
50
51
  key = matches[1]
51
52
  value = matches[2].strip
52
53
 
53
- if song.respond_to?("#{key}=".to_sym)
54
- song.send("#{key}=", value)
54
+ if song.respond_to?(:"#{key}=")
55
+ song.send(:"#{key}=", value)
55
56
  else
56
57
  puts "WARNING: Unknown attribute '#{key}'"
57
58
  end
@@ -66,18 +67,18 @@ module SongPro
66
67
  end
67
68
 
68
69
  def self.process_lyrics_and_chords(song, current_section, text)
69
- return if text == ''
70
+ return if text == ""
70
71
 
71
72
  if current_section.nil?
72
- current_section = Section.new(name: '')
73
+ current_section = Section.new(name: "")
73
74
  song.sections << current_section
74
75
  end
75
76
 
76
77
  line = Line.new
77
78
 
78
- if text.start_with?('|-')
79
+ if text.match(TABLATURE_REGEX)
79
80
  line.tablature = text
80
- elsif text.start_with?('| ')
81
+ elsif text.start_with?("| ")
81
82
  captures = text.scan(MEASURES_REGEX).flatten
82
83
 
83
84
  measures = []
@@ -90,7 +91,7 @@ module SongPro
90
91
  end
91
92
 
92
93
  line.measures = measures
93
- elsif text.start_with?('>')
94
+ elsif text.start_with?(">")
94
95
  matches = COMMENT_REGEX.match(text)
95
96
  comment = matches[1].strip
96
97
  line.comment = comment
@@ -99,11 +100,11 @@ module SongPro
99
100
 
100
101
  captures.each_slice(2) do |pair|
101
102
  part = Part.new
102
- chord = pair[0]&.strip || ''
103
- part.chord = chord.delete('[').delete(']')
104
- part.lyric = pair[1] || ''
103
+ chord = pair[0]&.strip || ""
104
+ part.chord = chord.delete("[").delete("]")
105
+ part.lyric = pair[1] || ""
105
106
 
106
- line.parts << part unless (part.chord == '') && (part.lyric == '')
107
+ line.parts << part unless (part.chord == "") && (part.lyric == "")
107
108
  end
108
109
  end
109
110
 
data/song_pro.gemspec CHANGED
@@ -1,34 +1,34 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'song_pro/version'
5
+ require "song_pro/version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'song_pro'
9
- spec.version = SongPro::VERSION
10
- spec.authors = ['Brian Kelly']
11
- spec.email = ['polymonic@gmail.com']
8
+ spec.name = "song_pro"
9
+ spec.version = SongPro::VERSION
10
+ spec.authors = ["Brian Kelly"]
11
+ spec.email = ["polymonic@gmail.com"]
12
12
 
13
- spec.summary = 'Converts SongPro files to HTML'
14
- spec.description = 'Provides classes for creating, parsing and rendering SongPro files'
15
- spec.homepage = 'https://songpro.org'
16
- spec.license = 'MIT'
13
+ spec.summary = "Converts SongPro files to HTML"
14
+ spec.description = "Provides classes for creating, parsing and rendering SongPro files"
15
+ spec.homepage = "https://songpro.org"
16
+ spec.license = "MIT"
17
17
 
18
18
  if spec.respond_to?(:metadata)
19
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
20
  else
21
- raise 'RubyGems 2.0 or newer is required to protect against ' \
22
- 'public gem pushes.'
21
+ raise "RubyGems 2.0 or newer is required to protect against " \
22
+ "public gem pushes."
23
23
  end
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
26
  f.match(%r{^(test|spec|features)/})
27
27
  end
28
- spec.require_paths = ['lib']
28
+ spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency 'markaby'
31
- spec.add_development_dependency "bundler", ">= 2.2.19"
32
- spec.add_development_dependency 'rake', '~> 13.0'
33
- spec.add_development_dependency 'rspec', '~> 3.8'
30
+ spec.add_development_dependency "bundler"
31
+ spec.add_development_dependency "rake"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "standardrb"
34
34
  end
metadata CHANGED
@@ -1,23 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: song_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Kelly
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-04 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: markaby
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
- type: :runtime
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
@@ -25,47 +25,47 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.19
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.2.19
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '13.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '13.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: standardrb
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.8'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.8'
68
+ version: '0'
69
69
  description: Provides classes for creating, parsing and rendering SongPro files
70
70
  email:
71
71
  - polymonic@gmail.com
@@ -77,7 +77,7 @@ files:
77
77
  - ".gitignore"
78
78
  - ".rspec"
79
79
  - ".ruby-version"
80
- - ".travis.yml"
80
+ - ".tool-versions"
81
81
  - Gemfile
82
82
  - Gemfile.lock
83
83
  - LICENSE.txt
@@ -98,7 +98,7 @@ licenses:
98
98
  - MIT
99
99
  metadata:
100
100
  allowed_push_host: https://rubygems.org
101
- post_install_message:
101
+ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.1.6
117
- signing_key:
116
+ rubygems_version: 3.5.15
117
+ signing_key:
118
118
  specification_version: 4
119
119
  summary: Converts SongPro files to HTML
120
120
  test_files: []
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.7.3
7
- before_install: gem install bundler -v 2.2