GradleSearchResTools 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7211d2c223e093ffdb6d518910796d0cfd12c026
4
+ data.tar.gz: 487d09244066b0c9d407281b5f1d2399876ec55b
5
+ SHA512:
6
+ metadata.gz: b0188d22f74c0a59c060aeb257a00cb0d5f0f77bdefaed9da4b8d16f91efa17b3ad043d34cb1e0073f1177f5a15ce52e6b9c5240d44507c9f97ebca72ac962fb
7
+ data.tar.gz: 6f47c728f852038b4de5f21fe6f1bcf940274d4cc0a92291cb18b43857d11a71c519aaf14d48aabbf73b900385cd249c7ffedfdf54cf4573c79af8680f160d23
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'GradleSearchResTools'
4
+ puts GradleSearchResTools.search(ARGV[0])
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ class GradleSearchResTools
3
+ def self.search(keyword = :gson)
4
+ searchTask = Search.new(keyword)
5
+ searchTask.searching
6
+ end
7
+ end
8
+
9
+ require 'search'
10
+
11
+
data/lib/Search.rb ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ require "open-uri"
3
+ require 'json'
4
+ class Search
5
+ def initialize(keyword)
6
+ @keyword = keyword
7
+ end
8
+
9
+ def searching
10
+ puts @keyword
11
+ puts '************************************************'
12
+ puts ' ......searching < '<<@keyword.chomp<<' > .......'
13
+ puts '************************************************'
14
+ sessionId = Random.rand(110000)
15
+ uri = 'http://gradleplease.appspot.com/search?q='<<@keyword.chomp<<'&session='<<sessionId.to_s
16
+ # puts uri
17
+ html_response = nil
18
+ open(uri) do |http|
19
+ html_response = http.read
20
+ end
21
+ if(html_response.length == 0)
22
+ return
23
+ end
24
+ # puts html_response
25
+ tag ='searchCallback('
26
+ sstart = tag.length
27
+ send = html_response.length-1 - sstart
28
+ result = html_response[sstart,send]
29
+ # puts result
30
+ json_obj = JSON.parse(result)
31
+ docs = json_obj['response']['docs']
32
+ if(docs.length == 0)
33
+ puts '*** not found ***'
34
+ return
35
+ end
36
+ firstRes = nil
37
+ puts ''
38
+ puts '************'
39
+ puts 'result:::::::::'
40
+ puts '--------------------------------------'
41
+ docs.each do |item|
42
+ p item["id"] << ":" << item['latestVersion']
43
+ if firstRes == nil
44
+ firstRes = item["id"] << ":" << item['latestVersion']
45
+ end
46
+ end
47
+ puts '--------------------------------------'
48
+
49
+ puts ''
50
+ puts '************* copy this to your project build file *************'
51
+ puts ''
52
+ puts 'dependencies {'
53
+ puts 'compile '<<"'"<<firstRes<<"'"
54
+ puts '}'
55
+ puts ''
56
+ puts '************* ------- searching end -------------- *************'
57
+ puts ''
58
+
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: GradleSearchResTools
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - liu peng
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Gradle Search Res Command line Tools!
14
+ email: 79144876@qq.com
15
+ executables:
16
+ - GradleSearchResTools
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/GradleSearchResTools
21
+ - lib/GradleSearchResTools.rb
22
+ - lib/Search.rb
23
+ homepage: http://rubygems.org/gems/GradleSearchResTools
24
+ licenses: []
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.4.6
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Gradle Search Res Tools!
46
+ test_files: []