Class: Commands::Search
- Inherits:
-
Object
- Object
- Commands::Search
- Defined in:
- lib/commands/plugin/commands.rb
Instance Method Summary collapse
-
#initialize(base_command) ⇒ Search
constructor
A new instance of Search.
- #options ⇒ Object
- #parse!(args) ⇒ Object
Constructor Details
#initialize(base_command) ⇒ Search
Returns a new instance of Search.
552 553 554 555 |
# File 'lib/commands/plugin/commands.rb', line 552 def initialize(base_command) @base_command = base_command @directory = "http://agilewebdevelopment.com/plugins/search?search=%s" end |
Instance Method Details
#options ⇒ Object
557 558 559 560 561 562 563 564 565 |
# File 'lib/commands/plugin/commands.rb', line 557 def OptionParser.new do |o| o.set_summary_indent(' ') o. = "Usage: #{@base_command.script_name} search \"search string\"" o.on( "-d DIRECTORY", "--directory DIRECTORY", "Queries the URL specified by DIRECTORY.") { |v| @directory = v } o.define_head "Search plugins." end end |
#parse!(args) ⇒ Object
567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/commands/plugin/commands.rb', line 567 def parse!(args) .parse!(args) uri = URI.parse(@directory % URI.escape(args.first)) request = Net::HTTP.new(uri.host, uri.port) root = REXML::Document.new(request.send_request('GET', uri.request_uri, nil, 'Accept' => 'application/xml').body).root root.elements.each('plugin') do |p| puts p.elements['name'].text puts " Info: #{p.elements['link'].text}" puts " Install: #{p.elements['repository'].text}" end rescue nil end |