Class: Warehaus::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/warehaus.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ CLI

Returns a new instance of CLI.



163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/warehaus.rb', line 163

def initialize(args)
	@options = args
				.select{|arg| (arg =~ /^\-/) != nil}
				.map{|arg| arg.gsub(/^\-/,'')}

	set_options

	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



199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/warehaus.rb', line 199

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



180
181
182
183
184
185
186
187
188
# File 'lib/warehaus.rb', line 180

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_optionsObject



176
177
178
# File 'lib/warehaus.rb', line 176

def set_options
	@options.each{ |opt| self.send(opt)}
end

#unbox(args) ⇒ Object



194
195
196
197
# File 'lib/warehaus.rb', line 194

def unbox(args)
	fetcher = Warehaus::Getter.new(*args)
	fetcher.unbox
end

#vObject



190
191
192
# File 'lib/warehaus.rb', line 190

def v
	$mode = "verbose"
end