class Openmeta::CLI

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/openmeta/cli.rb, line 9
def initialize(*)
  super
  Openmeta.ui = UI::Shell.new(options)
  Openmeta.ui.level = "debug" if options["verbose"]
end

Public Instance Methods

add(*files) click to toggle source
# File lib/openmeta/cli.rb, line 76
def add(*files)
  tags = options[:tag].split(',')
  Openmeta.add_tags(tags, files)
end
clear(*files) click to toggle source
# File lib/openmeta/cli.rb, line 52
def clear(*files)
  Openmeta.clear(files)
end
clone(*files) click to toggle source
# File lib/openmeta/cli.rb, line 31
def clone(*files)
  Openmeta.clone(options[:from], files)
end
get(*files) click to toggle source
# File lib/openmeta/cli.rb, line 41
def get(*files)
  files.each { |file|
    tags = {
      :tags => Openmeta.get_tags(file),
      :rating => Openmeta.get_rating(file)
    }
    puts_to(options[:format], tags)
  }
end
rate(*files) click to toggle source
# File lib/openmeta/cli.rb, line 98
def rate(*files)
  files.each { |file|
    if options[:rate] > 5.0
      raise RangeError, "rating is between [0.0 - 5.0]"
    end
    Openmeta.set_rating(options[:rate], file)
  }
end
recent() click to toggle source
# File lib/openmeta/cli.rb, line 21
def recent
  puts_to(options[:format], Openmeta.recent_tags)
end
remove(*files) click to toggle source
# File lib/openmeta/cli.rb, line 87
def remove(*files)
  tags = options[:tag].split(',')
  Openmeta.remove_tags(tags, files)
end
set(*files) click to toggle source
# File lib/openmeta/cli.rb, line 63
def set(*files)
  files.each { |file|
    tags = options[:tag].split(',')
    Openmeta.set_tags(tags, file)
  }
end

Private Instance Methods

puts_to(format, data) click to toggle source
# File lib/openmeta/cli.rb, line 108
def puts_to(format, data)
  unless format
    puts data
  else
    to_format = "to_#{format}"

    begin
      puts data.send(to_format)
    rescue NoMethodError
      raise Openmeta::NoMethodError, "#{to_format} has not implemented!"
    end
  end

end