项目作者: lulibrary

项目描述 :
Batch processing for the Pure Research Information System
高级语言: Ruby
项目地址: git://github.com/lulibrary/research_metadata_batch.git
创建时间: 2018-09-21T14:55:49Z
项目社区:https://github.com/lulibrary/research_metadata_batch

开源协议:

下载


Research Metadata Batch

Batch processing for the Pure Research Information System.

Status

Gem Version
Maintainability

Installation

Add this line to your application’s Gemfile:

  1. gem 'research_metadata_batch'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install research_metadata_batch

Basic usage

Uses the default gem behaviour which merely inspects the metadata models using STDOUT.

  1. pure_config = {
  2. url: ENV['PURE_URL'],
  3. username: ENV['PURE_USERNAME'],
  4. password: ENV['PURE_PASSWORD'],
  5. api_key: ENV['PURE_API_KEY']
  6. }
  7. ResearchMetadataBatch::Dataset.new(pure_config: pure_config).process

Creating an application

Either open up classes or create subclasses to implement application-specific behaviour.

This example creates subclasses and uses Amazon Web Services.

shared.rb

Implement methods from {ResearchMetadataBatch::Shared}.

  1. # require aws sdk
  2. module App
  3. module Shared
  4. def init(aws_config:)
  5. # Do something with :aws_config
  6. end
  7. def act(model)
  8. # Do something with Amazon Web Services
  9. return {key1: 'some_value', key2: 'another_value', msg: 'what_happened'}
  10. end
  11. end
  12. end

research_output.rb

  1. require_relative 'shared'
  2. module App
  3. class ResearchOutput < ResearchMetadataBatch::ResearchOutput
  4. include App::Shared
  5. end
  6. end

script.rb

  1. require 'research_metadata_batch'
  2. require_relative 'research_output'
  3. pure_config = {
  4. url: ENV['PURE_URL'],
  5. username: ENV['PURE_USERNAME'],
  6. password: ENV['PURE_PASSWORD'],
  7. api_key: ENV['PURE_API_KEY']
  8. }
  9. aws_config = {
  10. # details
  11. }
  12. log_file = '/path/to/your/log/file'
  13. config = {
  14. pure_config: pure_config,
  15. log_file: log_file
  16. }
  17. batch = App::ResearchOutput.new config
  18. batch.init aws_config: aws_config
  19. params = {
  20. size: 50,
  21. typeUri: [
  22. '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontojournal/article',
  23. '/dk/atira/pure/researchoutput/researchoutputtypes/contributiontoconference/paper'
  24. ]
  25. }
  26. batch.process params: params