GradleSearch 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 947c54123f11ceb0b2df9064383d960086695995
4
+ data.tar.gz: 227177906884d9cef098b219df0d18485db2cbf6
5
+ SHA512:
6
+ metadata.gz: 9ec3a0c7834da64631d3973a42679ddb9bf6c56e340fa3a970cd597b1f525b56156874e7d52d7b98c11ad4070abcacf002ef3585358a7e95d42ee363e322b8ab
7
+ data.tar.gz: 9643d2f42d210ba1a2b80424a94f59a23d67888a3127c000312f523aab82fa6bfd6cefc8043c38aef3bb37f1f9b8fd5570ffa7b4fc78d14fefd7ca0b87523dfe
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require 'dotenv'
3
+ Dotenv.load
4
+
5
+ require 'terminal-table'
6
+
7
+ $:.push File.expand_path("../../lib", __FILE__)
8
+
9
+ require 'GradleSearch'
10
+
11
+ puts GradleSearch.search(ARGV[0])
12
+
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ class GradleSearch
3
+ def self.search(keyword = :gson)
4
+ searchTask = Search.new(keyword)
5
+ searchTask.searching
6
+ end
7
+ end
8
+
9
+ require 'search'
10
+
11
+
@@ -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: GradleSearch
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
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: 'simple use this on your terminal command: GradleSearch gson'
14
+ email: 79144876@qq.com
15
+ executables:
16
+ - GradleSearch
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/GradleSearch
21
+ - lib/GradleSearch.rb
22
+ - lib/Search.rb
23
+ homepage: http://rubygems.org/gems/GradleSearch
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: []