Class: Sashimi::Commands::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/sashimi/commands.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Update

Returns a new instance of Update.



135
136
137
# File 'lib/sashimi/commands.rb', line 135

def initialize(base_command)
  @base_command = base_command
end

Instance Method Details

#optionsObject



139
140
141
142
143
144
145
146
147
# File 'lib/sashimi/commands.rb', line 139

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} update [OPTIONS] PLUGIN [PLUGIN2, PLUGIN3]"
    o.define_head "Update installed plugin(s)."
    o.on("-a", "--all", "Update all installed plugins.") { |@all| }
    o.on("-r", "--rails", "Install the plugin(s) in a Rails app.") { |@rails| }
  end
end

#parse!(args) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
# File 'lib/sashimi/commands.rb', line 149

def parse!(args)
  options.parse!(args)
  raise "Can't use both --all and --rails arguments." if @all and @rails
  if @all
    update_plugins(AbstractRepository.plugins_names)
  elsif @rails
    AbstractRepository.update_rails_plugins(args)
  else
    update_plugins(args)
  end
end

#update_plugins(plugins) ⇒ Object



161
162
163
164
165
# File 'lib/sashimi/commands.rb', line 161

def update_plugins(plugins)
  plugins.each do |plugin|
    Plugin.new(plugin).update
  end
end