Module: YAMG
- Defined in:
- lib/yamg.rb,
lib/yamg/cli.rb,
lib/yamg/icon.rb,
lib/yamg/splash.rb,
lib/yamg/version.rb,
lib/yamg/screenshot.rb
Overview
Defined Under Namespace
Classes: CLI, Icon, Screenshot, Splash
Constant Summary
collapse
- CONFIG_FILE =
'./yamg.yml'.freeze
- TEMPLATES =
YAML.load_file(
File.join(File.dirname(__FILE__), 'yamg', 'templates.yaml')
)
- VERSION =
'2.1.1'.freeze
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
24
25
26
|
# File 'lib/yamg.rb', line 24
def config
@config
end
|
.debug ⇒ Object
Returns the value of attribute debug.
24
25
26
|
# File 'lib/yamg.rb', line 24
def debug
@debug
end
|
Class Method Details
.info(msg, color = :red) ⇒ Object
67
68
69
70
|
# File 'lib/yamg.rb', line 67
def info(msg, color = :red)
return unless debug
puts Rainbow(msg).send(color)
end
|
.init ⇒ Object
26
27
28
29
30
31
32
33
34
|
# 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) ⇒ Object
36
37
38
39
40
|
# 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) ⇒ Object
42
43
44
45
46
47
|
# 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) ⇒ Object
72
73
74
75
76
77
|
# 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) ⇒ Object
49
50
51
52
|
# File 'lib/yamg.rb', line 49
def run(comm)
puts comm if debug
system(comm)
end
|
.run_ffmpeg ⇒ Object
59
60
|
# File 'lib/yamg.rb', line 59
def run_ffmpeg
end
|
.run_imagemagick(comm) ⇒ Object
62
63
64
65
|
# File 'lib/yamg.rb', line 62
def run_imagemagick(comm)
shell = MiniMagick::Shell.new shell.run(comm).strip
end
|
.run_rsvg(src, out, args = nil) ⇒ Object
54
55
56
57
|
# 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
|