module YAMG
Yet Another Media Generator
Constants
- CONFIG_FILE
- TEMPLATES
Load template works
- VERSION
Attributes
config[RW]
debug[RW]
Public Class Methods
info(msg, color = :red)
click to toggle source
# File lib/yamg.rb, line 67 def info(msg, color = :red) return unless debug puts Rainbow(msg).send(color) end
init()
click to toggle source
# File lib/yamg.rb, line 26 def init if File.exist?(CONFIG_FILE) puts "File exists: '#{CONFIG_FILE}'" exit 1 end src = File.join(File.dirname(__FILE__), 'yamg', 'yamg.yml') FileUtils.cp(src, CONFIG_FILE) puts_and_exit("Created configuration file '#{CONFIG_FILE}'", :black) end
load_config(conf = CONFIG_FILE)
click to toggle source
# File lib/yamg.rb, line 36 def load_config(conf = CONFIG_FILE) self.config = YAML.load_file(conf).freeze rescue Errno::ENOENT puts_and_exit('Create config! Run: `yamg init`') end
load_images(dir)
click to toggle source
# File lib/yamg.rb, line 42 def load_images(dir) return [dir] unless File.extname(dir).empty? Dir["#{dir}/*.{svg,png,jpg}"].map { |f| File.basename(f) } rescue TypeError puts_and_exit("Bad config file path: #{dir}") end
puts_and_exit(msg, color = :red)
click to toggle source
# File lib/yamg.rb, line 72 def puts_and_exit(msg, color = :red) puts puts Rainbow('---').black puts Rainbow(msg).send(color) exit color == :red ? 1 : 0 end
run(comm)
click to toggle source
# File lib/yamg.rb, line 49 def run(comm) puts comm if debug system(comm) end
run_ffmpeg()
click to toggle source
# File lib/yamg.rb, line 59 def run_ffmpeg end
run_imagemagick(comm)
click to toggle source
# File lib/yamg.rb, line 62 def run_imagemagick(comm) shell = MiniMagick::Shell.new # (whiny) shell.run(comm).strip end
run_rsvg(src, out, args = nil)
click to toggle source
# File lib/yamg.rb, line 54 def run_rsvg(src, out, args = nil) FileUtils.mkdir_p File.dirname(out) run "rsvg-convert #{args} #{src} > #{out}" end