Class: Rares::Command

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

Constant Summary collapse

DEFAULT_HOST =
'http://rampagerecipes.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Command

Returns a new instance of Command.



10
11
12
# File 'lib/rares/command.rb', line 10

def initialize(options)
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/rares/command.rb', line 6

def options
  @options
end

Instance Method Details

#runObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rares/command.rb', line 14

def run
  if options[:remote_id]
    id = options[:remote_id]
    directory = File.join Dir.pwd, "tmp", "rares", id
    FileUtils.rm_rf File.join Dir.pwd, "tmp", "rares"
    FileUtils.mkdir_p(directory)

    download_and_extract_recipe!(options[:remote_host] || DEFAULT_HOST, id, directory)

    Rares::Main.new(directory, Dir.pwd).perform
  elsif options[:local_path]
    puts "Using local folder #{options[:local_path]}"
    Rares::Main.new(options[:local_path], Dir.pwd).perform
  else
    puts "Should provide remote id or local path"
  end
end