Skip to content

Commit

Permalink
Removed whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
dchandekstark committed Apr 27, 2015
1 parent c5dedc3 commit 0c36ca1
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ rvm:
- 2.2
- 2.1
- 2.0.0
cache:
cache:
- bundler
script: "bundle exec rake ci"
2 changes: 1 addition & 1 deletion lib/ezid/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def handle_response(response, request_name)
message = "EZID #{request_name} -- #{response.status_line}"
logger.log(log_level, message)
raise response.exception if response.exception
response
response
end

def execute(request_class, *args)
Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def deletable?
end

# Mark the identifier as unavailable
# @param reason [String] an optional reason
# @param reason [String] an optional reason
# @return [String] the new status
def unavailable!(reason = nil)
if persisted? && reserved?
Expand Down
21 changes: 10 additions & 11 deletions lib/ezid/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Metadata
attr_reader :elements

def_delegators :elements, :[], :[]=, :each, :clear, :to_h, :empty?

class << self
def metadata_reader(element, alias_as=nil)
define_method element do
Expand All @@ -29,7 +29,7 @@ def metadata_writer(element, alias_as=nil)
end
if alias_as
alias_method "#{alias_as}=".to_sym, "#{element}=".to_sym
end
end
end

def metadata_accessor(element, alias_as=nil)
Expand All @@ -38,10 +38,10 @@ def metadata_accessor(element, alias_as=nil)
end

def metadata_profile(profile, *elements)
elements.each do |element|
elements.each do |element|
profile_element = [profile, element].join(".")
method = [profile, element].join("_")

define_method method do
get(profile_element)
end
Expand Down Expand Up @@ -91,9 +91,9 @@ def metadata_profile(profile, *elements)
datacite: [:creator, :title, :publisher, :publicationyear, :resourcetype],
erc: [:who, :what, :when]
}

PROFILES.each do |profile, elements|
metadata_profile profile, *elements
metadata_profile profile, *elements
end

# Accessors for EZID internal metadata elements
Expand All @@ -105,15 +105,15 @@ def metadata_profile(profile, *elements)
metadata_accessor :_target, :target

# Readers for EZID read-only internal metadata elements
metadata_reader :_created
metadata_reader :_created
metadata_reader :_datacenter, :datacenter
metadata_reader :_owner, :owner
metadata_reader :_ownergroup, :ownergroup
metadata_reader :_shadowedby, :shadowedby
metadata_reader :_shadows, :shadows
metadata_reader :_updated
metadata_reader :_updated

# Accessors for
# Accessors for
metadata_accessor :crossref
metadata_accessor :datacite
metadata_accessor :erc
Expand All @@ -136,7 +136,7 @@ def updated
def to_anvl(include_readonly = true)
hsh = elements.dup
hsh.reject! { |k, v| READONLY.include?(k) } unless include_readonly
lines = hsh.map do |name, value|
lines = hsh.map do |name, value|
element = [escape(ESCAPE_NAMES_RE, name), escape(ESCAPE_VALUES_RE, value)]
element.join(ANVL_SEPARATOR)
end
Expand Down Expand Up @@ -206,4 +206,3 @@ def coerce_string(data)

end
end

2 changes: 1 addition & 1 deletion lib/ezid/requests/mint_identifier_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MintIdentifierRequest < Request
self.response_class = MintIdentifierResponse

attr_reader :shoulder, :metadata

def initialize(client, shoulder, metadata)
@shoulder = shoulder
@metadata = Metadata.new(metadata)
Expand Down
6 changes: 3 additions & 3 deletions lib/ezid/requests/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def execute(client, *args)

def short_name
name.split("::").last.sub("Request", "")
end
end
end

attr_reader :client
Expand Down Expand Up @@ -90,10 +90,10 @@ def handle_response(http_response)
private

def get_response_for_request
connection.start do |conn|
connection.start do |conn|
add_authentication if authentication_required?
add_metadata if has_metadata?
conn.request(__getobj__)
conn.request(__getobj__)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/responses/delete_identifier_response.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "identifier_response"

module Ezid
#
#
# Response to a delete identifier request
# @api private
#
Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/responses/get_identifier_metadata_response.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "identifier_response"

module Ezid
#
#
# Response to a get identifier metadata request
# @api private
#
Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/responses/login_response.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "response"

module Ezid
#
#
# Response to a login request
# @api private
#
Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/responses/mint_identifier_response.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require_relative "new_identifier_response"

module Ezid
#
#
# Response to a mint identifier request
# @api private
#
Expand Down
2 changes: 0 additions & 2 deletions spec/integration/identifier_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


module Ezid
RSpec.describe Identifier do

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module Ezid
let(:http_response) { double(body: "success: ark:/99999/fk4fn19h88") }
context "and the :default_shoulder config option is set" do
before do
allow(MintIdentifierRequest).to receive(:execute).with(subject, TEST_ARK_SHOULDER, nil) { stub_response }
allow(MintIdentifierRequest).to receive(:execute).with(subject, TEST_ARK_SHOULDER, nil) { stub_response }
allow(Client.config).to receive(:default_shoulder) { TEST_ARK_SHOULDER }
end
it "should use the default shoulder" do
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/identifier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module Ezid
describe "when saving a persisted object" do
before do
allow(subject).to receive(:persisted?) { true }
allow(subject).to receive(:modify) { nil }
allow(subject).to receive(:modify) { nil }
end
it "should not change the persisted status" do
expect { subject.save }.not_to change(subject, :persisted?)
Expand All @@ -132,7 +132,7 @@ module Ezid
expect(subject.client).to receive(:delete_identifier).with("id") { double(id: "id") }
subject.delete
expect(subject).to be_deleted
end
end
end
context "and is not persisted" do
before { allow(subject).to receive(:persisted?) { false } }
Expand Down
20 changes: 10 additions & 10 deletions spec/unit/metadata_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ module Ezid
expect(subject[writer.to_s]).to eq("value")
end
end

shared_examples "a metadata reader" do |reader|
it "reads the \"#{reader}\" element" do
subject[reader.to_s] = "value"
expect(subject.send(reader)).to eq("value")
end
end

shared_examples "a metadata reader with an alias" do |reader, aliased_as|
it_behaves_like "a metadata reader", reader
it "has a reader alias \"#{aliased_as}\"" do
subject[reader.to_s] = "value"
expect(subject.send(aliased_as)).to eq("value")
end
end

shared_examples "a metadata writer with an alias" do |writer, aliased_as|
it_behaves_like "a metadata writer", writer
it "has a writer alias \"#{aliased_as}\"" do
Expand Down Expand Up @@ -52,7 +52,7 @@ module Ezid
shared_examples "a metadata profile accessor with an alias" do |profile, accessor|
it_behaves_like "a metadata accessor with an alias", [profile, accessor].join("."), [profile, accessor].join("_")
end

describe "_owner" do
it_behaves_like "a metadata reader with an alias", :_owner, :owner
end
Expand All @@ -68,7 +68,7 @@ module Ezid
describe "_datacenter" do
it_behaves_like "a metadata reader with an alias", :_datacenter, :datacenter
end

describe "_coowners" do
it_behaves_like "a metadata accessor with an alias", :_coowners, :coowners
end
Expand All @@ -84,7 +84,7 @@ module Ezid
describe "_export" do
it_behaves_like "a metadata accessor with an alias", :_export, :export
end

describe "_created" do
it_behaves_like "a metadata reader", :_created
it_behaves_like "a time reader alias", :_created, :created
Expand All @@ -93,7 +93,7 @@ module Ezid
it_behaves_like "a metadata reader", :_updated
it_behaves_like "a time reader alias", :_updated, :updated
end

describe "erc" do
it_behaves_like "a metadata accessor", :erc
end
Expand All @@ -106,7 +106,7 @@ module Ezid
describe "crossref" do
it_behaves_like "a metadata accessor", :crossref
end

describe "dc.creator" do
it_behaves_like "a metadata profile accessor with an alias", :dc, :creator
end
Expand All @@ -122,7 +122,7 @@ module Ezid
describe "dc.type" do
it_behaves_like "a metadata profile accessor with an alias", :dc, :type
end

describe "datacite.creator" do
it_behaves_like "a metadata profile accessor with an alias", :datacite, :creator
end
Expand All @@ -138,7 +138,7 @@ module Ezid
describe "datacite.resourcetype" do
it_behaves_like "a metadata profile accessor with an alias", :datacite, :resourcetype
end

describe "erc.who" do
it_behaves_like "a metadata profile accessor with an alias", :erc, :who
end
Expand Down

0 comments on commit 0c36ca1

Please sign in to comment.