ezid-client 1.4.1 → 1.4.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac92a9017e776a4c88d7577881022af87f2d755d
4
- data.tar.gz: 3be1a1ee6ee37c784ce6bf07810ca0d3be2d4fc9
3
+ metadata.gz: fac2bb0d958a961b82670ed7c449989653648ea8
4
+ data.tar.gz: 53c4f97b36512859a1e7f7c7ec36d71a035419e6
5
5
  SHA512:
6
- metadata.gz: bb1f24f662eeed776a0c1380759ff9200e2e4619b04e553658c8ef96dc999985363abbfc5e454a6630cd9e38d5da9e6b25b6a98f1a85d1ab1274cb3fa371f630
7
- data.tar.gz: 5467514182de6d43ef1128065b6193440e42345d72e80e9b91e6f29dde5db927d7cb65ab9e772e523c05dc27b9a9dd9486ad3db9fbd745ab7c9b7a36325acac4
6
+ metadata.gz: cab9bdb73a109aca706dd8d4bba336c8446d35424daeb6814996b1d2c5778722cdfccb13a34f415a3165ce78b034217cc266b3d9a74ce42dd738c210f5a08512
7
+ data.tar.gz: c920024b464e32639d74dc77568c680ec48f3d909290d91ef08557939e5d5aaf66ff11e5d8f0eef7194cce25c27a966760a5bb9859f45f09e5cb256b746a4a43
data/Rakefile CHANGED
@@ -6,7 +6,17 @@ RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  desc "Run the ci build (no integration tests)"
8
8
  task :ci do
9
- system "rspec ./spec/unit/"
9
+ system "rspec . -t ~deprecated -t ~integration"
10
+ end
11
+
12
+ desc "Run tests of deprecated functionality"
13
+ task :deprecated do
14
+ system "rspec . -t deprecated"
15
+ end
16
+
17
+ desc "Run the integration tests"
18
+ task :integration do
19
+ system "rspec . -t integration"
10
20
  end
11
21
 
12
22
  task default: :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -86,18 +86,29 @@ module Ezid
86
86
 
87
87
  def initialize(*args)
88
88
  raise ArgumentError, "`new` receives 0-2 arguments." if args.size > 2
89
- data = args.last.is_a?(Hash) ? args.pop : nil
89
+ options = args.last.is_a?(Hash) ? args.pop : nil
90
90
  @id = args.first
91
91
  apply_default_metadata
92
- if data
93
- if shoulder = data.delete(:shoulder)
92
+ if options
93
+ if id = options.delete(:id)
94
+ warn "[DEPRECATION] The `:id` hash option is deprecated and will raise an exception in 2.0. The id should be passed as the first argument to `new` or set explicitly using the attribute writer. (called by #{caller.first})"
95
+ if @id
96
+ raise ArgumentError,
97
+ "`id' specified in both positional argument and (deprecated) hash option."
98
+ end
99
+ @id = id
100
+ end
101
+ if shoulder = options.delete(:shoulder)
94
102
  warn "[DEPRECATION] The `:shoulder` hash option is deprecated and will raise an exception in 2.0. Use `Ezid::Identifier.mint(shoulder, metadata)` to mint an identifier. (called by #{caller.first})"
95
103
  @shoulder = shoulder
96
104
  end
97
- if anvl = data.delete(:metadata)
105
+ if client = options.delete(:client)
106
+ warn "[DEPRECATION] The `:client` hash option is deprecated and ignored. It will raise an exception in 2.0. See the README for details on configuring `Ezid::Client`."
107
+ end
108
+ if anvl = options.delete(:metadata)
98
109
  update_metadata(anvl)
99
110
  end
100
- update_metadata(data)
111
+ update_metadata(options)
101
112
  end
102
113
  yield self if block_given?
103
114
  end
@@ -1,7 +1,7 @@
1
1
  module Ezid
2
2
  class ProxyIdentifier
3
3
 
4
- warn "[DEPRECATION] `Ezid::ProxyIdentifier` is deprecated and will be removed in v2.0. Use `Ezid::Identifier` instead."
4
+ warn "[DEPRECATION] `Ezid::ProxyIdentifier` is deprecated and will be removed in v2.0. Use `Ezid::Identifier` instead. (called from #{caller.first})"
5
5
 
6
6
  attr_reader :id
7
7
  attr_accessor :__real
@@ -1,7 +1,7 @@
1
1
  require "time"
2
2
 
3
3
  module Ezid
4
- RSpec.describe Client do
4
+ RSpec.describe Client, integration: true do
5
5
 
6
6
  shared_examples "an EZID client" do |client|
7
7
  it "should mint and modify" do
@@ -1,5 +1,5 @@
1
1
  module Ezid
2
- RSpec.describe Identifier do
2
+ RSpec.describe Identifier, integration: true do
3
3
 
4
4
  before {
5
5
  @identifier = described_class.mint(TEST_ARK_SHOULDER, target: "http://example.com")
@@ -14,16 +14,14 @@ module Ezid
14
14
  described_class.create("id")
15
15
  end
16
16
  end
17
- describe "with a hash metadata arg" do
17
+ describe "with a hash metadata arg", deprecated: true do
18
18
  it "mints a new Identifier" do
19
- skip "DEPRECATED"
20
19
  expect(described_class).to receive(:mint).with(nil, profile: "dc", target: "http://example.com")
21
20
  described_class.create(profile: "dc", target: "http://example.com")
22
21
  end
23
22
  end
24
- describe "with no args" do
23
+ describe "with no args", deprecated: true do
25
24
  it "mints a new Identifier" do
26
- skip "DEPRECATED"
27
25
  expect(described_class).to receive(:mint).with(nil, nil)
28
26
  described_class.create
29
27
  end
@@ -113,11 +111,29 @@ module Ezid
113
111
  its(:metadata) { is_expected.to eq("_profile"=>"dc", "_target"=>"http://example.com", "_status"=>"reserved", "_export"=>"no") }
114
112
  end
115
113
  end
114
+ describe "deprecated hash options", deprecated: true do
115
+ describe "id" do
116
+ subject { described_class.new(id: "id") }
117
+ its(:id) { is_expected.to eq("id") }
118
+ specify {
119
+ expect { described_class.new("id", id: "id") }.to raise_error(ArgumentError)
120
+ }
121
+ end
122
+ describe "shoulder" do
123
+ subject { described_class.new(shoulder: "shoulder") }
124
+ its(:shoulder) { is_expected.to eq("shoulder") }
125
+ end
126
+ describe "client" do
127
+ let(:client) { double }
128
+ subject { described_class.new(client: client) }
129
+ its(:client) { is_expected.to_not eq(client) }
130
+ end
131
+ end
116
132
  end
117
133
 
118
134
  describe "#update" do
119
135
  let(:metadata) { {"status" => "unavailable"} }
120
- subject { described_class.new(id: "id") }
136
+ subject { described_class.new("id") }
121
137
  it "updates the metadata and saves" do
122
138
  expect(subject).to receive(:update_metadata).with(metadata)
123
139
  expect(subject).to receive(:save) { double }
@@ -223,7 +239,7 @@ module Ezid
223
239
  end
224
240
  end
225
241
  context "when identifier is not reserved" do
226
- subject { described_class.new(id: "id", status: Status::PUBLIC) }
242
+ subject { described_class.new("id", status: Status::PUBLIC) }
227
243
  it "raises an exception" do
228
244
  expect { subject.delete }.to raise_error(Error)
229
245
  end
@@ -302,7 +318,7 @@ module Ezid
302
318
  end
303
319
 
304
320
  describe "status-changing methods" do
305
- subject { described_class.new(id: "id", status: status) }
321
+ subject { described_class.new("id", status: status) }
306
322
  describe "#unavailable!" do
307
323
  context "when the status is \"unavailable\"" do
308
324
  let(:status) { "#{Status::UNAVAILABLE} | whatever" }
@@ -359,7 +375,7 @@ module Ezid
359
375
  end
360
376
  end
361
377
  describe "#public!" do
362
- subject { described_class.new(id: "id", status: Status::UNAVAILABLE) }
378
+ subject { described_class.new("id", status: Status::UNAVAILABLE) }
363
379
  it "changes the status" do
364
380
  expect { subject.public! }.to change(subject, :status).from(Status::UNAVAILABLE).to(Status::PUBLIC)
365
381
  end
@@ -1,26 +1,25 @@
1
- require 'ezid/proxy_identifier'
2
-
3
1
  module Ezid
4
- RSpec.describe ProxyIdentifier do
5
-
6
- describe "initialization" do
7
- it "should not load the real identifier" do
8
- expect(Identifier).not_to receive(:find)
9
- described_class.new("ark:/99999/fk4fn19h88")
2
+ RSpec.describe "proxy identifier", deprecated: true do
3
+ require 'ezid/proxy_identifier'
4
+ describe ProxyIdentifier do
5
+ describe "initialization" do
6
+ it "should not load the real identifier" do
7
+ expect(Identifier).not_to receive(:find)
8
+ described_class.new("ark:/99999/fk4fn19h88")
9
+ end
10
10
  end
11
- end
12
11
 
13
- describe "lazy loading" do
14
- subject { described_class.new(id) }
12
+ describe "lazy loading" do
13
+ subject { described_class.new(id) }
15
14
 
16
- let(:id) { "ark:/99999/fk4fn19h88" }
17
- let(:real) { double(id: id, target: "http://ezid.cdlib.org/id/#{id}") }
15
+ let(:id) { "ark:/99999/fk4fn19h88" }
16
+ let(:real) { double(id: id, target: "http://ezid.cdlib.org/id/#{id}") }
18
17
 
19
- it "should load the real identifier when calling a missing method" do
20
- expect(Identifier).to receive(:find).with(id) { real }
21
- expect(subject.target).to eq(real.target)
18
+ it "should load the real identifier when calling a missing method" do
19
+ expect(Identifier).to receive(:find).with(id) { real }
20
+ expect(subject.target).to eq(real.target)
21
+ end
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezid-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie