mvn-get 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mvn-get/cli.rb +1 -0
- data/lib/mvn-get/mvn-get.rb +6 -39
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05dfa24826165feb2d1041a6ca65f1386495e46b
|
4
|
+
data.tar.gz: c607c48f12a969f852d2cd5545750206ddf6a4b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b010e03b2368d581dc6d7879117e28041d201602e0407cd7d5a8d2e3fb330efded86d40d5fd8b88986cddbc1f1d83282e88cab3392f1ad4583a3fcef2cfb57d0
|
7
|
+
data.tar.gz: 4d8dc18b2eb4ae97442eeb0aeb28bae511dd4f6c8056f5cf7905eec8cfa4201a15b248b5080c57c914669957b24a140ff685b45d653cc3e8d015ee178e9556b9
|
data/lib/mvn-get/cli.rb
CHANGED
data/lib/mvn-get/mvn-get.rb
CHANGED
@@ -13,7 +13,7 @@ module MavenCentral
|
|
13
13
|
module_function
|
14
14
|
|
15
15
|
def version
|
16
|
-
"0.0.
|
16
|
+
"0.0.3"
|
17
17
|
end
|
18
18
|
|
19
19
|
def extract_url_from_dict(d, filetype="pom")
|
@@ -50,8 +50,6 @@ module MavenCentral
|
|
50
50
|
"#{MAVEN_CENTRAL_SEARCH}?q=#{keyword}&wt=json"
|
51
51
|
end
|
52
52
|
|
53
|
-
# puts url
|
54
|
-
|
55
53
|
result = {}
|
56
54
|
body = JSON.parse(MavenCentral.request(url))
|
57
55
|
result["candidates"] = body["response"]["docs"].map{|x| x["id"] }
|
@@ -81,7 +79,7 @@ class MavenCentralRepo
|
|
81
79
|
|
82
80
|
@id = id
|
83
81
|
d = MavenCentral.id2dict(@id)
|
84
|
-
raise "not a correct id
|
82
|
+
raise "not a correct id. please use 'groupId:artifactId' or 'groupId:artifactId:version'" if d.nil?
|
85
83
|
|
86
84
|
# use lastest version by default
|
87
85
|
if d["version"] == nil || d["version"].strip == ""
|
@@ -92,22 +90,15 @@ class MavenCentralRepo
|
|
92
90
|
@groupId, @artifactId, @version = d["groupId"], d["artifactId"], d["version"]
|
93
91
|
|
94
92
|
pom_url = MavenCentral.extract_url_from_dict(d)
|
95
|
-
# puts pom_url
|
96
|
-
|
97
93
|
body = MavenCentral.request(pom_url)
|
98
94
|
@pom = Hash.from_xml( body )
|
99
95
|
end
|
100
96
|
|
101
|
-
# def dependencies_url
|
102
|
-
# dependencies.map{|x| MavenCentral.extract_url_from_id(x, "pom") }
|
103
|
-
# end
|
104
|
-
|
105
97
|
def dependencies(ignore_test_lib = true)
|
106
98
|
return [] if @pom["project"]["dependencies"].nil? or
|
107
99
|
(@pom["project"]["dependencies"].class == String and @pom["project"]["dependencies"].strip == "")
|
108
100
|
[@pom["project"]["dependencies"]["dependency"]].flatten.map{|x|
|
109
101
|
next if ignore_test_lib and x["scope"] and x["scope"].strip == "test"
|
110
|
-
# puts "dep #{@id}\n#{x}"
|
111
102
|
if x["version"] =~ /\s*[$]{\s*project[.]version\s*}\s*/
|
112
103
|
x["version"] = @version
|
113
104
|
end
|
@@ -128,7 +119,6 @@ class MavenCentralRepo
|
|
128
119
|
deps = dependencies(ignore_test_lib)
|
129
120
|
while not deps.empty?
|
130
121
|
d = deps.shift
|
131
|
-
# puts "deps #{d}"
|
132
122
|
if not res.map{|x| x.id }.include?(d)
|
133
123
|
r = MavenCentralRepo.new(d)
|
134
124
|
if not res.include?(r)
|
@@ -144,21 +134,15 @@ class MavenCentralRepo
|
|
144
134
|
end
|
145
135
|
end
|
146
136
|
|
147
|
-
|
148
|
-
|
149
|
-
|
137
|
+
if only_select_lastest_version
|
138
|
+
res = res.group_by{|x| "#{x.groupId}:#{x.artifactId}" }.map{|k, v| v.reduce{|s, x| if s.version <=> x.version then x else s end } }.flatten
|
139
|
+
end
|
150
140
|
|
151
141
|
res.sort!
|
152
142
|
@_recursive_dependencies ||= {}
|
153
143
|
@_recursive_dependencies[ignore_test_lib] ||= {}
|
154
144
|
@_recursive_dependencies[ignore_test_lib][only_select_lastest_version] = res
|
155
145
|
return res
|
156
|
-
# dependencies.map{|x|
|
157
|
-
# repo = MavenCentralRepo.new(x)
|
158
|
-
# puts "--- #{@id} ---"
|
159
|
-
# puts repo.dependencies
|
160
|
-
# [repo, repo.recursive_dependencies]
|
161
|
-
# }.flatten
|
162
146
|
end
|
163
147
|
|
164
148
|
def inspect
|
@@ -182,25 +166,8 @@ class MavenCentralRepo
|
|
182
166
|
|
183
167
|
end
|
184
168
|
|
185
|
-
# id =
|
186
|
-
|
187
|
-
# id = "com.mashape.unirest:unirest-java:1.4.5"
|
169
|
+
# id = 'com.mashape.unirest:unirest-java:1.4.5'
|
188
170
|
# r = MavenCentralRepo.new(id)
|
189
|
-
# r.recursive_dependencies.each {|x| x.download }
|
190
|
-
# puts r.dependencies
|
191
|
-
|
192
|
-
# puts MavenCentral.search("org.technbolts:junit:1.0.1")
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
# puts r.recursive_dependencies
|
197
|
-
# puts r.dependencies_url
|
198
|
-
# puts r.dependencies
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
# require 'irb'
|
203
|
-
# IRB.start
|
204
171
|
|
205
172
|
|
206
173
|
|