lib/yamg/cli.rb in yamg-0.3.8 vs lib/yamg/cli.rb in yamg-0.5.0
- old
+ new
@@ -1,11 +1,11 @@
module YAMG
# Command line interface
class CLI
attr_accessor :works, :scope
- def initialize(argv)
+ def initialize(argv = {})
puts
puts Rainbow(' Y A M G').red
puts
if argv.join =~ /debug/
YAMG.debug = true
@@ -33,24 +33,26 @@
File.join(path, asset)
end
def compile_screenshots(ss, size, setup)
return unless YAMG.config['screenshot'].respond_to?(:[])
- fail 'No url provided' unless url = YAMG.config['screenshot']['url']
- Screenshot.new(ss, { 'size' => size, 'url' => url } ).work(setup['path'])
+ fail 'No url provided' unless (url = YAMG.config['screenshot']['url'])
+ Screenshot.new(ss, 'size' => size, 'url' => url).work(setup['path'])
puts Rainbow("[o]SS #{ss}").black
end
def compile_media(i, size, setup)
end
def compile_icon(i, size, setup)
folder = setup['icon'] || YAMG.config['icon']['path']
# Don' use || here, we are after false
+ bg = setup['bg'] || setup['background']
round = setup['rounded']
round = YAMG.config['icon']['rounded'] if round.nil?
- Icon.new(folder, size, round).image(home_for(i, setup))
+ radius = setup['radius']
+ Icon.new(folder, size, bg, round, radius).image(home_for(i, setup))
print Rainbow(round ? '(i)' : '[i]').black
YAMG.info("Icon #{size}px -> #{setup['path']}#{i} ", :black)
end
def compile_splash(s, size, setup)
@@ -59,10 +61,19 @@
Splash.new(path, size, background).image(home_for(s, setup))
print Rainbow('{S}').black
YAMG.info("Splash #{size.join('x')}px #{setup['path']}#{s}", :black)
end
+ def compile_docs(opts)
+ out = opts['path']
+ %w( manifest.json browserconfig.xml ).each do |doc|
+ puts Rainbow("{DOCS} #{out}/#{doc} created. Please review.").red
+ src = File.expand_path("assets/#{doc}", File.dirname(__FILE__))
+ FileUtils.cp(src, out)
+ end
+ end
+
def compile_work(job, opts)
task = YAMG::TEMPLATES[job] || (works[job] && works[job]['export'])
%w(icon logo splash media screenshots).each do |subtask|
next unless (work = task[subtask])
@@ -70,13 +81,14 @@
Thread.new do # 500% speed up with 8 cores
send(:"compile_#{subtask}", asset, size, setup_for(opts))
end
end
end
+ compile_docs(opts) if task['docs']
end
def compile
- works.select! { |k,_v| k =~ /#{scope}/ } if scope
+ works.select! { |k, _v| k =~ /#{scope}/ } if scope
puts Rainbow("Tasks: #{works.keys.join(', ')}").yellow
works.each { |out, opts| compile_work(out, opts) }
end
def screenshot