songbook 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d20c26b15096f5863840b96174b942278f09216778a856ada04c973565cf4eb9
4
- data.tar.gz: 647f3ab59bb714ab5c0441a61b8f5d932968db85793e8973613830d0a88988ae
3
+ metadata.gz: 55dc94f2eba30f9815fec093a92a043d522e924cfaae0ec2fac0f16e558b3ee7
4
+ data.tar.gz: e146bd742a98b4e9082cf0df6d1cccd57304ac81c25e70bd4f91ef4012bb1655
5
5
  SHA512:
6
- metadata.gz: 9274349be564d80f1ba11e0b2045fd2887d1dc04b5970b72c63a1bed682074d864514f575aa40fd2d60501ecaae719b670ed065b570723f6e67d1e96163e21db
7
- data.tar.gz: d1bf5d257e46b6e836204855ebf19a5776ae9ee3dea83dd143417f747ca3c62089b10bb91c4dc1729beaa091028014d0681e8c7756605fca6f323af8ef0555a9
6
+ metadata.gz: 3b371581b64be50d59778b85e91020418502b8243565941be4575253aae6c476cb2f291d1d8c23110e54bec2746d4236312eccc5bb76fc3e3982f8debf3be080
7
+ data.tar.gz: c7647e32a215b89e4ee1965c7ccd413d0f4e26c58f370f68478cb4fbd543d29349daba8b11fa35d6923702108da8975ba8c42e472172e32f5ced4b261432f300
@@ -27,11 +27,14 @@ module Songbook
27
27
  end
28
28
 
29
29
  def song
30
+ table_width = song_data['config']['table_width'] if song_data['config']
31
+
30
32
  @song ||= Song.new(
31
33
  title: File.basename(input_path, '.yml'),
32
34
  details: song_data['details'],
33
35
  chords: song_data['chords'],
34
- lyrics: song_data['lyrics']
36
+ lyrics: song_data['lyrics'],
37
+ table_width: table_width
35
38
  )
36
39
  end
37
40
 
@@ -5,7 +5,6 @@ require 'tty-table'
5
5
  module Songbook
6
6
  class RenderSong
7
7
  SEPARATOR = [nil, nil].freeze
8
- TABLE_WIDTH = 80
9
8
  LYRICS_CHORDS_SEPARATOR = ' '
10
9
 
11
10
  attr_reader :song
@@ -33,7 +32,7 @@ module Songbook
33
32
  t << ["[#{verse.title}]", nil]
34
33
 
35
34
  verse.lines.each do |line|
36
- t << [line.lyrics, line.chords]
35
+ t << [line.chords, line.lyrics]
37
36
  end
38
37
 
39
38
  t << SEPARATOR
@@ -49,12 +48,12 @@ module Songbook
49
48
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
50
49
 
51
50
  def table_settings
52
- { column_widths: [lyrics_column_width, nil], multiline: true }
51
+ { column_widths: [chords_column_width, lyrics_column_width], multiline: true }
53
52
  end
54
53
 
55
54
  def lyrics_column_width
56
55
  [
57
- TABLE_WIDTH - chords_column_width - LYRICS_CHORDS_SEPARATOR.length,
56
+ song.table_width - chords_column_width - LYRICS_CHORDS_SEPARATOR.length,
58
57
  max_lyrics_column_width
59
58
  ].min
60
59
  end
data/lib/songbook/song.rb CHANGED
@@ -4,13 +4,16 @@ require_relative 'verse'
4
4
 
5
5
  module Songbook
6
6
  class Song
7
- attr_reader :title, :details, :chords, :lyrics
7
+ TABLE_WIDTH = 80
8
8
 
9
- def initialize(title:, details:, chords:, lyrics:)
9
+ attr_reader :title, :details, :chords, :lyrics, :table_width
10
+
11
+ def initialize(title:, details:, chords:, lyrics:, table_width: nil)
10
12
  @title = title
11
13
  @details = details
12
14
  @chords = chords
13
15
  @lyrics = lyrics
16
+ @table_width = table_width || TABLE_WIDTH
14
17
  end
15
18
 
16
19
  def verses
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Songbook
4
- VERSION = '0.3.1'
4
+ VERSION = '0.5.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: songbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - George Mendoza
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-table
@@ -135,7 +135,7 @@ licenses:
135
135
  - MIT
136
136
  metadata:
137
137
  allowed_push_host: https://rubygems.org
138
- post_install_message:
138
+ post_install_message:
139
139
  rdoc_options: []
140
140
  require_paths:
141
141
  - lib
@@ -150,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubygems_version: 3.1.2
154
- signing_key:
153
+ rubygems_version: 3.3.22
154
+ signing_key:
155
155
  specification_version: 4
156
156
  summary: Songbook
157
157
  test_files: []