puree 0.17.1 → 0.18.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2057afc22f318c041a9ae6e2f38f45d6bf178896
4
- data.tar.gz: dbd57196335d0291d3a3e8afcae5ce3185a56a9b
3
+ metadata.gz: c2678f284947384cb88da1511bbdedf6cbc00314
4
+ data.tar.gz: 7d8435e7e07d5e98aa8240e1e736456503457a7f
5
5
  SHA512:
6
- metadata.gz: b6d2f693ac2abefbb753d43f183e25d1d89cc6dd44f5bab659002c2b7f9e6aeb5499ad9dc668e19a2891854a2c095c5f0fe1bbcaf4d6b55dcce43668740aa6b3
7
- data.tar.gz: 969daf19da9bfd0eafb5cb20bc73bbe6930f145d565b5f57c76a9559d144486f854acffe27bbc1a4eb9c89a9c2f91879fef82ded23df08c6f05d5a2e36145841
6
+ metadata.gz: fe6494c3ac14f9f20811268c5b3c65b2cd5b5f888a94113cf2f887729c3ea1998d73883193bdc0db740659f8f099f354f6767e30a0c75b00c182496cba18b13a
7
+ data.tar.gz: 1d9cf4abce07487bcf45881ebec3bbf7f6c1ab241002e1c91c0891cee3220dfccf1f82f2c65eac2e3cd19b7bc3eff6eccca0b9aa806b049d198a1bd496df39a8
data/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7
7
  - Factory to make resource objects?
8
8
  - Make ALL dates ISO 8601 YYYY-MM-DD, rather than mirror varying formats from Pure?
9
9
 
10
+ ## 0.18.0 - 2016-09-20
11
+ ### Added
12
+ - Collection - count of records available.
13
+
10
14
  ## 0.17.1 - 2016-09-08
11
15
  ### Fixed
12
16
  - Dataset - available extraction.
data/PITCHME.md ADDED
@@ -0,0 +1,108 @@
1
+ #HSLIDE
2
+
3
+ ## Rationale
4
+
5
+ Projects revealed challenges getting specific data from the Pure Research Information System API.
6
+
7
+ #VSLIDE
8
+
9
+ ## DOI minting
10
+
11
+ Transforming metadata to the DataCite XML schema and minting Digital Object Identifiers.
12
+
13
+ <a href="https://github.com/lulibrary/doi" target="_blank">GitHub</a>
14
+
15
+ #VSLIDE
16
+
17
+ ## Fedora repository
18
+
19
+ Transforming metadata to RDF and ingesting via REST API.
20
+
21
+ #VSLIDE
22
+
23
+ ## Linked open data
24
+
25
+ Transforming metadata to RDF and publishing in Fuseki triple store.
26
+
27
+ #VSLIDE
28
+
29
+ ## Primo
30
+
31
+ Enriching author metadata.
32
+
33
+ #VSLIDE
34
+
35
+ ## DMAOnline
36
+
37
+ Ingesting research data management data from the Current Research Information System (CRIS) of multiple institutions.
38
+
39
+ <a href="http://dmao.info/" target="_blank">Project website</a>
40
+
41
+ #HSLIDE
42
+
43
+ ## Pure API challenges
44
+
45
+ #VSLIDE
46
+
47
+ - Metadata at resource level e.g. dataset.
48
+ - Only XML available. <!-- .element: class="fragment" -->
49
+ - XML needs processing to extract specific metadata. <!-- .element: class="fragment" -->
50
+ - Local web services consuming the Pure API are not useful when contributing FOSS. <!-- .element: class="fragment" -->
51
+
52
+ #HSLIDE
53
+
54
+ ## Pur&#233;e: an answer to the challenges
55
+
56
+ #VSLIDE
57
+
58
+ - Consumes the Pure API.
59
+ - Metadata available in simple data structures. <!-- .element: class="fragment" -->
60
+ - No XML processing needed in any code. <!-- .element: class="fragment" -->
61
+
62
+ #VSLIDE
63
+
64
+ ## Single resource
65
+ Tell Pur&#233;e what you are looking for...
66
+
67
+ ```ruby
68
+ d = Puree::Dataset.new
69
+ metadata = d.find uuid: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
70
+ ```
71
+ ...and get the data from a hash...
72
+
73
+ ```ruby
74
+ metadata['doi']
75
+ ```
76
+
77
+ ...or using a method...
78
+
79
+ ```ruby
80
+ d.doi
81
+ ```
82
+
83
+ #VSLIDE
84
+
85
+ ## Collection of resources
86
+ Tell Pur&#233;e what you are looking for...
87
+
88
+ ```ruby
89
+ c = Puree::Collection.new resource: :dataset
90
+ metadata = c.find limit: 50
91
+ ```
92
+ ...and get the data from an array of hashes or from an array of instances.
93
+
94
+ #VSLIDE
95
+
96
+ ## Location
97
+
98
+ <a href="https://rubygems.org/gems/puree" target="_blank">RubyGems</a>
99
+
100
+ <a href="https://github.com/lulibrary/puree" target="_blank">GitHub</a>
101
+
102
+ #VSLIDE
103
+
104
+ ## Documentation
105
+
106
+ <a href="http://www.rubydoc.info/gems/puree" target="_blank">API in YARD</a>
107
+
108
+ <a href="https://aalbinclark.gitbooks.io/puree" target="_blank">Detailed usage in GitBook</a>
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pur&#233;e [![Gem Version](https://badge.fury.io/rb/puree.svg)](https://badge.fury.io/rb/puree)
1
+ # Pur&#233;e [![Gem Version](https://badge.fury.io/rb/puree.svg)](https://badge.fury.io/rb/puree) [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/lulibrary/puree)
2
2
  Consumes the Pure Research Information System API and puts the metadata into simple data structures.
3
3
 
4
4
  ## Installation
@@ -65,6 +65,8 @@ module Puree
65
65
  record_rendering: rendering
66
66
  }
67
67
 
68
+ reset
69
+
68
70
  missing = missing_credentials
69
71
  if !missing.empty?
70
72
  missing.each do |m|
@@ -88,7 +90,7 @@ module Puree
88
90
 
89
91
  query['rendering'] = @options[:rendering]
90
92
 
91
- if @options[:limit]
93
+ if @options[:limit] >= 0
92
94
  query['window.size'] = @options[:limit]
93
95
  end
94
96
 
@@ -133,6 +135,7 @@ module Puree
133
135
  @doc = Nokogiri::XML @response.body
134
136
  @doc.remove_namespaces!
135
137
 
138
+ @count = extract_count
136
139
  # code = @response.code
137
140
  # body = @response.body
138
141
  # puts "#{self.class.name} #{code}"
@@ -157,8 +160,20 @@ module Puree
157
160
  end
158
161
 
159
162
 
163
+ # Count of records available for a resource type
164
+ #
165
+ # @return [Integer]
166
+ def count
167
+ @count
168
+ end
169
+
160
170
  private
161
171
 
172
+ def extract_count
173
+ path = '//count'
174
+ xpath_query_for_single_value(path).to_i
175
+ end
176
+
162
177
 
163
178
  # Array of UUIDs
164
179
  #
@@ -233,6 +248,11 @@ module Puree
233
248
  @doc.xpath path
234
249
  end
235
250
 
251
+ def xpath_query_for_single_value(path)
252
+ xpath_result = xpath_query path
253
+ xpath_result ? xpath_result.text.strip : ''
254
+ end
255
+
236
256
 
237
257
  def missing_credentials
238
258
  missing = []
@@ -252,6 +272,11 @@ module Puree
252
272
  missing
253
273
  end
254
274
 
275
+ def reset
276
+ @response = nil
277
+ @count = nil
278
+ end
279
+
255
280
  alias :find :get
256
281
 
257
282
  end
data/lib/puree/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Puree
2
2
  # Semantic version number
3
3
  #
4
- VERSION = "0.17.1"
4
+ VERSION = "0.18.0"
5
5
  end
data/spec/collection.rb CHANGED
@@ -47,4 +47,16 @@ describe 'Collection' do
47
47
 
48
48
  end
49
49
 
50
+ describe 'data retrieval count' do
51
+ before(:all) do
52
+ new
53
+ @p.find limit: 0
54
+ end
55
+
56
+ it '#count' do
57
+ expect(@p.count).to be_an_instance_of(Fixnum)
58
+ end
59
+
60
+ end
61
+
50
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Albin-Clark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -50,6 +50,7 @@ files:
50
50
  - CHANGELOG.md
51
51
  - Gemfile
52
52
  - LICENSE.txt
53
+ - PITCHME.md
53
54
  - README.md
54
55
  - Rakefile
55
56
  - lib/puree.rb