Class: Quik::Toolii
- Inherits:
-
Object
- Object
- Quik::Toolii
- Extended by:
- GLI::App
- Defined in:
- lib/quik/cli/main.rb
Overview
NOTE: gli added function are class methods (thus, wrap class Toolii in Tool for now)
Class Method Summary collapse
- .fetch_catalog ⇒ Object
- .fetch_script(name_or_path) ⇒ Object
- .logger ⇒ Object
- .logger=(value) ⇒ Object
- .opts ⇒ Object
-
.opts=(value) ⇒ Object
todo: find a better name e.g.
Instance Method Summary collapse
-
#verbose ⇒ Object
todo: use -w for short form? check ruby interpreter if in use too?.
Class Method Details
.fetch_catalog ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/quik/cli/main.rb', line 51 def self.fetch_catalog ## scripts_dir = "#{Quik.root}/test/data" ## catalog = Catalog.new( "#{scripts_dir}/scripts.yml" ) url = QUIK_SCRIPTS_URL puts "GET #{url}".bold.green ## output network access in green bold catalog = Catalog.from_url( url ) catalog end |
.fetch_script(name_or_path) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/quik/cli/main.rb', line 64 def self.fetch_script( name_or_path ) ## first try local version in working folder text = '' extname = File.extname( name_or_path ) ## try local first ## todo/fix: check in ~/.quik/ dir too? path = if extname == '.rb' && File.exist?( name_or_path ) name_or_path elsif extname == '' && File.exist?( "#{name_or_path}.rb" ) "#{name_or_path}.rb" elsif extname == '' && File.exist?( "~/.quik/#{name_or_path}.rb" ) "~/.quik/#{name_or_path}.rb" ## todo/check - if (~) shortcut works in windows -too? else nil end if path text = File.open( path, 'r:utf-8' ) { |f| f.read } else ## try fetch remote script url = nil if name_or_path.index( '/' ).nil? ## assume short-cut name if no (/) in name ## do a lookup from catalog!!! catalog = fetch_catalog rec = catalog.find( name_or_path ) url = rec['script'] if rec if url.nil? puts "!! ERROR - sorry no wizard script found / available for name >#{name_or_path}<" exit 1 end else ## assume custom github url shortcut url = "https://github.com/#{name_or_path}/raw/master/quik.rb" end ## assume utf8 text encoding for now puts "GET #{url}".bold.green ## output network access in green bold worker = Fetcher::Worker.new text = worker.read_utf8!( url ) end text end |
.logger ⇒ Object
25 |
# File 'lib/quik/cli/main.rb', line 25 def self.logger() @@logger; end |
.logger=(value) ⇒ Object
24 |
# File 'lib/quik/cli/main.rb', line 24 def self.logger=(value) @@logger=value; end |
.opts ⇒ Object
29 |
# File 'lib/quik/cli/main.rb', line 29 def self.opts() @@opts; end |
.opts=(value) ⇒ Object
todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
28 |
# File 'lib/quik/cli/main.rb', line 28 def self.opts=(value) @@opts = value; end |
Instance Method Details
#verbose ⇒ Object
todo: use -w for short form? check ruby interpreter if in use too?
44 |
# File 'lib/quik/cli/main.rb', line 44 switch [:verbose], negatable: false |