Module: Assetify
- Defined in:
- lib/assetify/cli.rb,
lib/assetify/dsl.rb,
lib/assetify/gui.rb,
lib/assetify/asset.rb,
lib/assetify/helpers.rb,
lib/assetify/version.rb,
lib/assetify/cli/term.rb,
lib/assetify/asset/pkg.rb,
lib/assetify/assetfile.rb,
lib/assetify/constants.rb,
lib/assetify/asset/pathfix.rb
Overview
To be refactored…
Defined Under Namespace
Modules: Helpers Classes: Asset, Assetfile, CLI, DSL, GUI, Pathfix, Pkg
Constant Summary collapse
- LINE =
CLI.new
- VERSION =
'3.0.0'.freeze
- Opt =
{ vendor: 'public/vendor', newname: true }
- TSIZE =
80
- ASSETS_PATH =
'vendor/assets'.freeze
- ASSETS =
[:javascripts, :stylesheets, :images].freeze
Class Method Summary collapse
-
.bar ⇒ Object
Divider bar.
- .check(assets) ⇒ Object
-
.check_param(params, string) ⇒ Object
Text Interface.
-
.find_assets(params = nil) ⇒ Object
Fuzzy find files.
- .install(assets, force = false) ⇒ Object
- .work!(params) ⇒ Object
-
.work_on(params) ⇒ Object
CLI Master case/switch!.
Class Method Details
.check(assets) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/assetify/cli.rb', line 24 def check(assets) assets.each do |a| LINE.p a.header if a.file_exists? # Return if file is on path a.read_data LINE.f "#{a.print_version} Installed" else LINE.f 'Not Found', :red end end end |
.check_param(params, string) ⇒ Object
Text Interface
11 12 13 14 15 16 |
# File 'lib/assetify/cli.rb', line 11 def check_param(params, string) unless string.include? params[0] puts "Did you mean #{string}?" exit 0 end end |
.find_assets(params = nil) ⇒ Object
Fuzzy find files
19 20 21 22 |
# File 'lib/assetify/cli.rb', line 19 def find_assets(params = nil) return Asset.all unless params Asset.filter params end |
.install(assets, force = false) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/assetify/cli.rb', line 36 def install(assets, force = false) assets.each do |a| LINE.p a.header if !force && a.file_exists? # Return if file is on path a.read_data return LINE.f "#{a.print_version} Installed" end begin # Creates a thread to insert dots while downloading points = Thread.new { loop { ; LINE.p '.'; sleep 1; } } a.install! force LINE.f "#{a.print_version} ok" rescue => e LINE.f :FAIL, :red p "Fail: #{e} #{e.backtrace}" ensure points.kill end end end |
.work!(params) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/assetify/cli.rb', line 97 def work!(params) start = Time.now Assetfile.find print "Assetify - #{Asset.all.size} assets" print " | #{params[1..-1].join(' . ')}" if params[1] puts ' |' work_on params puts "Done in #{Time.now - start}s" end |
.work_on(params) ⇒ Object
CLI Master case/switch!
Destructive: i -> install u -> update x -> clean ? todo
Safe: c -> check w -> web
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/assetify/cli.rb', line 70 def work_on(params) assets = find_assets(params[1]) case params.first when /^i/, nil check_param params, 'install' if params[0] install assets when /^u/ check_param params, 'update' install assets, :force when /^c/ check_param params, 'check' check assets when /^w/ check_param params, 'web' GUI.boot! else puts "Dunno how to #{params.join}." end end |