Skip to content

Commit

Permalink
Appease rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcolvar committed Apr 3, 2018
1 parent dbfd450 commit 609f00e
Show file tree
Hide file tree
Showing 13 changed files with 457 additions and 414 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Metrics/BlockLength:
Naming/MethodName:
Exclude:
- 'lib/iiif_manifest/manifest_builder/iiif_service.rb'
- 'lib/iiif_manifest/v3/manifest_builder/iiif_service.rb'

RSpec/MultipleExpectations:
Enabled: false
14 changes: 14 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Metrics/AbcSize:
Exclude:
- 'lib/iiif_manifest/manifest_builder/resource_builder.rb'
- 'lib/iiif_manifest/manifest_factory.rb'
- 'lib/iiif_manifest/v3/manifest_builder/resource_builder.rb'
- 'lib/iiif_manifest/v3/manifest_factory.rb'

# Offense count: 1
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
Expand Down Expand Up @@ -41,6 +43,7 @@ RSpec/VerifiedDoubles:
RSpec/ExampleLength:
Exclude:
- 'spec/lib/iiif_manifest/manifest_factory_spec.rb'
- 'spec/lib/iiif_manifest/v3/manifest_factory_spec.rb'

# Offense count: 20
Style/Documentation:
Expand All @@ -66,7 +69,18 @@ Style/Documentation:
- 'lib/iiif_manifest/manifest_service_locator.rb'
- 'lib/iiif_manifest.rb'
- 'lib/iiif_manifest/manifest_builder/iiif_service.rb'
- 'lib/iiif_manifest/v3.rb'
- 'lib/iiif_manifest/v3/manifest_factory.rb'
- 'lib/iiif_manifest/v3/manifest_builder/structure_builder.rb'
- 'lib/iiif_manifest/v3/manifest_builder/iiif_service.rb'
- 'lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb'
- 'lib/iiif_manifest/v3/manifest_builder/image_builder.rb'
- 'lib/iiif_manifest/v3/manifest_builder/resource_builder.rb'
- 'lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb'
- 'lib/iiif_manifest/v3/manifest_builder.rb'
- 'lib/iiif_manifest/v3/manifest_service_locator.rb'
- 'spec/lib/iiif_manifest/manifest_factory_spec.rb'
- 'spec/lib/iiif_manifest/v3/manifest_factory_spec.rb'

# Offense count: 1
Style/MethodMissing:
Expand Down
12 changes: 7 additions & 5 deletions lib/iiif_manifest/v3.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
require 'active_support/core_ext/module'
require 'active_support/core_ext/object'

module IIIFManifest::V3
extend ActiveSupport::Autoload
autoload :ManifestBuilder
autoload :ManifestFactory
autoload :ManifestServiceLocator
module IIIFManifest
module V3
extend ActiveSupport::Autoload
autoload :ManifestBuilder
autoload :ManifestFactory
autoload :ManifestServiceLocator
end
end
44 changes: 23 additions & 21 deletions lib/iiif_manifest/v3/manifest_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@
require_relative 'manifest_builder/resource_builder'
require_relative 'manifest_builder/structure_builder'

module IIIFManifest::V3
class ManifestBuilder
attr_reader :work,
:builders,
:top_record_factory
def initialize(work, builders:, top_record_factory:)
@work = work
@builders = builders
@top_record_factory = top_record_factory
end
module IIIFManifest
module V3
class ManifestBuilder
attr_reader :work,
:builders,
:top_record_factory
def initialize(work, builders:, top_record_factory:)
@work = work
@builders = builders
@top_record_factory = top_record_factory
end

def apply(collection)
collection['manifests'] ||= []
collection['manifests'] << to_h
collection
end
def apply(collection)
collection['manifests'] ||= []
collection['manifests'] << to_h
collection
end

def to_h
@to_h ||= builders.new(work).apply(top_record)
end
def to_h
@to_h ||= builders.new(work).apply(top_record)
end

private
private

def top_record
top_record_factory.new
def top_record
top_record_factory.new
end
end
end
end
24 changes: 13 additions & 11 deletions lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
module IIIFManifest::V3
class ManifestBuilder
class CanvasBuilder < ::IIIFManifest::ManifestBuilder::CanvasBuilder
def apply(items)
return items if canvas.items.blank?
items << canvas
end
module IIIFManifest
module V3
class ManifestBuilder
class CanvasBuilder < ::IIIFManifest::ManifestBuilder::CanvasBuilder
def apply(items)
return items if canvas.items.blank?
items << canvas
end

private
private

def apply_record_properties
canvas['id'] = path
canvas.label = record.to_s
def apply_record_properties
canvas['id'] = path
canvas.label = record.to_s
end
end
end
end
Expand Down
Loading

0 comments on commit 609f00e

Please sign in to comment.