Build Status Coverage Status Gem Version

lyber_core

Robot Creation

Create a class that mixes in LyberCore::Robot

  • In the initializer, call super with the repository, workflow name, step name
  • Your class #perform method will perform the actual work, with druid passed in as the one and only argument
module Robots
  module DorRepo
    module Accession

      class Shelve
        include LyberCore::Robot

        def initialize
          super('dor', 'accessionWF', 'shelve')
        end

        def perform druid
          obj = Dor::Item.find(druid)
          obj.shelve
        end

      end

    end
  end
end

By default, the druid will be set to the completed state, but you can optionally have it set to skipped by creating a ReturnState object as shown below. You can also return custom notes in this way ```ruby module Robots module DorRepo module Accession

  class Shelve
    include LyberCore::Robot

    def initialize
      super('dor', 'accessionWF', 'shelve')
    end

    def perform druid
      obj = Dor::Item.find(druid)
      if some_logic_here_to_determine_if_shelving_occurs
        obj.shelve
        return LyberCore::Robot::ReturnState.new(status: 'completed') # set the final state to completed

return LyberCore::Robot::ReturnState.new(status: 'completed', note: 'some custom note to pass back to workflow') # set the final state to completed with a custom note

      else
        # just return skipped if we did nothing
        return LyberCore::Robot::ReturnState.new(status: 'skipped') # set the final state to skipped

return LyberCore::Robot::ReturnState.new(status: 'skipped', note: 'some custom note to pass back to workflow') # set the final state to skipped with a custom note

      end
    end

  end

end

end end ```

Robot Environment Setup

  • Create a config/boot.rb file to load the classpath, classes and configuration that your robot will need in order to run. See the boot.rb file from the Common-Accessioning robot suite as an example

  • Add require 'resque/tasks' to your Rakefile

  • Create an environment task within your Rakefile that requires your config/boot.rb file

Example Rakefile modifications

require 'robot-controller/tasks'
...
task :environment do
  require_relative 'config/boot'
end

Start the Robot

  • Use rake to start your robot, specifying the Resque queue as the environment variable QUEUE
$ QUEUE=accessionWF_shelve rake environment workers

Enqueing a Job

require 'resque'
Resque.enqueue_to('accessionWF_shelve'.to_sym, Robot::DorRepo::Accession::Shelve, 'druid:aa123bb4567')

Releases

  • 4.0 Remove unused classes and dependencies
  • 3.0 Robot overhaul. Use resque for job management and bluepill for process management
  • 2.1.1 Relax dor-services-gem version requirement
  • 2.0 Moved what was left of DorService (namely get_objects_for_workstep()) to dor-services' Dor::WorkflowService. Removed IdentityMetadata and DublinCore XML models. Factored out all remaining global constants. Removed unnecessary dependencies.
  • 1.3 Started to use Dor::Config for workspace configuration
  • 1.0.0 Factored all Dor::* classes and object models out of lyber-core and into a separate dor-services gem. WARNING: MAY BREAK COMPATIBILITY WITH PREVIOUS DOR-ENABLED CODE.
  • 0.9.8 Created branch for legacy work "0.9-legacy". Robots can now be configured with fully qualified workflows for prerequisites eg dor:googleScannedBookWF:register-object
  • 0.9.2 Workflow bug fixes. Last version that supports active-fedora 1.0.7
  • We recommend that you DO NOT USE any version older than these

Copyright

Copyright (c) 2014-16 Stanford University Library. See LICENSE for details.