Module: OpenAccess::APC

Includes:
Exceptions
Defined in:
lib/openaccess/apc.rb,
lib/openaccess/apc/version.rb,
lib/openaccess/apc/exceptions.rb

Overview

Methods for managing open access article publishing charges (APCs)

Defined Under Namespace

Modules: Exceptions

Constant Summary collapse

VERSION =
'0.2.0'.freeze

Class Method Summary collapse

Class Method Details

.configure {|config| ... } ⇒ void

This method returns an undefined value.

Sets the module configuration

Yields:

  • (config)

    Passes the configuration hash to the block

Yield Parameters:

  • config (Hash)

    the configuration hash



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/openaccess/apc.rb', line 160

def self.configure
  # Get user-supplied configuration from the block
  yield(@config)

  # LDAP client for person resolution
  @ldap = configure_ldap

  # Pure clients
  @person_extractor = Puree::Extractor::Person.new(@config[:pure])
  @person_query = Puree::Query::Person.new(@config[:pure])
end

.person(username = nil, employee_id: nil) ⇒ String

Returns the Pure person UUID given a network username

Parameters:

  • username (String) (defaults to: nil)

    the network username

Returns:

  • (String)

    the Pure UUID of the corresponding person

Raises:



175
176
177
178
179
180
181
# File 'lib/openaccess/apc.rb', line 175

def self.person(username = nil, employee_id: nil)
  employee_id ||= person_employee_id(username)
  person = @person_extractor.find_by_id(employee_id: employee_id)
  return person.uuid unless person.nil?
  raise UserNotFound, 'No user for employee ID: ' \
                      "#{employee_id} (username: #{username})"
end

.publications_for_person(username, **opts) ⇒ Object

Returns an array of publication summary details for the N most recent funding-eligible publications

Parameters:

  • username (String)

    the network username

  • opts (Hash)

    the options hash

Options Hash (**opts):

  • :created_end (Date, DateTime, String, Time)

    include publications deposited on or up to this date

  • :created_start (Date, DateTime, String, Time)

    include publications deposited on or after this date

  • :results (Integer)

    the number of eligible publications required



193
194
195
196
197
198
# File 'lib/openaccess/apc.rb', line 193

def self.publications_for_person(username, **opts)
  person_uuid = person(username)
  publications_criteria(opts)
  pubs = @person_query.publications_extended(uuid: person_uuid, **opts)
  publications_summary(pubs[0..opts[:results]])
end