edanrb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/lib/edan.rb +40 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWViZDA3OTVkMWEyY2VjMGM3N2RlZTcxZGI4OGYxYjNlNWFlMmY2MA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjBlYTYyZjdlZDJjOWJlNDJjYzBhNGZmNDAzOTc5Y2M2MTUzMzM2Mg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YTk5YzRjODk0ZWM3MmQ2MzZhNThkNTg1ZWNlNWQ2ZWMyMzIxMThkZGFlMDVk
|
10
|
+
YmEyYzJlYmI4ZTZiYWZiZDQ1YzY1Nzc2OGZkMWU2MzdhNTc3YzBjZjJhNGJh
|
11
|
+
NzZhZTlmNzkwNzI1ZjY3NWQ4NzkwODNmYmZjN2MzZjU0MTQ4NDU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YmIzNmRiYTJiYjE0NDBkNjlkMjEzOTlkMWY5NDg0YTdjOTUxODA2ZjIzMWU0
|
14
|
+
ZWMzYThhMjU1NjZhZDdlZDg3ZDk2MDllZWZhZTk1OWVmNGFhNjJhN2RiYmMw
|
15
|
+
OTE4NzI2NWQ5NGUyN2JmMmNiNTYwYzVkNTU5MWJiNTMyOWZlNDY=
|
data/lib/edan.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# (c) 2013 Smithsonian Institution.
|
3
|
+
# Use subject to license terms.
|
4
|
+
|
5
|
+
require "net/http"
|
6
|
+
|
7
|
+
class EDANQuery
|
8
|
+
attr_accessor :server, :app_id, :username, :password
|
9
|
+
|
10
|
+
def warn_if_empty(var, var_name)
|
11
|
+
puts "please provide a value for #{var_name}" if var.nil? || var.empty?
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(app_id, options = {})
|
15
|
+
warn_if_empty(app_id, "app_id")
|
16
|
+
|
17
|
+
@server = options[:server] || 'http://edan-api.si.edu'
|
18
|
+
@app_id = app_id
|
19
|
+
|
20
|
+
@username = ENV['EDANUSER']
|
21
|
+
warn_if_empty(@username, "ENV['EDANUSER']")
|
22
|
+
|
23
|
+
@password = ENV['EDANPASS']
|
24
|
+
warn_if_empty(@password, "ENV['EDANPASS']")
|
25
|
+
end
|
26
|
+
|
27
|
+
def request(params="start=0", service="/metadataService")
|
28
|
+
#puts "==> #{username} #{password}"
|
29
|
+
uri = URI.parse(server + service + '?' + params)
|
30
|
+
|
31
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
32
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
33
|
+
request.basic_auth(username, password)
|
34
|
+
request['X-AppId'] = app_id
|
35
|
+
response = http.request(request)
|
36
|
+
return response;
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: edanrb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sarah Allen
|
8
|
+
- Andrew Gunther
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: a simple library to get data from Smithsonian EDAN API
|
15
|
+
email: allensa@si.edu
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/edan.rb
|
21
|
+
homepage: https://github.com/Smithsonian/edanrb
|
22
|
+
licenses:
|
23
|
+
- https://github.com/Smithsonian/edanrb/blob/master/license.md
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.0.4
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Smithsonian EDAN API
|
45
|
+
test_files: []
|