Class: FlickrTools::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/flickr-tools/command.rb

Direct Known Subclasses

Auth, GetSet, Upload

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/flickr-tools/command.rb', line 15

def initialize(argv)
  @config_dir = self.class.find_config_dir
  @args = argv.dup
  @name = @args.shift
  @token_cache = File.join(@config_dir, "#{@name}.yml")
  @flickr_yml = File.join @config_dir, 'flickr.yml'
  unless File.readable?(@flickr_yml)
    FileUtils.cp File.expand_path('../../../doc/flickr.yml.example', __FILE__), @flickr_yml
    puts "Please get a flickr API key and secret from flickr.com and edit #{@flickr_yml} accordingly."
    exit 1
  end
end

Class Method Details

.find_config_dirObject



5
6
7
8
9
10
11
12
# File 'lib/flickr-tools/command.rb', line 5

def self.find_config_dir
  config_dir = File.expand_path('../../../config', __FILE__)
  unless File.directory?(config_dir)
    config_dir = File.join(ENV['HOME'], '.flickr-tools')
    FileUtils.mkdir_p config_dir
  end
  return config_dir
end