Module: Photostat

Defined in:
lib/photostat.rb,
lib/photostat/db/base.rb,
lib/photostat/utils/os.rb,
lib/photostat/plugins/00_base.rb,
lib/photostat/plugins/01_local.rb,
lib/photostat/plugins/03_query.rb,
lib/photostat/plugins/02_flickr.rb

Defined Under Namespace

Modules: DB, OSUtils, Plugins Classes: Flickr, Local, Query

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.activate!Object



29
30
31
32
33
# File 'lib/photostat.rb', line 29

def self.activate!
  Photostat::Plugins.all_in_order.each do |plugin|      
    plugin.new.activate!
  end
end

.activate_plugin!(name) ⇒ Object



39
40
41
# File 'lib/photostat.rb', line 39

def self.activate_plugin!(name)
  Photostat::Plugin.all[name.to_s].new.activate!
end

.configObject



22
23
24
25
26
27
# File 'lib/photostat.rb', line 22

def self.config
  unless @config
    @config = YAML.load(File.read(File.expand_path "~/.photostat"))
  end
  @config
end

.configure_plugin!(name) ⇒ Object



35
36
37
# File 'lib/photostat.rb', line 35

def self.configure_plugin!(name)
  Photostat::Plugins.all[name.to_s].new.config
end

.executeObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/photostat.rb', line 43

def self.execute
  cmd, subc = nil, :help
  cmd = ARGV.shift if ARGV and ARGV.length > 0
  if cmd =~ /^(\w+):(\w+)$/
    cmd, subc = $1, $2.to_sym
  end

  all_plugins = Photostat::Plugins.all
  if cmd and all_plugins[cmd]
    all_plugins[cmd].new.send subc
  else
    show_help
  end
end

.rootObject



18
19
20
# File 'lib/photostat.rb', line 18

def self.root
  Pathname.new File.join(File.dirname(__FILE__), 'photostat')
end

.show_helpObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/photostat.rb', line 58

def self.show_help
  puts "Photostat version #{Photostat::VERSION}"
  puts
  puts "Getting help for a particular plugin:   photostat <plugin_name>"
  puts "Getting help for a particular command:: photostat <command> --help"
  puts
  puts "Available plugins:"

  Photostat::Plugins.all.each_key do |cmd_name|      
    cmd_obj = Photostat::Plugins.all[cmd_name]
    help_text = "#{cmd_name}"
    help_text += "\t- #{cmd_obj.help_text}" if cmd_obj.help_text
    puts "  #{help_text}"
  end

  puts
  puts "All available commands:"
  Photostat::Plugins.all.each_key do |cmd_name|
    cmd_obj = Photostat::Plugins.all[cmd_name]
    cmd_obj.exposes.each do |name|
      msg = "  #{cmd_obj.plugin_name}:#{name}"
      if cmd_obj.exposes_help[name]
        msg += "\t- " + cmd_obj.exposes_help[name] 
      end
      puts msg
    end
  end
  puts
end