datacatalog 0.3.6 → 0.3.7
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.
- data/Rakefile +1 -1
- data/datacatalog.gemspec +2 -2
- data/lib/base.rb +7 -1
- data/lib/resources/favorite.rb +1 -1
- data/lib/resources/source.rb +7 -7
- data/spec/base_spec.rb +9 -5
- data/spec/favorite_spec.rb +10 -6
- metadata +2 -2
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "datacatalog"
|
8
|
-
gem.version = '0.3.
|
8
|
+
gem.version = '0.3.7'
|
9
9
|
gem.rubyforge_project = "datacatalog"
|
10
10
|
gem.summary = %Q{Client for the National Data Catalog API}
|
11
11
|
gem.description = %Q{A Ruby client library for the National Data Catalog API}
|
data/datacatalog.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{datacatalog}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Luigi Montanez", "David James"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-12-01}
|
13
13
|
s.description = %q{A Ruby client library for the National Data Catalog API}
|
14
14
|
s.email = %q{luigi@sunlightfoundation.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/base.rb
CHANGED
@@ -78,7 +78,13 @@ module DataCatalog
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.filterize(conditions)
|
81
|
-
conditions.map
|
81
|
+
conditions.map do |k, v|
|
82
|
+
"#{k}" + if v.is_a?(Regexp)
|
83
|
+
%(:"#{v.source}")
|
84
|
+
else
|
85
|
+
%(="#{v}")
|
86
|
+
end
|
87
|
+
end.join(" ")
|
82
88
|
end
|
83
89
|
|
84
90
|
def method_missing(method_name, *args)
|
data/lib/resources/favorite.rb
CHANGED
data/lib/resources/source.rb
CHANGED
@@ -5,11 +5,11 @@ module DataCatalog
|
|
5
5
|
def self.all(conditions={})
|
6
6
|
many(http_get(uri, :query => query_hash(conditions)))
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def self.search(term)
|
10
|
-
many(http_get(uri, :query => {:search => term.downcase}))
|
10
|
+
many(http_get(uri, :query => { :search => term.downcase }))
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def self.create(params={})
|
14
14
|
one(http_post(uri, :body => params))
|
15
15
|
end
|
@@ -17,21 +17,21 @@ module DataCatalog
|
|
17
17
|
def self.destroy(id)
|
18
18
|
one(http_delete(uri(id)))
|
19
19
|
end
|
20
|
-
|
21
|
-
def self.first(conditions=
|
20
|
+
|
21
|
+
def self.first(conditions={})
|
22
22
|
one(http_get(uri, :query => query_hash(conditions)).first)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.get(id)
|
26
26
|
one(http_get(uri(id)))
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def self.update(id, params={})
|
30
30
|
one(http_put(uri(id), :body => params))
|
31
31
|
end
|
32
32
|
|
33
33
|
# == Helpers
|
34
|
-
|
34
|
+
|
35
35
|
def self.uri(id=nil)
|
36
36
|
"/sources/#{id}"
|
37
37
|
end
|
data/spec/base_spec.rb
CHANGED
@@ -127,14 +127,18 @@ describe Base do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
describe ".filterize" do
|
130
|
-
it "should work with 1 param" do
|
131
|
-
%(name
|
130
|
+
it "should work with 1 string param" do
|
131
|
+
%(name="John Doe").should == Base.filterize(:name => "John Doe")
|
132
132
|
end
|
133
133
|
|
134
|
-
it "should work with
|
134
|
+
it "should work with 1 regex param" do
|
135
|
+
%(name:"John Doe").should == Base.filterize(:name => /John Doe/)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should work with 2 string params" do
|
135
139
|
[
|
136
|
-
%(zip
|
137
|
-
%(name
|
140
|
+
%(zip="20036" name="John Doe"),
|
141
|
+
%(name="John Doe" zip="20036")
|
138
142
|
].should include(Base.filterize(:name => "John Doe", :zip => "20036"))
|
139
143
|
end
|
140
144
|
end
|
data/spec/favorite_spec.rb
CHANGED
@@ -7,12 +7,16 @@ describe Favorite do
|
|
7
7
|
setup_api
|
8
8
|
clean_slate
|
9
9
|
|
10
|
-
@user = User.create(
|
11
|
-
|
10
|
+
@user = User.create(
|
11
|
+
:name => "Ted Smith",
|
12
|
+
:email => "ted@email.com"
|
13
|
+
)
|
12
14
|
|
13
|
-
@source = Source.create(
|
14
|
-
|
15
|
-
|
15
|
+
@source = Source.create(
|
16
|
+
:title => "Some FCC Data",
|
17
|
+
:url => "http://fcc.gov/somedata.csv",
|
18
|
+
:source_type => "dataset"
|
19
|
+
)
|
16
20
|
|
17
21
|
DataCatalog.with_key(@user.primary_api_key) do
|
18
22
|
@favorite = Favorite.create(:source_id => @source.id)
|
@@ -22,7 +26,7 @@ describe Favorite do
|
|
22
26
|
|
23
27
|
describe ".create" do
|
24
28
|
|
25
|
-
it "should create a favorite when valid params are passed in" do
|
29
|
+
it "should create a favorite when valid params are passed in" do
|
26
30
|
refreshed_user = User.get(@user.id)
|
27
31
|
refreshed_user.favorites.first.title.should == "Some FCC Data"
|
28
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datacatalog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luigi Montanez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-12-01 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|