Class: Warehaus::CLI
- Inherits:
-
Object
- Object
- Warehaus::CLI
- Defined in:
- lib/warehaus.rb
Instance Method Summary collapse
- #help(method = "none") ⇒ Object
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #json(args) ⇒ Object
- #set_options ⇒ Object
- #unbox(args) ⇒ Object
- #v ⇒ Object
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/warehaus.rb', line 147 def initialize(args) @options = args .select{|arg| (arg =~ /^\-/) != nil} .map{|arg| arg.gsub(/^\-/,'')} stripped_args = args.reject{|arg| (arg =~ /^\-/) != nil} @method = stripped_args[0] @arguments = stripped_args[1..-1] self.send(@method, @arguments) end |
Instance Method Details
#help(method = "none") ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/warehaus.rb', line 183 def help(method="none") puts <<eol WAREHAUS NAME warehaus SYNOPSIS warehouse COMMAND [-v] [ARGS] DESCRIPTION Takes URLS or IDs for Sketchup Warehouse models, grabs their collada resources, and unpacks them into a target directory OPTIONS -v Prints logging and debug information WAREHAUS COMMANDS unbox [identifier] [path=./] [name=warehouse_model] Unpacks Sketchup model identified by [identifier] to [path]/[name]/[name].dae json [path] [path] is a path to a json file to parse and use for unboxing. see the github docs for information on the strucure of this file help prints help eol end |
#json(args) ⇒ Object
164 165 166 167 168 169 170 171 172 |
# File 'lib/warehaus.rb', line 164 def json(args) File.open(args[0]) do |file| @json = JSON.parse(file.read, :symbolize_names => true) end Warehaus::Getter.from_hash(@json) end |
#set_options ⇒ Object
160 161 162 |
# File 'lib/warehaus.rb', line 160 def @options.each{ |opt| self.send(opt)} end |
#unbox(args) ⇒ Object
178 179 180 181 |
# File 'lib/warehaus.rb', line 178 def unbox(args) fetcher = Warehaus::Getter.new(*args) fetcher.unbox end |
#v ⇒ Object
174 175 176 |
# File 'lib/warehaus.rb', line 174 def v $mode = "verbose" end |