Class: Looks::Command::Add

Inherits:
AccountManagement show all
Defined in:
lib/looks/command/add.rb

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from AccountManagement

#configure

Methods inherited from Base

#initialize, #run, #to_s, #usage

Constructor Details

This class inherits a constructor from Looks::Command::Base

Instance Method Details

#argumentsObject



9
10
11
# File 'lib/looks/command/add.rb', line 9

def arguments
  [ '<filename>' ]
end

#execute(args) ⇒ Object

Raises:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/looks/command/add.rb', line 13

def execute(args)
  super

  filename = args.first

  raise Error, "#{filename}: File not found" unless File.exists? filename

  begin
    File.open(filename) do |file|
      puts Gravatar::Account.new(config).add(file.read)
    end
  rescue IOError, SystemCallError
    raise Error, "#{filename}: Cannot read file"
  end
end