Class: RSGuitarTech::Multipacker

Inherits:
Object
  • Object
show all
Defined in:
lib/rsgt/multipacker.rb,
lib/rsgt/multipacker/config_processor.rb

Defined Under Namespace

Classes: ConfigProcessor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, directory:, unpack_dir:, repack_dir:, dest_dir:, filters: {}, options: {}) ⇒ Multipacker

Returns a new instance of Multipacker.



10
11
12
13
14
15
16
17
18
19
# File 'lib/rsgt/multipacker.rb', line 10

def initialize(title:, directory:, unpack_dir:, repack_dir:, dest_dir:, filters: {}, options: {})
  @title      = title
  @directory  = directory
  @unpack_dir = unpack_dir
  @repack_dir = repack_dir
  @dest_dir   = dest_dir
  @filters    = filters
  @options    = options
  @count      = {psarcs: 0, skipped: 0, failed: 0, total: 0}
end

Class Method Details

.process!(*args) ⇒ Object



4
5
6
# File 'lib/rsgt/multipacker.rb', line 4

def self.process!(*args)
  self.new(*args).process!
end

Instance Method Details

#ensure_dir!(dir) ⇒ Object



39
40
41
# File 'lib/rsgt/multipacker.rb', line 39

def ensure_dir!(dir)
  shell_out "mkdir -p #{dir}/"
end

#move!Object



58
59
60
61
62
# File 'lib/rsgt/multipacker.rb', line 58

def move!
  packed_psarc = repack_dir.split("/").last + ".psarc"
  puts "Moving packed psarc (#{packed_psarc}) to: #{title} - #{count[:total]} songs _m.psarc"
  shell_out "mv #{packed_psarc} #{dest_dir}/#{title}\\ \\-\\ #{count[:total]}\\ songs\\ \\_m.psarc"
end

#process!Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rsgt/multipacker.rb', line 21

def process!
  reset! unpack_dir if options[:reset_unpack]
  reset! repack_dir if options[:reset_repack]
  ensure_dir! unpack_dir
  ensure_dir! repack_dir
  unpack!
  if count[:skipped] >= count[:total]
    puts "All done! No new files found to repack"
    return
  end
  repack!
  move!
end

#repack!Object



53
54
55
56
# File 'lib/rsgt/multipacker.rb', line 53

def repack!
  puts "Packing #{count[:total]} songs into #{repack_dir}.psarc"
  shell_out %Q{pyrocksmith --no-crypto --pack "#{repack_dir}"}
end

#reset!(dir) ⇒ Object



35
36
37
# File 'lib/rsgt/multipacker.rb', line 35

def reset!(dir)
  shell_out "rm -rf #{dir}"
end

#unpack!Object



43
44
45
46
47
48
49
50
51
# File 'lib/rsgt/multipacker.rb', line 43

def unpack!
  filtered_psarscs.each do |dlc|
    if unpack dlc
      count[:total] = count[:total] + 1
    else
      count[:failed] = count[:failed] + 1
    end
  end
end