datacatalog 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +11 -11
- data/README.md +34 -34
- data/Rakefile +1 -1
- data/datacatalog.gemspec +2 -2
- data/lib/main.rb +41 -41
- data/sandbox_api.yml.example +2 -2
- data/spec/datacatalog_spec.rb +36 -36
- metadata +2 -2
data/LICENSE.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
Copyright (c) 2009, Sunlight Foundation.
|
2
|
-
|
3
|
-
All rights reserved.
|
4
|
-
|
5
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
6
|
-
|
7
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
9
|
-
* Neither the name of Sunlight Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
-
|
11
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
1
|
+
Copyright (c) 2009, Sunlight Foundation.
|
2
|
+
|
3
|
+
All rights reserved.
|
4
|
+
|
5
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
9
|
+
* Neither the name of Sunlight Foundation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
10
|
+
|
11
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
# Ruby Gem for the National Data Catalog API
|
2
|
-
|
3
|
-
Under heavy development.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
For now, the gem will not be packaged. Instead, install it manually:
|
8
|
-
|
9
|
-
$ git clone git clone git://github.com/sunlightlabs/ruby-datacatalog.git
|
10
|
-
$ cd ruby-datacatalog
|
11
|
-
$ rake check_dependencies
|
12
|
-
$ rake build
|
13
|
-
$ rake install # uses sudo
|
14
|
-
# Or, instead of the line above:
|
15
|
-
$ gem install pkg/datacatalog-0.1.0.gem
|
16
|
-
|
17
|
-
## Usage
|
18
|
-
|
19
|
-
require 'rubygems'
|
20
|
-
require 'datacatalog'
|
21
|
-
|
22
|
-
DataCatalog.api_key = 'c40505247a5e308a24d70a0118f76534b543795b'
|
23
|
-
|
24
|
-
## Running Specs
|
25
|
-
|
26
|
-
We're not mocking out any of the web API calls in the specs. Instead, we expect developers who wish to run the specs to download and run a local sandbox instance of the [Data Catalog API](http://github.com/sunlightlabs/datacatalog-api), a Sinatra app:
|
27
|
-
|
28
|
-
git clone git://github.com/sunlightlabs/datacatalog-api.git
|
29
|
-
|
30
|
-
Get the app running like any normal Sinatra app, so you can choose to use thin or Passenger or new hotness like [Unicorn](http://unicorn.bogomips.org/). Some special considerations:
|
31
|
-
|
32
|
-
1. We recommend creating a `sandbox` entry in `datacatalog-api`'s `config.yml`.
|
33
|
-
2. Run `RACK_ENV=sandbox rake db:ensure_admin` in the `datacatalog-api` project to create a super admin for the API instance.
|
34
|
-
3. Back here in `ruby-datacatalog`, use the example file in `spec/` to create your own `spec/sandbox_api.yml` with the API key of the admin and your local URI.
|
1
|
+
# Ruby Gem for the National Data Catalog API
|
2
|
+
|
3
|
+
Under heavy development.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
For now, the gem will not be packaged. Instead, install it manually:
|
8
|
+
|
9
|
+
$ git clone git clone git://github.com/sunlightlabs/ruby-datacatalog.git
|
10
|
+
$ cd ruby-datacatalog
|
11
|
+
$ rake check_dependencies
|
12
|
+
$ rake build
|
13
|
+
$ rake install # uses sudo
|
14
|
+
# Or, instead of the line above:
|
15
|
+
$ gem install pkg/datacatalog-0.1.0.gem
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'datacatalog'
|
21
|
+
|
22
|
+
DataCatalog.api_key = 'c40505247a5e308a24d70a0118f76534b543795b'
|
23
|
+
|
24
|
+
## Running Specs
|
25
|
+
|
26
|
+
We're not mocking out any of the web API calls in the specs. Instead, we expect developers who wish to run the specs to download and run a local sandbox instance of the [Data Catalog API](http://github.com/sunlightlabs/datacatalog-api), a Sinatra app:
|
27
|
+
|
28
|
+
git clone git://github.com/sunlightlabs/datacatalog-api.git
|
29
|
+
|
30
|
+
Get the app running like any normal Sinatra app, so you can choose to use thin or Passenger or new hotness like [Unicorn](http://unicorn.bogomips.org/). Some special considerations:
|
31
|
+
|
32
|
+
1. We recommend creating a `sandbox` entry in `datacatalog-api`'s `config.yml`.
|
33
|
+
2. Run `RACK_ENV=sandbox rake db:ensure_admin` in the `datacatalog-api` project to create a super admin for the API instance.
|
34
|
+
3. Back here in `ruby-datacatalog`, use the example file in `spec/` to create your own `spec/sandbox_api.yml` with the API key of the admin and your local URI.
|
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.4.
|
8
|
+
gem.version = '0.4.3'
|
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.4.
|
8
|
+
s.version = "0.4.3"
|
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-
|
12
|
+
s.date = %q{2009-12-09}
|
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/main.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
module DataCatalog
|
2
|
-
|
3
|
-
# == Exceptions
|
4
|
-
|
5
|
-
class Error < RuntimeError; end
|
6
|
-
class BadRequest < Error; end # 400
|
7
|
-
class Unauthorized < Error; end # 401
|
8
|
-
class Forbidden < Error; end # 403
|
9
|
-
class NotFound < Error; end # 404
|
10
|
-
class Conflict < Error; end # 409
|
11
|
-
class InternalServerError < Error; end # 500
|
12
|
-
class ApiKeyNotConfigured < Error; end
|
13
|
-
class CannotDeletePrimaryApiKey < Error; end
|
14
|
-
|
15
|
-
# == Accessors
|
16
|
-
|
17
|
-
def self.api_key
|
18
|
-
Base.default_params[:api_key]
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.api_key=(key)
|
22
|
-
Base.default_params :api_key => key
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.base_uri
|
26
|
-
Base.base_uri
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.base_uri=(uri)
|
30
|
-
Base.base_uri(uri.blank? ? Base::DEFAULT_BASE_URI : uri)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.with_key(temp_key)
|
34
|
-
original_key = DataCatalog.api_key
|
35
|
-
DataCatalog.api_key = temp_key
|
36
|
-
result = yield
|
37
|
-
DataCatalog.api_key = original_key
|
38
|
-
result
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
1
|
+
module DataCatalog
|
2
|
+
|
3
|
+
# == Exceptions
|
4
|
+
|
5
|
+
class Error < RuntimeError; end
|
6
|
+
class BadRequest < Error; end # 400
|
7
|
+
class Unauthorized < Error; end # 401
|
8
|
+
class Forbidden < Error; end # 403
|
9
|
+
class NotFound < Error; end # 404
|
10
|
+
class Conflict < Error; end # 409
|
11
|
+
class InternalServerError < Error; end # 500
|
12
|
+
class ApiKeyNotConfigured < Error; end
|
13
|
+
class CannotDeletePrimaryApiKey < Error; end
|
14
|
+
|
15
|
+
# == Accessors
|
16
|
+
|
17
|
+
def self.api_key
|
18
|
+
Base.default_params[:api_key]
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.api_key=(key)
|
22
|
+
Base.default_params :api_key => key
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.base_uri
|
26
|
+
Base.base_uri
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.base_uri=(uri)
|
30
|
+
Base.base_uri(uri.blank? ? Base::DEFAULT_BASE_URI : uri)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.with_key(temp_key)
|
34
|
+
original_key = DataCatalog.api_key
|
35
|
+
DataCatalog.api_key = temp_key
|
36
|
+
result = yield
|
37
|
+
DataCatalog.api_key = original_key
|
38
|
+
result
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/sandbox_api.yml.example
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
api_key: d193d1523d49e4caf46297ef94d7a2c995d3b2cb # generate with rake db:ensure_admin on datacatalog-api
|
2
|
-
base_uri: sandbox.dc-api.local
|
1
|
+
api_key: d193d1523d49e4caf46297ef94d7a2c995d3b2cb # generate with rake db:ensure_admin on datacatalog-api
|
2
|
+
base_uri: sandbox.dc-api.local
|
data/spec/datacatalog_spec.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
include DataCatalog
|
3
|
-
|
4
|
-
describe DataCatalog do
|
5
|
-
|
6
|
-
describe "module accessors" do
|
7
|
-
it "should access the API Key" do
|
8
|
-
DataCatalog.api_key = "4159179f32ff8fefd2c6d48b7e675e7736bf1357"
|
9
|
-
DataCatalog.api_key.should == "4159179f32ff8fefd2c6d48b7e675e7736bf1357"
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should access the base URI" do
|
13
|
-
DataCatalog.base_uri = 'http://somehost.com'
|
14
|
-
DataCatalog.base_uri.should == 'http://somehost.com'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe ".with_key" do
|
19
|
-
it "should set the API key within the block" do
|
20
|
-
regular_key = '4159179f32ff8fefd2c6d48b7e675e7736bf1357'
|
21
|
-
DataCatalog.api_key = regular_key
|
22
|
-
temporary_key = '0000123400001234000012340000123400001234'
|
23
|
-
DataCatalog.with_key(temporary_key) do
|
24
|
-
DataCatalog.api_key.should == temporary_key
|
25
|
-
end
|
26
|
-
DataCatalog.api_key.should == regular_key
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return the last value in the block" do
|
30
|
-
DataCatalog.with_key("0000444400004444") do
|
31
|
-
42
|
32
|
-
end.should == 42
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
include DataCatalog
|
3
|
+
|
4
|
+
describe DataCatalog do
|
5
|
+
|
6
|
+
describe "module accessors" do
|
7
|
+
it "should access the API Key" do
|
8
|
+
DataCatalog.api_key = "4159179f32ff8fefd2c6d48b7e675e7736bf1357"
|
9
|
+
DataCatalog.api_key.should == "4159179f32ff8fefd2c6d48b7e675e7736bf1357"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should access the base URI" do
|
13
|
+
DataCatalog.base_uri = 'http://somehost.com'
|
14
|
+
DataCatalog.base_uri.should == 'http://somehost.com'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe ".with_key" do
|
19
|
+
it "should set the API key within the block" do
|
20
|
+
regular_key = '4159179f32ff8fefd2c6d48b7e675e7736bf1357'
|
21
|
+
DataCatalog.api_key = regular_key
|
22
|
+
temporary_key = '0000123400001234000012340000123400001234'
|
23
|
+
DataCatalog.with_key(temporary_key) do
|
24
|
+
DataCatalog.api_key.should == temporary_key
|
25
|
+
end
|
26
|
+
DataCatalog.api_key.should == regular_key
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should return the last value in the block" do
|
30
|
+
DataCatalog.with_key("0000444400004444") do
|
31
|
+
42
|
32
|
+
end.should == 42
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
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.4.
|
4
|
+
version: 0.4.3
|
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-12-
|
13
|
+
date: 2009-12-09 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|