Class: NightcrawlerSwift::CLI::Formatters::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/nightcrawler_swift/cli/formatters/basic.rb

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ Basic

Returns a new instance of Basic.



5
6
7
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 5

def initialize runner
  @runner = runner
end

Instance Method Details

#command_delete(command) ⇒ Object



27
28
29
30
31
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 27

def command_delete command
  filepath = @runner.argv.first
  deleted = command.new.execute(filepath).to_json
  @runner.log(deleted ? "success" : "failure")
end

#command_download(command) ⇒ Object



14
15
16
17
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 14

def command_download command
  filepath = @runner.argv.first
  @runner.log command.new.execute(filepath)
end

#command_list(command) ⇒ Object



9
10
11
12
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 9

def command_list command
  array = command.new.execute
  array.each {|hash| @runner.log hash["name"]}
end

#command_metadata(command) ⇒ Object



33
34
35
36
37
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 33

def  command
  filepath = @runner.argv.first
   = command.new.execute(filepath)
  @runner.log JSON.pretty_generate()
end

#command_upload(command) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 19

def command_upload command
  realpath = @runner.argv.shift
  swiftpath = @runner.argv.shift

  uploaded = command.new.execute swiftpath, File.open(File.expand_path(realpath), "r")
  @runner.log(uploaded ? "success" : "failure")
end

#command_url_for(command) ⇒ Object



39
40
41
42
# File 'lib/nightcrawler_swift/cli/formatters/basic.rb', line 39

def command_url_for command
  filepath = @runner.argv.first
  @runner.log command.new.execute(filepath)
end