Class: Search
- Inherits:
-
Object
- Object
- Search
- Defined in:
- lib/Search.rb
Instance Method Summary collapse
-
#initialize(keyword) ⇒ Search
constructor
A new instance of Search.
- #searching ⇒ Object
Constructor Details
#initialize(keyword) ⇒ Search
Returns a new instance of Search.
6 7 8 |
# File 'lib/Search.rb', line 6 def initialize(keyword) @keyword = keyword end |
Instance Method Details
#searching ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/Search.rb', line 10 def searching if @keyword == nil || @keyword.to_s.length == 0 puts 'search keyword empty' return end puts @keyword puts '************************************************' puts ' ......searching < '<<@keyword.chomp<<' > .......' puts '************************************************' uri = 'http://192.168.18.56:8081/nexus/service/local/lucene/search?_dc=1438050306799&q='+@keyword+'&collapseresults=false' html_response = nil open(uri) do |http| html_response = http.read end if(html_response.length == 0) return end document = Oga.parse_xml html_response puts 'totalCount: ' + document.at_css('searchNGResponse totalCount').text document.css('searchNGResponse data artifact').each do |person| puts ' ' puts "Group : " + person.at_css('groupId').text puts "Artifact : " + person.at_css('artifactId').text puts "Version : " + person.at_css('version').text puts ' ' # puts '<dependency>' # puts '<groupId>' + person.at_css('groupId').text + '</groupId>' # puts '<artifactId>' + person.at_css('artifactId').text + '</artifactId>' # puts '<version>' + person.at_css('version').text + '</version>' # puts '</dependency>' end puts '--end--' end |