niffler 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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjQ1NjY0ODI5NWNiY2U0YTUwYjYwMmJmNzJlZjNmNjkwNjcyYmYzMQ==
4
+ MjNjMmQwMTE4MDhkYmIwMmZlYmRkOTk3Y2ZmNmQ3MjE1ZTQ1Y2QwMQ==
5
5
  data.tar.gz: !binary |-
6
- ZTJjZTk1MTM2ZjYyZTA0NzcxYzEzNDQ1YjA5YjgwYTI2ZTc2N2UyNg==
6
+ NGE5NWQ0MzVmY2FmMmNhZDUxOTIyOTIyM2MzZmQ1ZmQxZjc3MTU3NQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTU4MTY4YmMxNTcwNzViNjJiMDc3YzViZTU2YjFjZTE0N2I5NzE4OGNjNGI2
10
- YTg2YjI5NGY1ZjMxY2NkNjIzYTJjMzFjYmU1N2UzMmZhMDc2MmQyYzRmN2Ri
11
- MjBjNzNjYzJjNTMwZmViZjlkNmY1YzI1ZGUwMDliNWNmMTA3OGQ=
9
+ ZjcwNmM4Zjk4MTc0MDdiYzE4MTRlZTc3M2FmNDQwMjkxODQwYjZiMDlmMTAx
10
+ NWZlNjgyOTgyMjQ4ZjU0YThlYmQyYjUwMDYyZjBkZDJjNjA0OGU3YjVhNTY1
11
+ M2M1NDM2MDlkZTU0MTM4NjEwY2FiMzZjNmI4M2NkOTI2Y2VlN2Y=
12
12
  data.tar.gz: !binary |-
13
- MTg0MzNmMjFjNTBiNDQyYWM5Y2E0MGY0ODA5MWI5YzBjZDRlYjVkMmExYWQ5
14
- MmY2NTk5NjlmOWZkYmI0YWUyMzY5YTE3ZWUzNTliNWVlNzU4YTNjM2FmYjA4
15
- ZGZlYTZmY2UzNTViNTRiMjBmNTZlYTRiNTIyYmU3NGYwYWVmYTM=
13
+ YjNmMGE5NTg3OTAzMWE0YjFhZTcwYjhhMDkxMGU0MGI2MjFiODQyZGI1Yjdl
14
+ MDBlMzc1MGM0ODUwMzljOWUyYmFjNjYyYzg0Yzc3NDliNGI4ZjBkYWVmOWI4
15
+ MTk0MjQ1NTA1ZWYzZGEwYWMxMWRiMjhmOWQ4ZmIyZjBlYWQyYzA=
data/doc/TODO.md CHANGED
@@ -6,3 +6,6 @@
6
6
  * Search by filepath
7
7
  * Search by classname
8
8
  * search by fully-qualified classname
9
+
10
+ ## Fixes
11
+ * Specs should use their own, fake server
data/lib/niffler.rb CHANGED
@@ -0,0 +1,5 @@
1
+ require 'niffler/maven'
2
+
3
+ class Niffler
4
+
5
+ end
data/lib/niffler/maven.rb CHANGED
@@ -80,9 +80,11 @@ class Niffler
80
80
  results = []
81
81
  # response docs refers to the portion of the response with the software metadata for each result
82
82
  for r in json["response"]["docs"]
83
- result = Niffler::Maven.new(group: r["g"], artifact: r["a"], version: r["latestVersion"],
84
- repository: r["repositoryId"], packaging: r["p"])
85
- results << result
83
+ unless r.nil?
84
+ result = Niffler::Maven.new(group: r["g"], artifact: r["a"], version: r["latestVersion"],
85
+ repository: r["repositoryId"], packaging: r["p"])
86
+ results << result
87
+ end # unless r.nil?
86
88
  end # for result
87
89
 
88
90
  return results
@@ -93,8 +95,10 @@ class Niffler
93
95
  # {"responseHeader"=>{"status"=>0, "QTime"=>1, "params"=>{"spellcheck"=>"true", "fl"=>"id,g,a,latestVersion,p,ec,repositoryId,text,timestamp,versionCount", "sort"=>"score desc,timestamp desc,g asc,a asc", "indent"=>"off", "q"=>"guice", "qf"=>"text^20 g^5 a^10", "spellcheck.count"=>"5", "wt"=>"json", "rows"=>"20", "version"=>"2.2", "defType"=>"dismax"}}, "response"=>{"numFound"=>234, "start"=>0, "docs"=>[{"id"=>"com.jolira:guice", "g"=>"com.jolira", "a"=>"guice", "latestVersion"=>"3.0.0", "repositoryId"=>"central", "p"=>"jar", "timestamp"=>1301724755000, "versionCount"=>8, "text"=>["com.jolira", "guice", "-javadoc.jar", "-sources.jar", ".jar", ".pom"], "ec"=>["-javadoc.jar", "-sources.jar", ".jar", ".pom"]}
94
96
  # response docs refers to the portion of the response with the software metadata for each result
95
97
  r = json["response"]["docs"].last
96
- result = Niffler::Maven.new(group: r["g"], artifact: r["a"], version: r["v"],
97
- repository: r["repositoryId"], packaging: r["p"])
98
+ unless r.nil?
99
+ result = Niffler::Maven.new(group: r["g"], artifact: r["a"], version: r["v"],
100
+ repository: r["repositoryId"], packaging: r["p"])
101
+ end
98
102
  return result
99
103
  end # def parse_response
100
104
  end # class Maven
@@ -1,3 +1,3 @@
1
1
  class Niffler
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/niffler-0.0.2.gem ADDED
Binary file
@@ -3,34 +3,46 @@ require 'json'
3
3
  require 'niffler/maven'
4
4
 
5
5
  describe Niffler::Maven do
6
- describe '#group_query' do
7
- before do
8
- @result = Niffler::Maven.group_query("guice")
9
- end # before
6
+ describe '#group_query' do
7
+ context 'with a valid group name' do
8
+ before do
9
+ @result = Niffler::Maven.group_query("guice")
10
+ end # before
10
11
 
11
- it 'returns a Niffler::Maven object' do
12
- @result.should be_kind_of(Niffler::Maven)
13
- end # it
12
+ it 'returns a Niffler::Maven object' do
13
+ @result.should be_kind_of(Niffler::Maven)
14
+ end # it
14
15
 
15
- it 'returns the group name' do
16
- @result.group.should eq("org.apache.servicemix.bundles")
17
- end # it
16
+ it 'returns the group name' do
17
+ @result.group.should eq("org.apache.servicemix.bundles")
18
+ end # it
18
19
 
19
- it 'returns the artifact name' do
20
- @result.artifact.should eq("org.apache.servicemix.bundles.guice")
21
- end # it
20
+ it 'returns the artifact name' do
21
+ @result.artifact.should eq("org.apache.servicemix.bundles.guice")
22
+ end # it
22
23
 
23
- it 'returns the latest version' do
24
- @result.version.should eq("3.0_1")
25
- end # it
24
+ it 'returns the latest version' do
25
+ @result.version.should eq("3.0_1")
26
+ end # it
26
27
 
27
- it 'returns the repository' do
28
- @result.repository.should eq("central")
29
- end # it
28
+ it 'returns the repository' do
29
+ @result.repository.should eq("central")
30
+ end # it
30
31
 
31
- it 'returns the packaging' do
32
- @result.packaging.should eq("bundle")
33
- end # it
32
+ it 'returns the packaging' do
33
+ @result.packaging.should eq("bundle")
34
+ end # it
35
+ end # context
36
+
37
+ context 'with a fake group name' do
38
+ before do
39
+ @result = Niffler::Maven.group_query("thisisafakegroupname")
40
+ end # before
41
+
42
+ it 'returns nil for a fake name' do
43
+ @result.should be_nil
44
+ end # it
45
+ end # context
34
46
  end # describe
35
47
 
36
48
  describe '#groups_query' do
@@ -46,6 +58,16 @@ describe Niffler::Maven do
46
58
  end # it
47
59
  end # context
48
60
 
61
+ context 'with a fake groups name' do
62
+ before do
63
+ @result = Niffler::Maven.groups_query("thisisafakegroupsname")
64
+ end # before
65
+
66
+ it 'returns an empty array for a fake name' do
67
+ @result.should be_empty
68
+ end # it
69
+ end # context
70
+
49
71
  context 'with a group AND version' do
50
72
  pending "returns correctly when a version is also specified"
51
73
  end # context
@@ -70,6 +92,16 @@ describe Niffler::Maven do
70
92
  @results.last.should be_kind_of(Niffler::Maven)
71
93
  end # it
72
94
  end # context
95
+
96
+ context 'with a fake artifacts name' do
97
+ before do
98
+ @result = Niffler::Maven.artifacts_query("thisisafakeartifactsname")
99
+ end # before
100
+
101
+ it 'returns an empty array for a fake name' do
102
+ @result.should be_empty
103
+ end # it
104
+ end # context
73
105
  end # describe
74
106
 
75
107
  describe '#artifact_query' do
@@ -87,7 +119,7 @@ describe Niffler::Maven do
87
119
  end # it
88
120
 
89
121
  it 'returns the latest version' do
90
- @result.version.should eq("2.10.4")
122
+ @result.version.should eq("2.11.0")
91
123
  end # it
92
124
 
93
125
  it 'returns the repository' do
@@ -98,6 +130,16 @@ describe Niffler::Maven do
98
130
  @result.packaging.should eq("maven-plugin")
99
131
  end # it
100
132
  end # context
133
+
134
+ context 'with a fake artifact name' do
135
+ before do
136
+ @result = Niffler::Maven.artifact_query("thisisafakeartifactname")
137
+ end # before
138
+
139
+ it 'returns nil for a fake name' do
140
+ @result.should be_nil
141
+ end # it
142
+ end # context
101
143
  end # describe
102
144
 
103
145
  describe '#hash_query' do
@@ -122,5 +164,15 @@ describe Niffler::Maven do
122
164
  @result.packaging.should eq("jar")
123
165
  end # it
124
166
  end # context
167
+
168
+ context 'with a fake hash' do
169
+ before do
170
+ @result = Niffler::Maven.hash_query("ffffffffffffffffffffffffffffffffffffffff")
171
+ end
172
+
173
+ it "returns empty if it doesn't exist" do
174
+ @result.should be_nil
175
+ end # it
176
+ end # context
125
177
  end # describe hash
126
178
  end # describe Niffler
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niffler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Carlson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-20 00:00:00.000000000 Z
11
+ date: 2013-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack-client
@@ -137,7 +137,7 @@ files:
137
137
  - lib/niffler.rb
138
138
  - lib/niffler/maven.rb
139
139
  - lib/niffler/version.rb
140
- - niffler-0.0.1.gem
140
+ - niffler-0.0.2.gem
141
141
  - niffler.gemspec
142
142
  - spec/lib/niffler/maven_spec.rb
143
143
  - spec/lib/niffler_spec.rb
data/niffler-0.0.1.gem DELETED
Binary file