Class: Commands::Sources

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

Instance Method Summary collapse

Constructor Details

#initialize(base_command) ⇒ Sources

Returns a new instance of Sources.



180
181
182
# File 'lib/commands/plugin/commands.rb', line 180

def initialize(base_command)
  @base_command = base_command
end

Instance Method Details

#optionsObject



184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/commands/plugin/commands.rb', line 184

def options
  OptionParser.new do |o|
    o.set_summary_indent('  ')
    o.banner =    "Usage: #{@base_command.script_name} sources [OPTIONS] [PATTERN]"
    o.define_head "List configured plugin repositories."
    o.separator   ""        
    o.separator   "Options:"
    o.separator   ""
    o.on(         "-c", "--check", 
                  "Report status of repository.") { |@sources| } # TODO Implement
    o.on(         "-r", "--refresh", 
                  "Refresh the source cache with the list of plugins available in each repository.") { refresh }
  end
end

#parse!(args) ⇒ Object



199
200
201
202
203
204
# File 'lib/commands/plugin/commands.rb', line 199

def parse!(args)
  options.parse!(args)
  Repositories.each do |repo|
    puts repo.uri
  end
end

#refreshObject



206
207
208
209
210
211
# File 'lib/commands/plugin/commands.rb', line 206

def refresh
  puts "Refreshing source cache (may take a few minutes)..."
  repositories = Repositories.instance
  repositories.refresh!
  repositories.save
end