dor-fetcher 0.0.1
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.
- checksums.yaml +15 -0
- data/lib/dor-fetcher.rb +84 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
M2FhZDJlMzQwNTBhNTcwYmQxNGI4NGUzNmU4ZTBlMDg4N2RmNTQwZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzQ2ZjdjZDQ0ZTY2YWEyOTA1OWQxMzRjZGI0NGNiYzFkMTVkMGI0Yg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YjE1ZTEyZWUxZDE1M2UwMjM1MWQ4MWZkMzBhNGJmYmFjYzE2YTdkNTM3ZDM0
|
10
|
+
NGM4NzBlZWZhNGM4ZTJkMGMwNDVjNmQ1NTE3ODk3ODBhZjczNmRkYmE4ODMz
|
11
|
+
OGQ4NTk1ZmFmNTE5YWI1M2E0MjZhMmJiZDY2OWZhODVhNzY1MDg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2M1MWU1Mjc0ZjQyNmI1NGQ2NGZiODYxYzJjOTgyZTUzZWE1OWY2Mjc4YWRj
|
14
|
+
ZWMwM2JlN2QwNzgzNTk4YTlkOTM4OThlNjcxNDkxMDZkMzY2NTEyM2M0Zjc4
|
15
|
+
ZTAyZDc0NDU2NGJjNTQ1YjIzZTA0ZTI3NmNkMGVlNDk3YzdkMGI=
|
data/lib/dor-fetcher.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module DorFetcher
|
4
|
+
|
5
|
+
class Client
|
6
|
+
|
7
|
+
@@supported_params = [:first_modified, :last_modified]
|
8
|
+
@@count_only_param = "?rows=0"
|
9
|
+
@@default_service_url = 'http://127.0.0.1:3000'
|
10
|
+
|
11
|
+
#Call me with {:service_url='http://SERVICEURL'}
|
12
|
+
def initialize options = {}
|
13
|
+
#TODO: Check for a well formed URL and a 200 from the destination before just accepting this
|
14
|
+
@service_url = options[:service_url] || @@default_service_url
|
15
|
+
end
|
16
|
+
#options :count_only, :first_modified, :last_modified
|
17
|
+
def get_collection(collection, params = {})
|
18
|
+
return query_api('collection', collection, params)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_count_for_collection(collection, params = {})
|
22
|
+
return query_api('collection', collection, add_count_only_param(params))
|
23
|
+
end
|
24
|
+
|
25
|
+
def list_all_collections
|
26
|
+
return query_api('collection', '', {})
|
27
|
+
end
|
28
|
+
|
29
|
+
def total_collection_count
|
30
|
+
return query_api('collection', '', {:count_only=>true})
|
31
|
+
end
|
32
|
+
|
33
|
+
#options :count_only, :first_modified, :last_modified
|
34
|
+
def get_apo(apo, params= {})
|
35
|
+
return query_api('apo', apo, params)
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_count_for_apo(apo, params={})
|
39
|
+
return query_api('apo', apo, add_count_only_param(params))
|
40
|
+
end
|
41
|
+
|
42
|
+
def list_all_apos
|
43
|
+
return query_api('apo', '', {})
|
44
|
+
end
|
45
|
+
|
46
|
+
def total_apo_count
|
47
|
+
return query_api('apo', '', {:count_only=>true})
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def query_api(base, druid, params)
|
52
|
+
url = "#{@service_url}/#{base}/#{druid}#{add_params(params)}"
|
53
|
+
begin
|
54
|
+
resp = Net::HTTP.get_response(URI.parse(url))
|
55
|
+
rescue
|
56
|
+
raise "Connection Error with url #{url}"
|
57
|
+
end
|
58
|
+
|
59
|
+
return resp.body.to_i if params[:count_only] == true
|
60
|
+
return resp.body
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def add_params(params)
|
65
|
+
args_string = ""
|
66
|
+
|
67
|
+
#Handle Count Only
|
68
|
+
args_string << @@count_only_param if params[:count_only] == true
|
69
|
+
|
70
|
+
@@supported_params.each do |p|
|
71
|
+
args_string << "#?{p.to_s}=#{params[p]}" if params[p] != nil
|
72
|
+
end
|
73
|
+
return args_string
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_count_only_param(params)
|
77
|
+
params.store(:count_only, true)
|
78
|
+
return params
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dor-fetcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carrick Rogers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Wrapped for the Dor Fetcher Services restful api.
|
14
|
+
email: carrickr@stanford.edu
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dor-fetcher.rb
|
20
|
+
homepage: http://www.stanford.edu
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.1.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: DorFetcher Gem
|
43
|
+
test_files: []
|
44
|
+
has_rdoc:
|