hunting 0.1.0
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 +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +176 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/hunting.gemspec +37 -0
- data/lib/hunting.rb +68 -0
- data/lib/hunting/collection.rb +79 -0
- data/lib/hunting/digital_object.rb +60 -0
- data/lib/hunting/repository.rb +55 -0
- data/lib/hunting/version.rb +3 -0
- metadata +146 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 985ecd9b9ff22857ff96540f6682951f184a9f58
|
4
|
+
data.tar.gz: 0afce070647cc90787be5c34ef6056199334e1dc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d04eb9c9cf14f4529ede74869923d4acef0380e2bebf5aa9c89c5be38dfc6444035628428b8c538c5f59de83d43e644ed229cf01c3cc8c82df492e0bfbf0339c
|
7
|
+
data.tar.gz: f1edb2af2252c180b191c389b6d3bfeacb6ded1a1bb1bf91a6ae1f03fd0b9412850249722bece005c17bdd9b2d9be8acce947a6bf1e3c38e1d6178ad0d4dca3a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# Hunting
|
2
|
+
|
3
|
+
Hunting is a Ruby wrapper for the CONTENTdm API. Quickly 'Scout' for collections and objects in your Repository, 'Hunt' for metadata in your Collections, and 'Trap' individual Digital Objects.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
__This gem has not yet been published to RubyGems. Please use the Dev Installation instructions below after cloning the repository.__
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'hunting'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install hunting
|
22
|
+
|
23
|
+
### Dev Installation
|
24
|
+
|
25
|
+
$ bundle install
|
26
|
+
$ gem build hunting.gemspec
|
27
|
+
$ gem install .\hunting-0.1.0.gem
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'hunting'
|
33
|
+
```
|
34
|
+
|
35
|
+
### Configuration
|
36
|
+
Hunting depends on configuration data, passed as either a hash or a yaml file, for local CONTENTdm system attributes, collections, and metadata fields.
|
37
|
+
|
38
|
+
#### With Hash
|
39
|
+
```ruby
|
40
|
+
Hunting.configure(hash)
|
41
|
+
```
|
42
|
+
Default config hash
|
43
|
+
```ruby
|
44
|
+
{
|
45
|
+
:cdm => {
|
46
|
+
'name' => 'Default Repo',
|
47
|
+
'server' => 'repository.address.edu',
|
48
|
+
'port' => 42,
|
49
|
+
'download_dir' => 'path/to/download/dir',
|
50
|
+
'records' => 3000
|
51
|
+
},
|
52
|
+
:progressbar => { 'length' => 60 }
|
53
|
+
}
|
54
|
+
```
|
55
|
+
|
56
|
+
#### With YAML File
|
57
|
+
```ruby
|
58
|
+
Hunting.configure_with('path\to\config.yml')
|
59
|
+
```
|
60
|
+
|
61
|
+
Example `config.yml`
|
62
|
+
```yaml
|
63
|
+
cdm:
|
64
|
+
name: # short repository name
|
65
|
+
server: # server address
|
66
|
+
port: # port number
|
67
|
+
download_dir: # directory path for logs and files
|
68
|
+
records: # number of records to return for Collection.data
|
69
|
+
|
70
|
+
progressbar:
|
71
|
+
length: # integer width for progress bar (default: 60)
|
72
|
+
```
|
73
|
+
|
74
|
+
### Repository.scout
|
75
|
+
|
76
|
+
Scout the repository for objects in all collections.
|
77
|
+
```ruby
|
78
|
+
repo = Repository.scout
|
79
|
+
```
|
80
|
+
|
81
|
+
Print all collection aliases in the repository.
|
82
|
+
```ruby
|
83
|
+
repo.collections.each do |collection_alias, collection|
|
84
|
+
puts collection_alias
|
85
|
+
end
|
86
|
+
```
|
87
|
+
OR
|
88
|
+
```ruby
|
89
|
+
repo.collections.each do |collection_alias, collection|
|
90
|
+
puts collection.alias
|
91
|
+
end
|
92
|
+
```
|
93
|
+
|
94
|
+
Scout the repository for objects in some collections.
|
95
|
+
```ruby
|
96
|
+
repo = Repository.scout(['collection_1_alias','collection_2_alias'])
|
97
|
+
```
|
98
|
+
|
99
|
+
Print some attributes of Collection 1.
|
100
|
+
```ruby
|
101
|
+
puts repo.collections['collection_1_alias'].alias
|
102
|
+
puts repo.collections['collection_1_alias'].name
|
103
|
+
puts repo.collections['collection_1_alias'].size
|
104
|
+
```
|
105
|
+
|
106
|
+
Print the Title of Object 7 from Collection 1.
|
107
|
+
```ruby
|
108
|
+
puts repo.collections['collection_1_alias'].records[7][:title]
|
109
|
+
```
|
110
|
+
|
111
|
+
Store all object pointers from Collection 1 in an array.
|
112
|
+
```ruby
|
113
|
+
collection_1_pointers = []
|
114
|
+
repo.collections['collection_1_alias'].records.each do |pointer, record|
|
115
|
+
collection_1_pointers.push(pointer)
|
116
|
+
end
|
117
|
+
```
|
118
|
+
|
119
|
+
### Collection.hunt
|
120
|
+
|
121
|
+
Hunt for all object metadata in Collection 1.
|
122
|
+
```ruby
|
123
|
+
repo.collections['collection_1_alias'].hunt
|
124
|
+
```
|
125
|
+
|
126
|
+
Hunt for some object metadata in Collection 1.
|
127
|
+
```ruby
|
128
|
+
repo.collections['collection_1_alias'].hunt([7,11,42])
|
129
|
+
```
|
130
|
+
|
131
|
+
Print the Title of Object 7 from Collection 1.
|
132
|
+
```ruby
|
133
|
+
puts repo.collections['collection_1_alias'].objects[7].metadata['Title']
|
134
|
+
```
|
135
|
+
|
136
|
+
Print the Title of Item 6 within (Compound) Object 7 from Collection 1.
|
137
|
+
```ruby
|
138
|
+
puts repo.collections['collection_1_alias'].objects[7].items[6].metadata['Title']
|
139
|
+
```
|
140
|
+
|
141
|
+
### Collection.trap
|
142
|
+
|
143
|
+
Trap Object 7 from Collection 1.
|
144
|
+
```ruby
|
145
|
+
object_7 = repo.collections['collection_1_alias'].trap(7)
|
146
|
+
```
|
147
|
+
|
148
|
+
Print some attributes of Object 7.
|
149
|
+
```ruby
|
150
|
+
puts object_7.metadata['Title']
|
151
|
+
puts object_7.type
|
152
|
+
puts object_7.pointer
|
153
|
+
```
|
154
|
+
|
155
|
+
Print all metadata field labels and values for Object 7.
|
156
|
+
```ruby
|
157
|
+
object_7.metadata.each do |label, value|
|
158
|
+
puts "#{label}: #{value}"
|
159
|
+
end
|
160
|
+
```
|
161
|
+
|
162
|
+
## Development
|
163
|
+
|
164
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
165
|
+
|
166
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
167
|
+
|
168
|
+
## Contributing
|
169
|
+
|
170
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/uhlibraries-digital/hunting.
|
171
|
+
|
172
|
+
|
173
|
+
## License
|
174
|
+
|
175
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
176
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hunting"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/hunting.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hunting/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hunting"
|
8
|
+
spec.version = Hunting::VERSION
|
9
|
+
spec.authors = ["Andy Weidner"]
|
10
|
+
spec.email = ["metaweidner@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Access digital collections through the CONTENTdm API.}
|
13
|
+
spec.description = %q{Hunting is a Ruby wrapper for the CONTENTdm API. Quickly 'Scout' your Repository, 'Hunt' for metadata in your Collections, and 'Trap' individual Digital Objects.}
|
14
|
+
spec.homepage = "https://github.com/uhlibraries-digital/hunting"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_dependency 'json', "~> 1.7"
|
31
|
+
spec.add_dependency 'xml-simple', "~> 1.1"
|
32
|
+
spec.add_dependency 'ruby-progressbar', "~> 1.8"
|
33
|
+
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
37
|
+
end
|
data/lib/hunting.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'hunting/version'
|
2
|
+
require 'hunting/repository'
|
3
|
+
require 'hunting/collection'
|
4
|
+
require 'hunting/digital_object'
|
5
|
+
require 'yaml'
|
6
|
+
require 'json'
|
7
|
+
require 'xmlsimple'
|
8
|
+
require 'open-uri'
|
9
|
+
require 'ruby-progressbar'
|
10
|
+
|
11
|
+
module Hunting
|
12
|
+
# Configuration defaults
|
13
|
+
@config = {
|
14
|
+
:cdm => {
|
15
|
+
'name' => 'Default Repo',
|
16
|
+
'server' => 'repository.address.edu',
|
17
|
+
'port' => 42,
|
18
|
+
'records' => 3000
|
19
|
+
},
|
20
|
+
:progressbar => { 'length' => 60 }
|
21
|
+
}
|
22
|
+
|
23
|
+
@valid_config_keys = @config.keys
|
24
|
+
|
25
|
+
# Configure through hash
|
26
|
+
def self.configure(opts = {})
|
27
|
+
opts.each do |key,value|
|
28
|
+
if @valid_config_keys.include? key.to_sym
|
29
|
+
@config[key.to_sym] = value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
server = @config[:cdm]['server']
|
33
|
+
port = @config[:cdm]['port']
|
34
|
+
@config[:dmwebservices] = "http://#{server}:#{port}/dmwebservices/index.php?q="
|
35
|
+
@config
|
36
|
+
end
|
37
|
+
|
38
|
+
# Configure through yaml file
|
39
|
+
def self.configure_with(path_to_yaml_file)
|
40
|
+
config = YAML::load(IO.read(path_to_yaml_file))
|
41
|
+
configure(config)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.config
|
45
|
+
@config
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.progressbar(type, name, total = nil)
|
49
|
+
length = Hunting.config[:progressbar]['length']
|
50
|
+
case type
|
51
|
+
when 'repository'
|
52
|
+
@progressbar = ProgressBar.create(total: total,
|
53
|
+
length: length,
|
54
|
+
format: "Scouting #{name}: %c |%B|")
|
55
|
+
when 'collection'
|
56
|
+
@progressbar = ProgressBar.create(total: total,
|
57
|
+
length: length,
|
58
|
+
format: "Hunting #{name}: %c/%C |%B|")
|
59
|
+
else
|
60
|
+
@progressbar = ProgressBar.create(length: length,
|
61
|
+
format: "Trapping #{name}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.increment
|
66
|
+
@progressbar.increment
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class Collection
|
2
|
+
|
3
|
+
attr_reader :alias,
|
4
|
+
:name,
|
5
|
+
:labels,
|
6
|
+
:size,
|
7
|
+
:records,
|
8
|
+
:objects
|
9
|
+
|
10
|
+
def initialize(collection)
|
11
|
+
@alias = collection[:alias]
|
12
|
+
@name = collection[:name]
|
13
|
+
@labels = map_labels_to_nicks
|
14
|
+
@size = 0
|
15
|
+
@records = scout_cdm
|
16
|
+
@objects = {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def map_labels_to_nicks
|
20
|
+
labels = {}
|
21
|
+
get_field_info = "dmGetCollectionFieldInfo/#{@alias}/json"
|
22
|
+
field_info = JSON.parse(open(Hunting.config[:dmwebservices] + get_field_info).read)
|
23
|
+
field_info.each { |field| labels.store(field['name'], field['nick']) }
|
24
|
+
labels
|
25
|
+
end
|
26
|
+
|
27
|
+
def scout_cdm
|
28
|
+
data = {}
|
29
|
+
records = Hunting.config[:cdm]['records']
|
30
|
+
dm_query = "dmQuery/#{@alias}/0/title/title/#{records}/1/0/0/0/0/0/0/json"
|
31
|
+
raw_data = JSON.parse(open(Hunting.config[:dmwebservices] + dm_query).read)
|
32
|
+
raw_data['records'].each do |record|
|
33
|
+
data.store(record['pointer'], {:filetype => record['filetype'], :title => record['title']})
|
34
|
+
Hunting.increment
|
35
|
+
@size += 1
|
36
|
+
end
|
37
|
+
data
|
38
|
+
end
|
39
|
+
|
40
|
+
def trap(pointer)
|
41
|
+
if @records.has_key?(pointer)
|
42
|
+
@progressbar = Hunting.progressbar('object', "#{@alias}(#{pointer})")
|
43
|
+
digital_object = DigitalObject.new({:pointer => pointer, :type => @records[pointer][:filetype]},
|
44
|
+
{:labels => @labels, :alias => @alias, :progress => 'no'})
|
45
|
+
@progressbar.finish
|
46
|
+
digital_object
|
47
|
+
else
|
48
|
+
puts "'#{@alias}' trap #{pointer} failed"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def hunt(pointers = 'all')
|
53
|
+
not_found = []
|
54
|
+
if pointers == 'all'
|
55
|
+
@progressbar = Hunting.progressbar('collection', @alias, @size)
|
56
|
+
@records.each do |pointer, object|
|
57
|
+
@objects.store(pointer, DigitalObject.new({:pointer => pointer, :type => object[:filetype]},
|
58
|
+
{:labels => @labels, :alias => @alias, :progress => 'yes'}))
|
59
|
+
end
|
60
|
+
@progressbar.finish
|
61
|
+
else
|
62
|
+
@progressbar = Hunting.progressbar('collection', @alias, pointers.size)
|
63
|
+
pointers.each do |pointer|
|
64
|
+
if @records.has_key?(pointer)
|
65
|
+
@objects.store(pointer, DigitalObject.new({:pointer => pointer, :type => @records[pointer][:filetype]},
|
66
|
+
{:labels => @labels, :alias => @alias, :progress => 'yes'}))
|
67
|
+
else
|
68
|
+
not_found.push(pointer)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
@progressbar.finish
|
72
|
+
if not_found.size > 0
|
73
|
+
print "'#{@alias}' hunt failed for: "
|
74
|
+
not_found.each {|pointer| print "#{pointer} "}
|
75
|
+
print "(#{not_found.size} of #{pointers.size})\n"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class DigitalObject
|
2
|
+
|
3
|
+
attr_reader :pointer,
|
4
|
+
:type,
|
5
|
+
:title,
|
6
|
+
:metadata,
|
7
|
+
:items
|
8
|
+
|
9
|
+
def initialize(record, collection)
|
10
|
+
@pointer = record[:pointer]
|
11
|
+
@alias = collection[:alias]
|
12
|
+
@labels = collection[:labels]
|
13
|
+
@metadata = {}
|
14
|
+
@items = {}
|
15
|
+
case record[:type]
|
16
|
+
when 'cpd'
|
17
|
+
@type = 'compound'
|
18
|
+
Hunting.increment if collection[:progress] == 'yes'
|
19
|
+
when 'file'
|
20
|
+
@type = 'file'
|
21
|
+
else
|
22
|
+
@type = 'single'
|
23
|
+
Hunting.increment if collection[:progress] == 'yes'
|
24
|
+
end
|
25
|
+
get_item_info = "dmGetItemInfo/#{@alias}/#{@pointer}/json"
|
26
|
+
raw_metadata = JSON.parse(open(Hunting.config[:dmwebservices] + get_item_info).read)
|
27
|
+
@title = raw_metadata['title']
|
28
|
+
@labels.each do |label, nick|
|
29
|
+
if raw_metadata[nick] == {}
|
30
|
+
@metadata[label] = ''
|
31
|
+
else
|
32
|
+
@metadata[label] = raw_metadata[nick]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if @type == 'compound'
|
36
|
+
get_c_o_info = "dmGetCompoundObjectInfo/#{@alias}/#{@pointer}/xml"
|
37
|
+
c_o_data = XmlSimple.xml_in(open(Hunting.config[:dmwebservices] + get_c_o_info))
|
38
|
+
if c_o_data['page'] == nil
|
39
|
+
content = open(Hunting.config[:dmwebservices] + get_c_o_info) {|f| f.read}
|
40
|
+
doc = XmlSimple::Document.new content
|
41
|
+
doc.elements.each("cpd/node/*") {|hierarchy| flatten(hierarchy)}
|
42
|
+
else
|
43
|
+
c_o_data['page'].each do |page|
|
44
|
+
@items.store(page['pageptr'][0].to_i, DigitalObject.new({:pointer => page['pageptr'][0].to_i, :type => 'file'},
|
45
|
+
{:labels => @labels, :alias => @alias}))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def flatten(hierarchy)
|
52
|
+
if hierarchy.elements['pageptr'] == nil
|
53
|
+
hierarchy.elements.each {|node| flatten(node)}
|
54
|
+
else
|
55
|
+
pointer = hierarchy.elements['pageptr'].text.to_i
|
56
|
+
@items.store(pointer, DigitalObject.new({:pointer => pointer, :type => 'file'},
|
57
|
+
{:labels => @labels, :alias => @alias}))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Repository
|
2
|
+
|
3
|
+
attr_reader :collections
|
4
|
+
attr_accessor :size
|
5
|
+
|
6
|
+
def self.scout(aliases = 'all')
|
7
|
+
Repository.new(aliases)
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(aliases)
|
11
|
+
@progressbar = Hunting.progressbar('repository', Hunting.config[:cdm]['name'])
|
12
|
+
@size = 0
|
13
|
+
@not_found = []
|
14
|
+
@collections = scout(aliases)
|
15
|
+
@progressbar.finish
|
16
|
+
if @not_found.size > 0
|
17
|
+
print 'Scout failed for: '
|
18
|
+
@not_found.each {|collection| print "#{collection} "}
|
19
|
+
print "\n"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def scout(aliases)
|
24
|
+
collections = {}
|
25
|
+
collection_info = {}
|
26
|
+
|
27
|
+
if Hunting.config[:dmwebservices] == nil
|
28
|
+
@progressbar.finish
|
29
|
+
abort("\nPlease configure Hunting for your CONTENTdm server:
|
30
|
+
\nHunting.configure(config_hash)\nOR\nHunting.configure_with(\"/path/to/config.yml\")\n")
|
31
|
+
else
|
32
|
+
cdm_collection_data = JSON.parse(open(Hunting.config[:dmwebservices] + "dmGetCollectionList/json").read)
|
33
|
+
end
|
34
|
+
|
35
|
+
cdm_collection_data.each do |collection|
|
36
|
+
collection_info.store(collection['secondary_alias'], {:alias => collection['secondary_alias'], :name => collection['name']})
|
37
|
+
end
|
38
|
+
|
39
|
+
if aliases == 'all'
|
40
|
+
collection_info.each do |collection_alias, info|
|
41
|
+
collections.store(collection_alias, Collection.new({:alias => collection_alias, :name => info[:name]}))
|
42
|
+
end
|
43
|
+
else
|
44
|
+
aliases.each do |c_alias|
|
45
|
+
if collection_info[c_alias] == nil
|
46
|
+
@not_found.push(c_alias)
|
47
|
+
else
|
48
|
+
collections.store(c_alias, Collection.new({:alias => c_alias, :name => collection_info[c_alias][:name]}))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
collections.each {|c_alias, collection| @size += collection.size}
|
53
|
+
collections
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hunting
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Weidner
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xml-simple
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-progressbar
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description: Hunting is a Ruby wrapper for the CONTENTdm API. Quickly 'Scout' your
|
98
|
+
Repository, 'Hunt' for metadata in your Collections, and 'Trap' individual Digital
|
99
|
+
Objects.
|
100
|
+
email:
|
101
|
+
- metaweidner@gmail.com
|
102
|
+
executables: []
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE.txt
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- bin/console
|
114
|
+
- bin/setup
|
115
|
+
- hunting.gemspec
|
116
|
+
- lib/hunting.rb
|
117
|
+
- lib/hunting/collection.rb
|
118
|
+
- lib/hunting/digital_object.rb
|
119
|
+
- lib/hunting/repository.rb
|
120
|
+
- lib/hunting/version.rb
|
121
|
+
homepage: https://github.com/uhlibraries-digital/hunting
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata:
|
125
|
+
allowed_push_host: https://rubygems.org
|
126
|
+
post_install_message:
|
127
|
+
rdoc_options: []
|
128
|
+
require_paths:
|
129
|
+
- lib
|
130
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
requirements: []
|
141
|
+
rubyforge_project:
|
142
|
+
rubygems_version: 2.4.8
|
143
|
+
signing_key:
|
144
|
+
specification_version: 4
|
145
|
+
summary: Access digital collections through the CONTENTdm API.
|
146
|
+
test_files: []
|