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 +4 -4
- data/Rakefile +11 -1
- data/VERSION +1 -1
- data/lib/ezid/identifier.rb +16 -5
- data/lib/ezid/proxy_identifier.rb +1 -1
- data/spec/integration/client_spec.rb +1 -1
- data/spec/integration/identifier_spec.rb +1 -1
- data/spec/unit/identifier_spec.rb +24 -8
- data/spec/unit/proxy_identifier_spec.rb +16 -17
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fac2bb0d958a961b82670ed7c449989653648ea8
         | 
| 4 | 
            +
              data.tar.gz: 53c4f97b36512859a1e7f7c7ec36d71a035419e6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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  | 
| 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.4.2
         | 
    
        data/lib/ezid/identifier.rb
    CHANGED
    
    | @@ -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 | 
            -
                   | 
| 89 | 
            +
                  options = args.last.is_a?(Hash) ? args.pop : nil
         | 
| 90 90 | 
             
                  @id = args.first
         | 
| 91 91 | 
             
                  apply_default_metadata
         | 
| 92 | 
            -
                  if  | 
| 93 | 
            -
                    if  | 
| 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  | 
| 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( | 
| 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
         | 
| @@ -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( | 
| 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( | 
| 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( | 
| 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( | 
| 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  | 
| 5 | 
            -
             | 
| 6 | 
            -
                describe  | 
| 7 | 
            -
                   | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 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 | 
            -
             | 
| 14 | 
            -
             | 
| 12 | 
            +
                  describe "lazy loading" do
         | 
| 13 | 
            +
                    subject { described_class.new(id) }
         | 
| 15 14 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
                    let(:id) { "ark:/99999/fk4fn19h88" }
         | 
| 16 | 
            +
                    let(:real) { double(id: id, target: "http://ezid.cdlib.org/id/#{id}") }
         | 
| 18 17 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 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. | 
| 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- | 
| 11 | 
            +
            date: 2016-03-03 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: hashie
         |