Skip to content

Commit

Permalink
placate ruboc*p
Browse files Browse the repository at this point in the history
  • Loading branch information
mnyrop committed Sep 11, 2020
1 parent b58b6d5 commit ec584f7
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
AllCops:
NewCops: enable
TargetRubyVersion: 2.4
Exclude: ['spec/**/*', 'test_build/**/*']
Layout/LineLength:
IgnoredPatterns: ['raise', 'puts', 'set', 'warn', 'ÈÉÊË', 'EEEE', 'safe_join', 'spec']
Metrics/AbcSize:
Max: 26
Max: 28
Metrics/MethodLength:
Max: 15
Layout/EmptyComment:
Enabled: false
Layout/EmptyLineAfterGuardClause:
Enabled: false
Style/SingleArgumentDig:
Enabled: false
2 changes: 0 additions & 2 deletions lib/wax_tasks/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ module WaxTasks
class Asset
attr_reader :id, :path



def initialize(path, pid, variants)
@path = path
@pid = pid
Expand Down
19 changes: 9 additions & 10 deletions lib/wax_tasks/collection/images.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ def items_from_imagedata
records = records_from_metadata
Dir.glob(Utils.safe_join(@imagedata_source, '*')).map do |path|
item = WaxTasks::Item.new(path, @image_variants)
if item.valid?
item.record = records.find { |r| r.pid == item.pid }
item.iiif_config = @config.dig 'images', 'iiif'
warn Rainbow("\nCould not find record in #{@metadata_source} for image item #{path}.\n").orange if item.record.nil?
item
else
puts Rainbow("Skipping #{path} because type #{item.type} is not an accepted format").yellow unless item.type == '.pdf'
end
next if item.type == '.pdf'
next puts Rainbow("Skipping #{path} because type #{item.type} is not an accepted format").yellow unless item.valid?

item.record = records.find { |r| r.pid == item.pid }
item.iiif_config = @config.dig 'images', 'iiif'
warn Rainbow("\nCould not find record in #{@metadata_source} for image item #{path}.\n").orange if item.record.nil?
item
end.compact
end

Expand Down Expand Up @@ -97,8 +96,8 @@ def add_iiif_results_to_records(records, manifests)

json = JSON.parse manifest.to_json
@image_variants.each do |k, _v|
value = json.dig k
record.set k, "/#{Utils.content_clean(value)}" unless value.nil?
value = json.fetch k, ''
record.set k, "/#{Utils.content_clean(value)}" unless value.empty?
end

record.set 'manifest', "/#{Utils.content_clean(manifest.id)}"
Expand Down
2 changes: 1 addition & 1 deletion lib/wax_tasks/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def type
#
#
def valid?
accepted_image_formats.include?(@type) || @type == 'dir'
accepted_image_formats.include? @type or @type == 'dir'
end

#
Expand Down
4 changes: 2 additions & 2 deletions lib/wax_tasks/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def self.content_clean(str)
str.gsub!(/\A---(.|\n)*?---/, '') # remove yaml front matter
str.gsub!(/{%(.*)%}/, '') # remove functional liquid
str.gsub!(/{{.*}}/, '') # remove referential liquid
str.gsub!(%r{<\/?[^>]*>}, '') # remove html
str.gsub!(%r{</?[^>]*>}, '') # remove html
str.gsub!('\\n', '') # remove newlines
str.gsub!(/\s+/, ' ') # remove extra space
str.tr!('"', "'") # replace double quotes with single
Expand All @@ -114,7 +114,7 @@ def self.slug(str)
#
#
def self.safe_join(*args)
File.join(args.compact).sub %r{^\/}, ''
File.join(args.compact).sub %r{^/}, ''
end

# Constructs the order variable for each page (if the collection
Expand Down
2 changes: 2 additions & 0 deletions lib/wax_tasks/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module WaxTasks
VERSION = '1.1.2'
end
2 changes: 1 addition & 1 deletion wax_tasks.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
spec.summary = 'Rake tasks for minimal exhibition sites with Minicomp/Wax.'
spec.description = 'Rake tasks for minimal exhibition sites with Minicomp/Wax.'

spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
spec.files = Dir.chdir(File.expand_path(__dir__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end

Expand Down

0 comments on commit ec584f7

Please sign in to comment.