class RSGuitarTech::UnpackedPSARC
Attributes
opts[RW]
psarc[RW]
tmpdir[RW]
Public Class Methods
from_psarc(psarc, opts) { |self| ... }
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 4 def self.from_psarc(psarc, opts) raise ArgumentError, "A block is required" unless block_given? raise ArgumentError, "#{psarc} not found!" unless File.exist?(psarc) puts "Unpacking psarc to temporary location..." # Use pyrocksmith to unpack the file, and check that it worked.. CommandRunner.run! ["pyrocksmith", "--unpack", psarc, "--no-crypto"] expected_extraction = File.basename psarc, ".*" raise ArgumentError unless File.exist?(expected_extraction + "/appid.appid") # Move it to a tmpdir, and yield Dir.mktmpdir do |dir| FileUtils.mv expected_extraction, dir yield self.new(psarc, dir, opts) end end
new(psarc, tmpdir, opts)
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 23 def initialize(psarc, tmpdir, opts) @psarc = psarc @tmpdir = tmpdir @opts = opts end
Public Instance Methods
audio_track(track: :main)
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 51 def audio_track(track: :main) audio_tracks[track] end
expected_extraction()
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 35 def expected_extraction File.basename psarc, ".*" end
manifest(type)
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 39 def manifest(type) Dir.glob("#{tmpdir}/#{expected_extraction}/manifests/*/*.json").detect { |filename| filename.include? type.to_s } end
ogg_track()
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 55 def ogg_track audio_tracks[:main].gsub ".wem", ".ogg" end
repack!()
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 29 def repack! puts "Repacking altered psarc..." CommandRunner.run! ["pyrocksmith", "--no-crypto", "--pack", "#{tmpdir}/#{expected_extraction}"] puts "Done! ✅" end
sng_bin(type)
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 43 def sng_bin(type) Dir.glob("#{tmpdir}/#{expected_extraction}/songs/bin/macos/*.sng").detect { |filename| filename.include? type.to_s } end
sng_xml()
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 47 def sng_xml Dir.glob("#{tmpdir}/#{expected_extraction}/songs/bin/macos/*.xml").first end
Private Instance Methods
audio_tracks()
click to toggle source
# File lib/rsgt/unpacked_psarc.rb, line 61 def audio_tracks @audio_tracks ||= begin both_wems = Dir.glob("#{tmpdir}/#{expected_extraction}/audio/mac/*.wem").sort_by { |wem| File.stat(wem).size } { main: both_wems.last, preview: both_wems.first } end end