datacatalog 0.4.15 → 0.4.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/Rakefile +6 -6
- data/datacatalog.gemspec +20 -17
- data/lib/base.rb +8 -8
- data/lib/cursor.rb +16 -12
- data/lib/main.rb +8 -8
- data/lib/resources/about.rb +4 -4
- data/lib/resources/api_key.rb +5 -5
- data/lib/resources/broken_link.rb +33 -0
- data/lib/resources/comment.rb +4 -4
- data/lib/resources/document.rb +2 -2
- data/lib/resources/download.rb +2 -2
- data/lib/resources/favorite.rb +3 -3
- data/lib/resources/import.rb +2 -2
- data/lib/resources/importer.rb +2 -2
- data/lib/resources/note.rb +2 -2
- data/lib/resources/organization.rb +1 -1
- data/lib/resources/rating.rb +4 -4
- data/lib/resources/report.rb +4 -4
- data/lib/resources/source.rb +2 -2
- data/lib/resources/user.rb +9 -9
- data/spec/about_spec.rb +5 -5
- data/spec/api_key_spec.rb +12 -12
- data/spec/base_spec.rb +16 -16
- data/spec/comment_spec.rb +9 -9
- data/spec/datacatalog_spec.rb +2 -2
- data/spec/document_spec.rb +18 -18
- data/spec/download_spec.rb +10 -10
- data/spec/empty_spec.rb +61 -0
- data/spec/favorite_spec.rb +14 -14
- data/spec/import_spec.rb +5 -5
- data/spec/importer_spec.rb +5 -5
- data/spec/note_spec.rb +16 -16
- data/spec/organization_spec.rb +20 -20
- data/spec/rating_spec.rb +20 -20
- data/spec/report_spec.rb +11 -11
- data/spec/source_spec.rb +26 -26
- data/spec/spec_helper.rb +10 -3
- data/spec/user_spec.rb +23 -23
- data/tasks/test_api.rake +3 -3
- metadata +20 -17
data/spec/source_spec.rb
CHANGED
@@ -20,7 +20,7 @@ module SourceHelpers
|
|
20
20
|
})
|
21
21
|
end
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def create_30_sources
|
25
25
|
(1..30).each do |n|
|
26
26
|
Source.create({
|
@@ -45,31 +45,31 @@ describe Source do
|
|
45
45
|
create_3_sources
|
46
46
|
@sources = Source.all
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should return an Enumerable object" do
|
50
50
|
@sources.is_a?(Enumerable).should == true
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should return an enumeration of sources" do
|
54
54
|
@sources.each do |source|
|
55
55
|
source.should be_an_instance_of(Source)
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "should return correct titles" do
|
60
60
|
expected = ["FCC Data", "NASA Data", "DOE Data"]
|
61
61
|
@sources.map(&:title).sort.should == expected.sort
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
|
64
|
+
|
65
65
|
describe "with cursor" do
|
66
|
-
|
66
|
+
|
67
67
|
it "should raise an error on bad index" do
|
68
68
|
executing do
|
69
69
|
@sources.page(0)
|
70
70
|
end.should raise_error(RuntimeError)
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
it "should return 20 objects when there are more than 20" do
|
74
74
|
create_30_sources
|
75
75
|
sources = Source.all
|
@@ -77,7 +77,7 @@ describe Source do
|
|
77
77
|
sources.page(1).size.should == 20
|
78
78
|
sources.page(2).size.should == 13
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
@@ -86,38 +86,38 @@ describe Source do
|
|
86
86
|
create_3_sources
|
87
87
|
@sources = Source.all(:title => "NASA Data")
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
it "should return an enumeration of sources" do
|
91
91
|
@sources.each do |source|
|
92
92
|
source.should be_an_instance_of(Source)
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
it "should return correct titles" do
|
97
97
|
expected = ["NASA Data"]
|
98
98
|
@sources.map(&:title).sort.should == expected.sort
|
99
99
|
end
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
describe ".search" do
|
103
103
|
before do
|
104
104
|
create_3_sources
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
it "should return correct search result" do
|
108
108
|
@sources = Source.search("FCC")
|
109
109
|
@sources.size.should == 1
|
110
110
|
@sources.first.title.should == "FCC Data"
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
describe ".create" do
|
115
115
|
it "should create a new source from basic params" do
|
116
116
|
source = create_source
|
117
117
|
source.should be_an_instance_of(Source)
|
118
118
|
source.url.should == "http://fcc.gov/somedata.csv"
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
it "should create a new source from custom params" do
|
122
122
|
source = create_source({ :custom => {
|
123
123
|
"0" => {
|
@@ -139,47 +139,47 @@ describe Source do
|
|
139
139
|
}
|
140
140
|
end
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
describe ".first" do
|
144
144
|
before do
|
145
145
|
create_3_sources
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
it "should return a source" do
|
149
149
|
source = Source.first(:title => "NASA Data")
|
150
150
|
source.should be_an_instance_of(Source)
|
151
151
|
source.title.should == "NASA Data"
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
it "should return nil if nothing found" do
|
155
155
|
source = Source.first(:title => "UFO Data")
|
156
156
|
source.should be_nil
|
157
157
|
end
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
describe ".get" do
|
161
161
|
before do
|
162
162
|
@source = create_source
|
163
163
|
end
|
164
|
-
|
164
|
+
|
165
165
|
it "should return a source" do
|
166
166
|
source = Source.get(@source.id)
|
167
167
|
source.should be_an_instance_of(Source)
|
168
168
|
source.title.should == "Some FCC Data"
|
169
169
|
end
|
170
|
-
|
170
|
+
|
171
171
|
it "should raise NotFound if no source exists" do
|
172
172
|
executing do
|
173
173
|
Source.get(mangle(@source.id))
|
174
174
|
end.should raise_error(NotFound)
|
175
175
|
end
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
describe ".update" do
|
179
179
|
before do
|
180
180
|
@source = create_source
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
it "should update an existing source from valid params" do
|
184
184
|
source = Source.update(@source.id, {
|
185
185
|
:url => "http://fec.gov/newdata.csv"
|
@@ -188,17 +188,17 @@ describe Source do
|
|
188
188
|
source.url.should == "http://fec.gov/newdata.csv"
|
189
189
|
end
|
190
190
|
end
|
191
|
-
|
191
|
+
|
192
192
|
describe ".destroy" do
|
193
193
|
before do
|
194
194
|
@source = create_source
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
it "should destroy an existing source" do
|
198
198
|
result = Source.destroy(@source.id)
|
199
199
|
result.should be_true
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
it "should raise NotFound when attempting to destroy non-existing source" do
|
203
203
|
executing do
|
204
204
|
Source.destroy(mangle(@source.id))
|
data/spec/spec_helper.rb
CHANGED
@@ -8,10 +8,17 @@ end
|
|
8
8
|
alias :executing :lambda
|
9
9
|
|
10
10
|
KLASSES = [
|
11
|
-
DataCatalog::
|
12
|
-
DataCatalog::
|
13
|
-
DataCatalog::
|
11
|
+
DataCatalog::Comment,
|
12
|
+
DataCatalog::Document,
|
13
|
+
DataCatalog::Download,
|
14
|
+
DataCatalog::Favorite,
|
14
15
|
DataCatalog::Import,
|
16
|
+
DataCatalog::Importer,
|
17
|
+
DataCatalog::Note,
|
18
|
+
DataCatalog::Organization,
|
19
|
+
DataCatalog::Rating,
|
20
|
+
DataCatalog::Report,
|
21
|
+
DataCatalog::Source,
|
15
22
|
]
|
16
23
|
|
17
24
|
def clean_slate
|
data/spec/user_spec.rb
CHANGED
@@ -7,8 +7,8 @@ module UserHelpers
|
|
7
7
|
:name => "Ted Smith",
|
8
8
|
:email => "ted@email.com"
|
9
9
|
})
|
10
|
-
end
|
11
|
-
|
10
|
+
end
|
11
|
+
|
12
12
|
def create_user_with_2_keys
|
13
13
|
user = create_user
|
14
14
|
result = user.generate_api_key!(
|
@@ -19,7 +19,7 @@ module UserHelpers
|
|
19
19
|
raise "incorrect number of keys" unless user.api_keys.length == 2
|
20
20
|
user
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def create_3_users
|
24
24
|
3.times do |n|
|
25
25
|
User.create(
|
@@ -32,7 +32,7 @@ end
|
|
32
32
|
|
33
33
|
describe User do
|
34
34
|
include UserHelpers
|
35
|
-
|
35
|
+
|
36
36
|
before do
|
37
37
|
setup_api
|
38
38
|
clean_slate
|
@@ -43,13 +43,13 @@ describe User do
|
|
43
43
|
create_3_users
|
44
44
|
@users = User.all
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should return an enumeration of users" do
|
48
48
|
@users.each do |u|
|
49
49
|
u.should be_an_instance_of(User)
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
it "should include four users" do
|
54
54
|
names = @users.map(&:name)
|
55
55
|
names.should include("User-0")
|
@@ -76,7 +76,7 @@ describe User do
|
|
76
76
|
end.should raise_error(BadRequest)
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
describe ".first" do
|
81
81
|
before do
|
82
82
|
create_3_users
|
@@ -87,18 +87,18 @@ describe User do
|
|
87
87
|
user.should be_an_instance_of(User)
|
88
88
|
user.name.should == "User-1"
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
it "should return nil if nothing found" do
|
92
92
|
user = User.first(:name => "Elvis")
|
93
93
|
user.should be_nil
|
94
94
|
end
|
95
95
|
end
|
96
|
-
|
96
|
+
|
97
97
|
describe ".get_by_api_key" do
|
98
98
|
before do
|
99
99
|
@user = create_user
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "should return a user" do
|
103
103
|
user = User.get_by_api_key(@user.primary_api_key)
|
104
104
|
user.should be_an_instance_of(User)
|
@@ -110,7 +110,7 @@ describe User do
|
|
110
110
|
before do
|
111
111
|
@user = create_user_with_2_keys
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
describe "user exists" do
|
115
115
|
before do
|
116
116
|
@u = User.get(@user.id)
|
@@ -130,7 +130,7 @@ describe User do
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
it "should raise NotFound if no user exists" do
|
135
135
|
executing do
|
136
136
|
User.get(mangle(@user.id))
|
@@ -142,7 +142,7 @@ describe User do
|
|
142
142
|
before do
|
143
143
|
@user = create_user_with_2_keys
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
describe "API key exists" do
|
147
147
|
before do
|
148
148
|
@u = User.get_by_api_key(@user.primary_api_key)
|
@@ -174,7 +174,7 @@ describe User do
|
|
174
174
|
before do
|
175
175
|
@user = create_user
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
it "should update a user when valid params are passed in" do
|
179
179
|
user = User.update(@user.id, { :name => "Jane Smith" })
|
180
180
|
user.name.should == "Jane Smith"
|
@@ -186,7 +186,7 @@ describe User do
|
|
186
186
|
end.should raise_error(BadRequest)
|
187
187
|
end
|
188
188
|
end
|
189
|
-
|
189
|
+
|
190
190
|
describe ".destroy" do
|
191
191
|
before do
|
192
192
|
@user = create_user
|
@@ -196,7 +196,7 @@ describe User do
|
|
196
196
|
result = User.destroy(@user.id)
|
197
197
|
result.should be_true
|
198
198
|
end
|
199
|
-
|
199
|
+
|
200
200
|
it "should raise NotFound when non-existing user" do
|
201
201
|
executing do
|
202
202
|
User.destroy(mangle(@user.id))
|
@@ -219,7 +219,7 @@ describe User do
|
|
219
219
|
@user.api_keys.last[:purpose].should == "Civic hacking with my awesome app"
|
220
220
|
@user.application_api_keys.length.should == 1
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
it "should raise BadRequest when attempting to create a primary key" do
|
224
224
|
executing do
|
225
225
|
@user.generate_api_key!({
|
@@ -229,12 +229,12 @@ describe User do
|
|
229
229
|
end.should raise_error(BadRequest)
|
230
230
|
end
|
231
231
|
end
|
232
|
-
|
232
|
+
|
233
233
|
describe "#update_api_key!" do
|
234
234
|
before do
|
235
235
|
@user = create_user_with_2_keys
|
236
236
|
end
|
237
|
-
|
237
|
+
|
238
238
|
it "should update a key for the user" do
|
239
239
|
@user.update_api_key!(@user.api_keys[1].id, {
|
240
240
|
:key_type => "valet",
|
@@ -242,7 +242,7 @@ describe User do
|
|
242
242
|
}).should be_true
|
243
243
|
@user.api_keys[1].purpose.should == "To be more awesome"
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
it "should raise NotFound if updating a key that doesn't exist" do
|
247
247
|
executing do
|
248
248
|
@user.update_api_key!(mangle(@user.api_keys[1].id), {})
|
@@ -262,12 +262,12 @@ describe User do
|
|
262
262
|
before do
|
263
263
|
@user = create_user_with_2_keys
|
264
264
|
end
|
265
|
-
|
265
|
+
|
266
266
|
it "should delete a key for the user" do
|
267
267
|
@user.delete_api_key!(@user.api_keys[1].id).should be_true
|
268
268
|
@user.api_keys.length.should == 1
|
269
269
|
end
|
270
|
-
|
270
|
+
|
271
271
|
it "should raise Conflict if deleting the primary key" do
|
272
272
|
executing do
|
273
273
|
@user.delete_api_key!(@user.api_keys[0].id)
|
@@ -275,5 +275,5 @@ describe User do
|
|
275
275
|
@user.api_keys.length.should == 2
|
276
276
|
end
|
277
277
|
end
|
278
|
-
|
278
|
+
|
279
279
|
end
|
data/tasks/test_api.rake
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 16
|
9
|
+
version: 0.4.16
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Luigi Montanez
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-08-10 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -28,8 +28,8 @@ dependencies:
|
|
28
28
|
segments:
|
29
29
|
- 2
|
30
30
|
- 3
|
31
|
-
-
|
32
|
-
version: 2.3.
|
31
|
+
- 8
|
32
|
+
version: 2.3.8
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -41,9 +41,9 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
segments:
|
43
43
|
- 0
|
44
|
-
-
|
45
|
-
-
|
46
|
-
version: 0.
|
44
|
+
- 6
|
45
|
+
- 1
|
46
|
+
version: 0.6.1
|
47
47
|
type: :runtime
|
48
48
|
version_requirements: *id002
|
49
49
|
- !ruby/object:Gem::Dependency
|
@@ -55,9 +55,9 @@ dependencies:
|
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
segments:
|
57
57
|
- 0
|
58
|
-
-
|
59
|
-
-
|
60
|
-
version: 0.
|
58
|
+
- 1
|
59
|
+
- 1
|
60
|
+
version: 0.1.1
|
61
61
|
type: :runtime
|
62
62
|
version_requirements: *id003
|
63
63
|
- !ruby/object:Gem::Dependency
|
@@ -83,9 +83,9 @@ dependencies:
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
segments:
|
85
85
|
- 1
|
86
|
-
-
|
87
|
-
-
|
88
|
-
version: 1.
|
86
|
+
- 4
|
87
|
+
- 0
|
88
|
+
version: 1.4.0
|
89
89
|
type: :development
|
90
90
|
version_requirements: *id005
|
91
91
|
- !ruby/object:Gem::Dependency
|
@@ -97,9 +97,9 @@ dependencies:
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
segments:
|
99
99
|
- 1
|
100
|
-
-
|
101
|
-
-
|
102
|
-
version: 1.
|
100
|
+
- 3
|
101
|
+
- 0
|
102
|
+
version: 1.3.0
|
103
103
|
type: :development
|
104
104
|
version_requirements: *id006
|
105
105
|
description: A Ruby client library for the National Data Catalog API
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/main.rb
|
125
125
|
- lib/resources/about.rb
|
126
126
|
- lib/resources/api_key.rb
|
127
|
+
- lib/resources/broken_link.rb
|
127
128
|
- lib/resources/comment.rb
|
128
129
|
- lib/resources/document.rb
|
129
130
|
- lib/resources/download.rb
|
@@ -144,6 +145,7 @@ files:
|
|
144
145
|
- spec/datacatalog_spec.rb
|
145
146
|
- spec/document_spec.rb
|
146
147
|
- spec/download_spec.rb
|
148
|
+
- spec/empty_spec.rb
|
147
149
|
- spec/favorite_spec.rb
|
148
150
|
- spec/import_spec.rb
|
149
151
|
- spec/importer_spec.rb
|
@@ -197,6 +199,7 @@ test_files:
|
|
197
199
|
- spec/datacatalog_spec.rb
|
198
200
|
- spec/document_spec.rb
|
199
201
|
- spec/download_spec.rb
|
202
|
+
- spec/empty_spec.rb
|
200
203
|
- spec/favorite_spec.rb
|
201
204
|
- spec/import_spec.rb
|
202
205
|
- spec/importer_spec.rb
|