Skip to content

Commit

Permalink
Merge pull request #558 from projecthydra-labs/address-yard-warnings
Browse files Browse the repository at this point in the history
Address yard warnings
  • Loading branch information
mjgiarlo authored Mar 14, 2017
2 parents 652d8f3 + b81ae7d commit bbec0db
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 46 deletions.
3 changes: 1 addition & 2 deletions app/actors/hyrax/actors/file_set_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def initialize(file_set, user)
# create_content, which also performs a save. However, due to the relationship between Hydra::PCDM objects,
# we have to save both the parent work and the file_set in order to record the "metadata" relationship
# between them.
# @param [ActiveFedora::Base] work the parent work that will contain the file_set.
# @param [Hash] file_set specifying the visibility, lease and/or embargo of the file set.
# @param [Hash] file_set_params specifying the visibility, lease and/or embargo of the file set.
# If you don't provide at least one of visibility, embargo_release_date or
# lease_expiration_date, visibility will be copied from the parent.
def create_metadata(file_set_params = {})
Expand Down
2 changes: 1 addition & 1 deletion app/actors/hyrax/create_with_remote_files_actor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def update(attributes)

protected

# @param [HashWithIndifferentAccess]
# @param [HashWithIndifferentAccess] remote_files
# @return [TrueClass]
def attach_files(remote_files)
return true unless remote_files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def create
end

# Finds a solr document matching the id and sets @presenter
# @raises CanCan::AccessDenied if the document is not found
# or the user doesn't have access to it.
# @raise CanCan::AccessDenied if the document is not found or the user doesn't have access to it.
def show
respond_to do |wants|
wants.html { presenter && parent_presenter }
Expand Down
3 changes: 1 addition & 2 deletions app/forms/hyrax/forms/admin_set_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ class AdminSetForm < Hyrax::Forms::CollectionForm
self.model_class = AdminSet
self.terms = [:title, :description, :thumbnail_id]

# @param model [AdminSet]
# @param permission_template [PermissionTemplate]
# @param [AdminSet] model
def initialize(model)
super(model)
end
Expand Down
4 changes: 2 additions & 2 deletions app/indexers/hyrax/indexes_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ def generate_solr_document
end

# Write the suppressed status into the solr_document
# @params [Hash] solr_document the solr document to add the field to
# @param [Hash] solr_document the solr document to add the field to
def index_suppressed(solr_document)
solr_document[suppressed_field] = object.suppressed?
end

# Write the workflow roles and state so one can see where the document moves to next
# @params [Hash] solr_document the solr document to add the field to
# @param [Hash] solr_document the solr document to add the field to
def index_workflow_fields(solr_document)
return unless object.persisted?
entity = PowerConverter.convert_to_sipity_entity(object)
Expand Down
4 changes: 2 additions & 2 deletions app/jobs/attach_files_to_work_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
class AttachFilesToWorkJob < ActiveJob::Base
queue_as Hyrax.config.ingest_queue_name

# @param [ActiveFedora::Base] the work class
# @param [Array<UploadedFile>] an array of files to attach
# @param [ActiveFedora::Base] work - the work object
# @param [Array<UploadedFile>] uploaded_files - an array of files to attach
def perform(work, uploaded_files)
uploaded_files.each do |uploaded_file|
file_set = FileSet.new
Expand Down
6 changes: 3 additions & 3 deletions app/jobs/audit_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class AuditJob < ActiveJob::Base
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content/fcr:versions/version1
# but it could also just be:
# http://localhost:8983/fedora/rest/test/a/b/c/abcxyz/content
# @param [FileSet] the parent object
# @param [String] file_id used to find the file within its parent object (usually "original_file")
# @param [String] uri of the specific file/version to be audited
# @param [FileSet] file_set - the parent object
# @param [String] file_id - used to find the file within its parent object (usually "original_file")
# @param [String] uri - of the specific file/version to be audited
def perform(file_set, file_id, uri)
log = run_audit(file_set, file_id, uri)
fixity_ok = log.pass == 1
Expand Down
2 changes: 1 addition & 1 deletion app/models/hyrax/permission_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def valid_release_date?(date)
end

# Determines whether a given visibility setting is valid based on this template's requirements
# @param [String] visibility value to validate
# @param [String] value - visibility value to validate
def valid_visibility?(value)
# If template doesn't specify a visiblity (i.e. is "varies"), then any visibility is valid
return true unless visibility.present?
Expand Down
2 changes: 1 addition & 1 deletion app/search_builders/hyrax/filter_by_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def generic_type_field

# Override this method if you want to limit some of the registered
# types from appearing in search results
# @returns [Array<Class>] the list of work types to include in searches
# @return [Array<Class>] the list of work types to include in searches
def work_types
Hyrax.config.curation_concerns
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/derivative_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DerivativePath
class << self
# Path on file system where derivative file is stored
# @param [ActiveFedora::Base or String] object either the AF object or its id
# @param [String] destintation_name
# @param [String] destination_name
def derivative_path_for_reference(object, destination_name)
new(object, destination_name).derivative_path
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/indexes_thumbnails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def generate_solr_document
end

# Write the thumbnail paths into the solr_document
# @params [Hash] solr_document the solr document to add the field to
# @param [Hash] solr_document the solr document to add the field to
def index_thumbnails(solr_document)
solr_document[thumbnail_field] = thumbnail_path
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/hyrax/parent_service.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Hyrax
class ParentService
# @param [String] the id of a child FileSet
# @param [String] id - the id of a child FileSet
# @return [ActiveFedora::Base] the parent object
def self.parent_for(id)
ids = ordered_by_ids(id)
Expand Down
6 changes: 3 additions & 3 deletions app/services/hyrax/thumbnail_path_service.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Hyrax
class ThumbnailPathService
class << self
# @param [Work, FileSet] the object to get the thumbnail for
# @param [Work, FileSet] object - to get the thumbnail for
# @return [String] a path to the thumbnail
def call(object)
return default_image unless object.thumbnail_id
Expand Down Expand Up @@ -44,12 +44,12 @@ def audio_image
end

# @return true if there a file on disk for this object, otherwise false
# @param [FileSet] thumbnail the object that is the thumbnail
# @param [FileSet] thumb - the object that is the thumbnail
def thumbnail?(thumb)
File.exist?(thumbnail_filepath(thumb))
end

# @param [FileSet] thumbnail the object that is the thumbnail
# @param [FileSet] thumb - the object that is the thumbnail
def thumbnail_filepath(thumb)
Hyrax::DerivativePath.derivative_path_for_reference(thumb, 'thumbnail')
end
Expand Down
8 changes: 4 additions & 4 deletions app/services/hyrax/workflow/sipity_actions_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class SipityActionsGenerator
#
# Responsible for creating database entries for the given workflow's actions
#
# @param workflow [Sipity::Workflow]
# @param actions_configuration [Hash] as defined in Hyrax::Workflow::WorkflowSchema
# @param [Sipity::Workflow] workflow
# @param [Hash] actions_configuration as defined in Hyrax::Workflow::WorkflowSchema
# @return [Sipity::Workflow]
# @raise [Hyrax::Workflow::InvalidStateRemovalException] Trying to remove a state that is in use
def self.call(**keywords, &block)
new(**keywords, &block).call
def self.call(workflow:, actions_configuration:, &block)
new(workflow: workflow, actions_configuration: actions_configuration, &block).call
end

def initialize(workflow:, actions_configuration:)
Expand Down
4 changes: 2 additions & 2 deletions app/services/hyrax/workflow/state_machine_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def build_transitions(name)
action.save!
end

# @params state_names[Array]
# @params roles [Array]
# @param [Array] state_names
# @param [Array] state_roles
def build_from_state(state_names, state_roles)
Array.wrap(state_names).each do |state_name|
workflow_state = Sipity::WorkflowState.find_or_create_by!(workflow: workflow, name: state_name.to_s)
Expand Down
32 changes: 16 additions & 16 deletions app/services/hyrax/workflow/workflow_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ def clear_load_errors!
# @api public
# Load all of the workflows for the given permission_template
#
# @param permission_template [Hyrax::PermissionTemplate]
# @param logger [#info, #debug, #warning, #fatal] By default this is Hyrax::Workflow::WorkflowImporter.default_logger
# @param [Hyrax::PermissionTemplate] permission_template
# @param [#info, #debug, #warning, #fatal] logger - By default this is Hyrax::Workflow::WorkflowImporter.default_logger
# @return [TrueClass] if one or more workflows were loaded
# @return [FalseClass] if no workflows were loaded
# @note I'd like to deprecate .load_workflows but for now that is beyond the scope of what I'm after. So I will use its magic instead
Expand All @@ -46,7 +46,7 @@ def self.load_workflow_for(permission_template:, logger: default_logger)
# @api public
#
# Load all the workflows in config/workflows/*.json for each of the permission templates
# @param permission_templates [#each] An enumerator of permission templates (by default Hyrax::PermissionTemplate.all)
# @param [#each] permission_templates - An enumerator of permission templates (by default Hyrax::PermissionTemplate.all)
# @return [TrueClass]
def self.load_workflows(permission_templates: Hyrax::PermissionTemplate.all, **kwargs)
clear_load_errors!
Expand All @@ -60,35 +60,35 @@ def self.load_workflows(permission_templates: Hyrax::PermissionTemplate.all, **k
#
# Responsible for generating the work type and corresponding processing entries based on given pathname or JSON document.
#
# @param path [#read or String] the location on the file system that can be read
# @param permission_template [Hyrax::PermissionTemplate] the permission_template that will be associated with each of these entries
# @param [#read or String] path - the location on the file system that can be read
# @param [Hyrax::PermissionTemplate] permission_template - the permission_template that will be associated with each of these entries
# @return [Array<Sipity::Workflow>]
def self.generate_from_json_file(path:, **keywords)
def self.generate_from_json_file(path:, permission_template:, **keywords)
contents = path.respond_to?(:read) ? path.read : File.read(path)
data = JSON.parse(contents)
generate_from_hash(data: data, **keywords)
generate_from_hash(data: data, permission_template: permission_template, **keywords)
end

# @api public
#
# Responsible for generating the work type and corresponding processing entries based on given pathname or JSON document.
#
# @param data [#deep_symbolize_keys] the configuration information from which we will generate all the data entries
# @param permission_template [Hyrax::PermissionTemplate] the permission_template that will be associated with each of these entries
# @param [#deep_symbolize_keys] data - the configuration information from which we will generate all the data entries
# @param [Hyrax::PermissionTemplate] permission_template - the permission_template that will be associated with each of these entries
# @return [Array<Sipity::Workflow>]
def self.generate_from_hash(data:, **keywords)
importer = new(data: data, **keywords)
def self.generate_from_hash(data:, permission_template:, **keywords)
importer = new(data: data, permission_template: permission_template, **keywords)
workflows = importer.call
self.load_errors ||= []
load_errors.concat(importer.errors)
workflows
end

# @param data [#deep_symbolize_keys] the configuration information from which we will generate all the data entries
# @param permission_template [Hyrax::PermissionTemplate] the permission_template that will be associated with each of these entries
# @param schema [#call] The schema in which you will validate the data
# @param validator [#call] The validation service for the given data and schema
# @param logger [#debug, #info, #fatal, #warning] The logger to capture any meaningful output
# @param [#deep_symbolize_keys] data - the configuration information from which we will generate all the data entries
# @param [Hyrax::PermissionTemplate] permission_template - the permission_template that will be associated with each of these entries
# @param [#call] schema - The schema in which you will validate the data
# @param [#call] validator - The validation service for the given data and schema
# @param [#debug, #info, #fatal, #warning] logger - The logger to capture any meaningful output
def initialize(data:, permission_template:, schema: default_schema, validator: default_validator, logger: default_logger)
self.data = data
self.schema = schema
Expand Down
4 changes: 2 additions & 2 deletions lib/hyrax/collections/search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def last_search_documents
end

# filter that sets up access-controlled lucene query in order to provide gated search behavior
# @param solr_parameters the current solr parameters
# @param user_parameters the current user-submitted parameters
# @param [Hash] solr_parameters the current solr parameters
# @param [Hash] _user_parameters the current user-submitted parameters
def apply_gated_search(solr_parameters, _user_parameters)
solr_parameters[:fq] ||= []

Expand Down

0 comments on commit bbec0db

Please sign in to comment.