Class: OAI::Harvester::Shell

Inherits:
Object
  • Object
show all
Includes:
Readline
Defined in:
lib/oai/harvester/shell.rb

Overview

OAI::Harvester::Shell

A OAI-PMH client shell allowing OAI Harvesting to be configured in an interactive manner. Typing ‘oai’ on the command line starts the shell. The first time the shell is run it will prompt for the following configuration details:

  1. A storage directory for all harvested records. Harvests will be stored under this directory in a directory structure based on the date of the harvest.

  2. A log file directory.

  3. Email address(es) for sending daily harvesting activity reports.

  4. Network address of the SMTP server for sending mail.

After the initial configuration, new harvest sites can be added by using the ‘new’ command. Sites are identified via nickname assigned by the user. After choosing a nickname, provide the URL of a harvestable site, and the shell will prompt you for the rest of the configuration information.

The shell automatically pulls down the list of sets in the repository, and the supported metadata prefixes. Making it very simple to setup harvests.

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Shell

Returns a new instance of Shell.



28
29
30
31
# File 'lib/oai/harvester/shell.rb', line 28

def initialize(config)
  @conf = config
  @conf.sites ||= {} # Initialize sites hash there isn't one
end

Instance Method Details

#startObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/oai/harvester/shell.rb', line 33

def start
  unless @conf.storage
    banner "Entering first-time setup"
    config
    setup_cron
  end
  puts "type 'help' for help"
  while((input = readline("oai> ", true)) != 'exit')
    begin
      cmd = input.split
      if 1 == cmd.size
        self.send(cmd[0])
      else
        self.send(cmd.shift, cmd.join(" "))
      end
    rescue NoMethodError
        puts "Not a recognized command. Type 'help' for clues."
    rescue
        puts "An error occurred:"
        puts $!
        puts $!.backtrace.join("\n")
    end
  end
end