Class: Coherent::Commands::Update

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

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Update

Returns a new instance of Update.



6
7
8
# File 'lib/plugin/commands/update.rb', line 6

def initialize(base_command)
  @base_command = base_command
end

Instance Method Details

#optionsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/plugin/commands/update.rb', line 10

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} update [name [name]...]"
    o.on(         "-r REVISION", "--revision REVISION",
                  "Checks out the given revision from subversion.",
                  "Ignored if subversion is not used.") { |v| @revision = v }
    o.define_head "Update plugins."
  end
end

#parse!(args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/plugin/commands/update.rb', line 21

def parse!(args)
  options.parse!(args)
  root = @base_command.environment.root
  cd root
  args = Dir["vendor/plugins/*"].map do |f|
    File.directory?("#{f}/.svn") ? File.basename(f) : nil
  end.compact if args.empty?
  cd "vendor/plugins"
  args.each do |name|
    if File.directory?(name)
      puts "Updating plugin: #{name}"
      system("svn #{$verbose ? '' : '-q'} up \"#{name}\" #{@revision ? "-r #{@revision}" : ''}")
    else
      puts "Plugin doesn't exist: #{name}"
    end
  end
end