stash-wrapper 0.1.1 → 0.1.2

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: 0b9b2b3b3b61546cb479b5641e250d4494daee32
4
- data.tar.gz: 88c5ce1cab8a9868b69b0905cb848346b3bebe33
3
+ metadata.gz: ffbc971060572311562d5cddea48605f7c6d152f
4
+ data.tar.gz: 80c7a4e1e610b4f945dfded51cb3f6835362d62e
5
5
  SHA512:
6
- metadata.gz: ca3ccf0129d471e5d3c92625784cdc03d4221c9691ea943e75ff73f354773c7082d92425cc16e6545056036165b9d9062376e20dd2044a5f43ae1de3830ab26c
7
- data.tar.gz: 93c73e6f99e009f811618145daa9b90820d094257b17f39cafac5f5c934584ab81d4efdc5a6c124e41a406c0aa5e41568e2f679d34f7b0154cf8349c9074c18d
6
+ metadata.gz: 692b374270d158d5e7c45fc3e7ca3b5fda1c43df8d465e28171977fd332063eb8264527eb245174719314b9be0393edc439d4c2f720fb0a3f1ccb5870486fd64
7
+ data.tar.gz: c35a351a76d85e7f25d843a169fd7acc15a28a073f94eb23bd2c04e6afe01e05f16bea9e903d610cb3c4026c32554e725640a01ef20779dff88f2dd16a3f5098
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 0.1.2 (31 March 2016)
2
+
3
+ - Add convenience method `Embargo.none` to create a no-embargo embargo element
4
+ - Make `StashAdministrative` (and thereby `StashWrapper`) default to `Embargo.none`
5
+ if no `Embargo` is provided
6
+
1
7
  # 0.1.1 (16 March 2016)
2
8
 
3
9
  - Fix gem metadata
@@ -24,6 +24,13 @@ module Stash
24
24
  self.start_date = start_date
25
25
  self.end_date = end_date
26
26
  end
27
+
28
+ # Creates a new `Embargo` instance of type {EmbargoType::NONE} with the current date as start and end.
29
+ # @return [Embargo]
30
+ def self.none
31
+ today = Date.today
32
+ new(type: EmbargoType::NONE, period: EmbargoType::NONE.value, start_date: today, end_date: today)
33
+ end
27
34
  end
28
35
 
29
36
  end
@@ -5,7 +5,7 @@ module Stash
5
5
  NAME = 'stash-wrapper'
6
6
 
7
7
  # The version of this gem
8
- VERSION = '0.1.1'
8
+ VERSION = '0.1.2'
9
9
 
10
10
  # The copyright notice for this gem
11
11
  COPYRIGHT = 'Copyright (c) 2016 The Regents of the University of California'
@@ -18,14 +18,14 @@ module Stash
18
18
  #
19
19
  # @param version [Version] the version
20
20
  # @param license [License] the license
21
- # @param embargo [Embargo] the embargo. Note that per the schema,
22
- # an `<st:embargo>` element is required even if there is no embargo
23
- # on the dataset (in which case it should use {EmbargoType::NONE}).
21
+ # @param embargo [Embargo, nil] the embargo information. If no `Embargo`
22
+ # is supplied, it will default to an embargo of type {EmbargoType::NONE}
23
+ # with the current date as start and end.
24
24
  # @param inventory [Inventory, nil] the (optional) file inventory
25
- def initialize(version:, license:, embargo:, inventory: nil)
25
+ def initialize(version:, license:, embargo: nil, inventory: nil)
26
26
  self.version = version
27
27
  self.license = license
28
- self.embargo = embargo
28
+ self.embargo = embargo || Embargo.none
29
29
  self.inventory = inventory
30
30
  end
31
31
  end
@@ -29,13 +29,13 @@ module Stash
29
29
  # @param identifier [Identifier] the identifier
30
30
  # @param version [Version] the version
31
31
  # @param license [License] the license
32
- # @param embargo [Embargo] the embargo. Note that per the schema,
33
- # an `<st:embargo>` element is required even if there is no embargo
34
- # on the dataset (in which case it should use {EmbargoType::NONE}).
32
+ # @param embargo [Embargo, nil] the embargo information. If no `Embargo`
33
+ # is supplied, it will default to an embargo of type {EmbargoType::NONE}
34
+ # with the current date as start and end.
35
35
  # @param inventory [Inventory, nil] the (optional) file inventory
36
36
  # @param descriptive_elements [Array<REXML::Element>] the encapsulated
37
37
  # XML metadata
38
- def initialize(identifier:, version:, license:, embargo:, inventory: nil, descriptive_elements:) # rubocop:disable Metrics/ParameterLists
38
+ def initialize(identifier:, version:, license:, embargo: nil, inventory: nil, descriptive_elements:) # rubocop:disable Metrics/ParameterLists
39
39
  self.identifier = identifier
40
40
  self.stash_administrative = StashAdministrative.new(
41
41
  version: version,
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ module Stash
4
+ module Wrapper
5
+ describe Embargo do
6
+ describe 'none' do
7
+ it "returns a no-embargo #{Embargo}" do
8
+ embargo = Embargo.none
9
+ expect(embargo).to be_an(Embargo)
10
+ expect(embargo.type).to eq(EmbargoType::NONE)
11
+ expect(embargo.period).to eq('none')
12
+ today = Date.today
13
+ expect(embargo.start_date).to eq(today)
14
+ expect(embargo.end_date).to eq(today)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ module Stash
4
+ module Wrapper
5
+ describe StashAdministrative do
6
+ describe '#initialize' do
7
+ it 'defaults to no embargo' do
8
+ admin = StashAdministrative.new(
9
+ version: Version.new(number: 1, date: Date.new(2013, 8, 18), note: 'Sample wrapped Datacite document'),
10
+ license: License::CC_BY,
11
+ inventory: Inventory.new(
12
+ files: [
13
+ StashFile.new(pathname: 'HSRC_MasterSampleII.dat', size_bytes: 12_345, mime_type: 'text/plain')
14
+ ])
15
+ )
16
+ embargo = admin.embargo
17
+ expect(embargo).to be_an(Embargo)
18
+ expect(embargo.type).to eq(EmbargoType::NONE)
19
+ expect(embargo.period).to eq('none')
20
+ today = Date.today
21
+ expect(embargo.start_date).to eq(today)
22
+ expect(embargo.end_date).to eq(today)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -136,6 +136,28 @@ module Stash
136
136
  end
137
137
  end
138
138
 
139
+ describe '#initialize' do
140
+ it 'defaults to no embargo' do
141
+ wrapper = StashWrapper.new(
142
+ identifier: Identifier.new(type: IdentifierType::DOI, value: '10.14749/1407399498'),
143
+ version: Version.new(number: 1, date: Date.new(2013, 8, 18), note: 'Sample wrapped Datacite document'),
144
+ license: License::CC_BY,
145
+ inventory: Inventory.new(
146
+ files: [
147
+ StashFile.new(pathname: 'HSRC_MasterSampleII.dat', size_bytes: 12_345, mime_type: 'text/plain')
148
+ ]),
149
+ descriptive_elements: []
150
+ )
151
+ embargo = wrapper.embargo
152
+ expect(embargo).to be_an(Embargo)
153
+ expect(embargo.type).to eq(EmbargoType::NONE)
154
+ expect(embargo.period).to eq('none')
155
+ today = Date.today
156
+ expect(embargo.start_date).to eq(today)
157
+ expect(embargo.end_date).to eq(today)
158
+ end
159
+ end
160
+
139
161
  describe '#save_to_xml' do
140
162
 
141
163
  describe 'namespace handling' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stash-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typesafe_enum
@@ -205,6 +205,8 @@ files:
205
205
  - spec/data/wrapper/wrapper-2.xml
206
206
  - spec/rspec_custom_matchers.rb
207
207
  - spec/spec_helper.rb
208
+ - spec/unit/stash/wrapper/embargo_spec.rb
209
+ - spec/unit/stash/wrapper/stash_administrative_spec.rb
208
210
  - spec/unit/stash/wrapper/stash_wrapper_spec.rb
209
211
  - stash-wrapper.gemspec
210
212
  homepage: http://github.com/CDLUC3/stash-wrapper
@@ -241,5 +243,7 @@ test_files:
241
243
  - spec/data/wrapper/wrapper-2.xml
242
244
  - spec/rspec_custom_matchers.rb
243
245
  - spec/spec_helper.rb
246
+ - spec/unit/stash/wrapper/embargo_spec.rb
247
+ - spec/unit/stash/wrapper/stash_administrative_spec.rb
244
248
  - spec/unit/stash/wrapper/stash_wrapper_spec.rb
245
249
  has_rdoc: