uwdc 0.0.1 → 0.0.2

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzZmZTU4NjE2MmIyNDdlYTdiYzI4NjlhNTc0NDNiYTAxYzYyZWZjMw==
4
+ MmJlMGM4Nzk5ZWJjMGFlZGQ1OGM5MmVmOTA3NmViZmIyYjBiOGZhNg==
5
5
  data.tar.gz: !binary |-
6
- ZGQyOTczOTcxZjlmZTIwNjhkZWFmMDc3YzEzMjE1MjExMmI5ZWI0OA==
6
+ OGI3Y2E1ZWM0ZTYyMWYzNDVjOTUyNWVmNTFlOTliYTM2OWVjNzY2MA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODFkNzNlNjVmNThiMDNkNGM1OGMyZGEwMGY1YzM1NWY0NDg2ZDcyODRmNzBj
10
- NDg4N2I1Zjg5MjA1NjU3OTc4ZWY1MjZkZDc2MjIzYjcyYmQ0ZjgxN2RjMWFl
11
- NzAyNzFkYWVhNjFkOWZjMmRmZWUyNjUwNGE5YjNkNTA2YTRkMTM=
9
+ MjNiODBlYjQ2ZTczZGRlODViZTE3NzQ2NTU1NTAzYWYxMTZmNTY5NjcxNDA2
10
+ NzI2ODAyNjYwNGE2ODZiYTBlNmM3MWZhNGFjNGM4MTQyMWJhZDU2ZGQ3ZTMx
11
+ ZTI3N2Q0ZjU3ZDY2OGRiOTg2MjJiMDQwYmZjYzZlMDhjMzA4YjM=
12
12
  data.tar.gz: !binary |-
13
- ODc5NTM2YzE1OTRmODgzYjJjOTU5MzQ1YmZiOWE5ZDk1Y2Y2YWE4M2UxNGVh
14
- NWY3MzllYzA3N2QzNzVhZTExOGJiNzRhMWEzMzM4MjgwYzBkMTliZjhhNTVl
15
- ZDMxNmRlYjM2YTcwNWJjNGExNWQ2ZDg5ZDEzNzUzYTcyZTYwMTM=
13
+ NDRlZTViMDZjYjNkZGM2YjAzMDFmNDRkMGZlZDI0MDg5NjI4NzY4NTY0OWYx
14
+ MWZiY2QyY2Q1OWIwOTI0M2YxY2YwM2U4ZWFmNzc3YWQxZDM0NWJhMmRiYTUz
15
+ MTY2ZWNlZDNiMTBlNDU0MzZlYWIzZGNiNTg5MDEwZWJhMjRkYWY=
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  UWDC
2
2
  ====
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/uwdc.png)](http://badge.fury.io/rb/uwdc)
4
5
  [![Build Status](https://travis-ci.org/ewlarson/uwdc.png)](https://travis-ci.org/ewlarson/uwdc)
5
6
  [![Dependency Status](https://gemnasium.com/ewlarson/uwdc.png)](https://gemnasium.com/ewlarson/uwdc)
6
7
  [![Code Climate](https://codeclimate.com/github/ewlarson/uwdc.png)](https://codeclimate.com/github/ewlarson/uwdc)
@@ -9,6 +10,10 @@ UWDC
9
10
 
10
11
  Gem for accessing University of Wisconsin Digital Collection items from our Fedora Commons repository.
11
12
 
13
+ ## Install
14
+
15
+ gem install uwdc
16
+
12
17
  ## Usage
13
18
 
14
19
  ### METS
@@ -16,9 +21,13 @@ Obtain the METS metadata for a UWDC object.
16
21
 
17
22
  ```ruby
18
23
  require 'uwdc'
19
- mets = UWDC::Mets.new('33QOBSVPJLWEM8S') # Ignoring
24
+ mets = UWDC::Mets.new('33QOBSVPJLWEM8S')
20
25
  mets.mods
21
26
  mets.mods.titles
27
+ # => ["A life idyl"]
28
+
29
+ mets.mods.metadata
30
+ # => {:titles=>["A life idyl"], :names=>[], :dates=>["1869"], :forms=>["text"], ...}
22
31
  ```
23
32
 
24
33
  UWDC METS will contain:
@@ -90,9 +99,9 @@ MODS top-level elements are boiled in Ruby to something more dot-syntax friendly
90
99
  </tbody>
91
100
  </table>
92
101
 
102
+ Transform via to_* calls. Supports JSON, Ruby and XML
103
+
93
104
  ```ruby
94
- # Transform via to_* calls
95
- # - supports JSON, Ruby and XML
96
105
  mods.to_json
97
106
  mods.to_ruby
98
107
  mods.to_xml
data/lib/uwdc.rb CHANGED
@@ -4,6 +4,7 @@ require 'httpclient'
4
4
  require 'nokogiri'
5
5
  require 'json'
6
6
  require 'active_support/core_ext/hash'
7
+ require 'ostruct'
7
8
 
8
9
  # UWDC
9
10
  module UWDC
data/lib/uwdc/display.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  module UWDC
2
- # Return an object to drive the display of UWDC items
2
+ # Public: Return an object to drive the display of UWDC items
3
+ #
4
+ # Example
5
+ #
6
+ # @display = UWDC::Display.new('33QOBSVPJLWEM8S')
7
+ # # => object
3
8
  class Display
4
9
 
5
10
  attr_accessor :mets, :title, :visual_representation
@@ -8,7 +13,7 @@ module UWDC
8
13
  @mets = UWDC::Mets.new(id,xml)
9
14
  end
10
15
 
11
- def use
16
+ def self.use
12
17
  {
13
18
  "title" => { :view => false, :partial => "text" },
14
19
  "visualrepresentation" => { :view => false, :partial => "text" },
@@ -20,7 +25,7 @@ module UWDC
20
25
  }
21
26
  end
22
27
 
23
- def cmodels
28
+ def self.cmodels
24
29
  {
25
30
  "info:fedora/1711.dl:CModelAudio" => { :view => true, :partial => "audio" },
26
31
  "info:fedora/1711.dl:CModelAudioStream" => { :view => true, :partial => "audio" },
@@ -44,7 +49,7 @@ module UWDC
44
49
  end
45
50
 
46
51
  def image_files(model)
47
- files.select{|file| file.id.include?(model) && use[file.use][:partial] == "image"}
52
+ files.select{|file| file.id.include?(model) && UWDC::Display.use[file.use][:partial] == "image"}
48
53
  end
49
54
 
50
55
  def images
@@ -64,6 +69,20 @@ module UWDC
64
69
  @mets.mods
65
70
  end
66
71
 
72
+ # @TODO:
73
+ # Public: Partials is the intersection of the struct_map and the object cmodels
74
+ # Need to preserve the struct map's "div" structure
75
+ # But also tease out which objects are displayable via which partials
76
+ #
77
+ # Return an array of Hashes (possibly nested) of ids keying to view partials
78
+ def partials
79
+ @mets.struct_map.structure
80
+ end
81
+
82
+ def models
83
+ @mets.rels_ext.models
84
+ end
85
+
67
86
  alias :metadata :mods
68
87
 
69
88
  private
@@ -73,7 +92,7 @@ module UWDC
73
92
  end
74
93
 
75
94
  def viewable_model?(model)
76
- model.last.detect{|name| cmodels[name][:view] == true}
95
+ model.last.detect{|name| UWDC::Display.cmodels[name][:view] == true}
77
96
  end
78
97
 
79
98
  def viewable_models
data/lib/uwdc/mods.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'ostruct'
2
-
3
1
  module UWDC
4
2
  # Public: Obtain the MODS metadata for a UWDC METS object
5
3
  #
@@ -140,7 +138,7 @@ module UWDC
140
138
  # @mods.access_conditions.rights
141
139
  # # => "Delehanty, Jim"
142
140
  #
143
- # Retuns an OpenStruct
141
+ # Returns an OpenStruct
144
142
  def access_conditions
145
143
  OpenStruct.new(rights: rights, reuse: reuse)
146
144
  end
data/lib/uwdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module UWDC
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -2,6 +2,11 @@
2
2
  require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
3
3
  require 'uwdc'
4
4
 
5
+ def clean_id(id)
6
+ clean = id.split("-")
7
+ "#{clean[0]}-#{clean[1]}"
8
+ end
9
+
5
10
  describe UWDC::Display do
6
11
 
7
12
  context 'PBO' do
@@ -11,11 +16,11 @@ describe UWDC::Display do
11
16
  end
12
17
 
13
18
  it "should include use attributes" do
14
- expect(@display.use).to be_true
19
+ expect(UWDC::Display.use).to be_true
15
20
  end
16
21
 
17
22
  it "should include content models" do
18
- expect(@display.cmodels).to be_true
23
+ expect(UWDC::Display.cmodels).to be_true
19
24
  end
20
25
 
21
26
  it "should include files" do
@@ -31,6 +36,18 @@ describe UWDC::Display do
31
36
  expect(@display.metadata).to be_true
32
37
  expect(@display.metadata).to be_an_instance_of(UWDC::Mods)
33
38
  end
39
+
40
+ it "should have partials" do
41
+ #puts @display.partials.inspect
42
+ expect(@display.partials).to be_true
43
+ end
44
+
45
+ it "should have models" do
46
+ @display.partials.each do |div|
47
+ puts @display.models.select{|model| model.include?(clean_id(div.id))}
48
+ end
49
+ expect(@display.models).to be_true
50
+ end
34
51
  end
35
52
 
36
53
  context 'UNTAC' do
data/uwdc.gemspec CHANGED
@@ -12,10 +12,10 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{Use the UWDC collections}
13
13
  gem.homepage = "https://github.com/ewlarson/uwdc"
14
14
 
15
- gem.add_dependency 'httpclient'
16
- gem.add_dependency 'nokogiri'
17
- gem.add_dependency 'json'
18
- gem.add_dependency 'active_support'
15
+ gem.add_dependency('httpclient', '~>2.3.3')
16
+ gem.add_dependency('nokogiri', '~>1.5.2')
17
+ gem.add_dependency('json', '~>1.8.0')
18
+ gem.add_dependency('active_support', '~>3.0.0')
19
19
 
20
20
  gem.add_development_dependency 'rake'
21
21
  gem.add_development_dependency 'rspec'
metadata CHANGED
@@ -1,71 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uwdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Larson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-22 00:00:00.000000000 Z
11
+ date: 2013-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.3.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 2.3.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.5.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.5.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.8.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.8.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: active_support
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: 3.0.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: 3.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement