Skip to content

Instantly share code, notes, and snippets.

@adrianvalenz
Created February 24, 2023 19:22
Show Gist options
  • Save adrianvalenz/911600ac1dbc673a69fdcb74665e2a15 to your computer and use it in GitHub Desktop.
Save adrianvalenz/911600ac1dbc673a69fdcb74665e2a15 to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
require 'pry'
a = [
# "1\nJubil[A]ee, jubilee,\nJubilee, jubilee,\nPraise God for the jubi[E]lee!\nWords of grace, words of grace,\nWords of grace, words of grace!\nTime ac[E7]cept'ble, the year of jubil[A]ee.\nLost possession recovered,\n[A7]From all bondage set f[D]ree,\n[E]In God's house reu[A]nited—\nOur [D]Lord proclaims the j[E7]ubil[A]ee!\n\n2\nFather's house, Father's house,\nFather's house, Father's house,\nReturned to the Father's house,\nGod did run, God did run,\nGod did run, God did run,\nFell on our neck and kissed us tenderly.\nIn Christ clothed and accepted,\nNo more “pigs” food for me!\nFattened calf now enjoying—\nOur God proclaims the jubilee!\n\n3\nJubilee, jubilee,\nJubilee, jubilee,\nGospel of the jubilee!\nVessels we, vessels we,\nVessels we, vessels we,\nChosen vessels, receiving His mercy.\nPoor, blind, empty, no longer,\nGlorious riches have we!\nTo all th' poor and afflicted—\nWe now proclaim the jubilee!",
# Psa. 126:1-6\n\n1\nWhen the [D]Lord turned a[G]gain the cap[D]tivity\nof [G-D]Zion,\nWe were l[G]ike them that [D]dream,\nWe were l[G]ike them that [D]dream.\n\n2\nThen was our [D]mouth filled with [G]laughter,\nAnd our t[D]ongues with [G-D]singing:\nThen [G]said they among the [D]nations,\nThe [G]Lord hath done great [D]things,\nThe [G]Lord hath done great [D]things for them,\n\n The [G]Lord[Em] hath done great [D]things for us;\n Whereo[Em-G]f we are [A]glad.\n The [G]Lord[Em] hath done great [D]things for us;\n Whereo[Em-G]f we are [A]glad.\n\n3\nTurn again our captivity,\nO Lord, as the streams,\nAs the streams in the south,\nAs the streams in the south.\n\n4\nThey that sow in tears shall reap in joy,\nThey that sow in tears shall reap in joy.\n\n5\nHe that goeth forth and weepeth,\nBearing precious seed, shall doubtless,\nCome again with rejoicing,\nCome again with rejoicing,\nBringing his sheaves with him.\n\n The Lord hath done great things for us;\n Whereof we are glad.\n The Lord hath done great things for us;\n Whereof we are glad.\n\n6\nWhen the Lord turned again the captivity\nof Zion,\nWe were like them that dream,\nWe were like them that dream.",
"\n1\nThe day ap[C]proaches; Jesus soon is [F]coming[G].\nRedeem the [C]time; it [Dm]must not slip a[G]way. [G7]\nLord, make us [C]ready for the cry:\n“Be[Am]hold Him!”[F]\nBy using e[C]very mo[Dm]ment of each [G]day.\n\n When Jesus [Am]comes,\n Will [F]we go in to [G]meet Him?\n When Jesus [Am]comes,\n Will [F]we from self have [C]ceased[G]?\n He’s coming [Am]soon\n To [F]take the wise ones [C]with Him. [Am]\n Oh, let us [C]not be l[Dm]eft outs[G]ide the [C]feast.[F C]\n\n2\nLord, help us to redeem these\nGolden moments;\nOur vessels fill with ointment from above;\nHelp us amen each trial and tribulation;\nIncrease in us; make us abound in love.\n\n He’s coming soon—\n These moments are so precious.\n The oil is here—\n Oh, let us buy the more.\n Amen the trials\n And welcome tribulations—\n The kingdom’s ours\n Through these afflictions sore.\n\n3\nLord, ever turn us from our\nSoulish pleasures\nTo gaze upon Thy tender, loving face.\nOh, keep us running forth\nTo meet the Bridegroom\nAnd patiently attending to the race.\n\n When Jesus comes,\n Will we be in His presence?\n When Jesus comes,\n Will we His face behold?\n Oh, let us not return to sloth and folly,\n But jealously His loving presence hold.\n\n4\nAs His dear Bride,\nLet us go forth to meet Him,\nOur lamps well-trimmed,\nOur fires burning bright,\nOur vessels filled, our eyes set on His glory,\nTo be with Him completely satisfied.\n\n Yes, satisfied—\n Christ and His Bride together,\n Yes, satisfied—throughout eternity.\n Oh, what a rest, what joy,\n What love, what favor\n To be His Bride\n When He comes to His feast!",
]
a.each do |song|
verse_chords = []
song.split("\n\n").each do |verse|
chorded_lines = []
verse.split("\n").each_with_index do |line, i|
tmp_line = line.dup
hash = {}
chords = line.scan(/\[([^\]]+)\]/)
if !chords.empty?
chords.each do |chord|
ch = chord.first
hash.compare_by_identity
hash[ch] = tmp_line.index("[#{chord.first}")
tmp_line.sub!("[#{chord.first}]", "")
end
verse_chords.push(hash)
elsif line.to_i.zero? && line[0] != "#"
verse_chords[i - 1]&.each do |key, value|
safe_check = line[value..value + 2]
if !safe_check.nil? && safe_check.include?("[")
if line.length < value + 3
line.insert(line.length, "[#{key}]")
else
line.insert(value + 3, "[#{key}]")
end
elsif !safe_check.nil? && safe_check.include?("]")
line.insert(value + 2, "[#{key}]")
else
binding.pry
line.insert(value, "[#{key}]")
end
end
# take away verse number
end
chorded_lines << line
end
parsed_lyrics = chorded_lines.join("\n")
puts parsed_lyrics
end
puts "----------------------------"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment