Class: Dataloaderb::ProcessRunner
- Inherits:
-
Object
- Object
- Dataloaderb::ProcessRunner
- Defined in:
- lib/dataloaderb/process_runner.rb
Instance Method Summary collapse
- #execute_process(process_name) ⇒ Object
-
#get_process_bat_path(bin_path) ⇒ Object
Given the path to the Apex Data Loader bin directory, return the expanded path of the process.bat file to be executed.
-
#get_process_execute_command(bin_path, conf_path, process_name) ⇒ Object
Given the path to the Apex Data Loader bin directory, the path to the folder with the process-conf.xml file, and the name of a process defined in the XML to run, return the command that the operating system needs to run to execute the process.
-
#initialize(bin_path, opts = {}) {|_self| ... } ⇒ ProcessRunner
constructor
Create the process runner and specify the path to the Apex Data Loader executable (batch) files.
-
#run(*yamls) ⇒ Object
Run one or more processes.
Constructor Details
#initialize(bin_path, opts = {}) {|_self| ... } ⇒ ProcessRunner
Create the process runner and specify the path to the Apex Data Loader executable (batch) files.
7 8 9 10 11 12 |
# File 'lib/dataloaderb/process_runner.rb', line 7 def initialize(bin_path, opts = {}, &block) @bin_path = bin_path @conf_path = nil @opts = opts yield self if block_given? end |
Instance Method Details
#execute_process(process_name) ⇒ Object
36 37 38 39 |
# File 'lib/dataloaderb/process_runner.rb', line 36 def execute_process(process_name) # @bin_path and @conf_path are full paths at this point `#{get_process_execute_command @bin_path, @conf_path, process_name}` end |
#get_process_bat_path(bin_path) ⇒ Object
Given the path to the Apex Data Loader bin directory, return the expanded path of the process.bat file to be executed.
52 53 54 |
# File 'lib/dataloaderb/process_runner.rb', line 52 def get_process_bat_path(bin_path) File. "#{bin_path}/process.bat" end |
#get_process_execute_command(bin_path, conf_path, process_name) ⇒ Object
Given the path to the Apex Data Loader bin directory, the path to the folder with the process-conf.xml file, and the name of a process defined in the XML to run, return the command that the operating system needs to run to execute the process.
46 47 48 |
# File 'lib/dataloaderb/process_runner.rb', line 46 def get_process_execute_command(bin_path, conf_path, process_name) "#{get_process_bat_path(bin_path)} #{conf_path} #{process_name}" end |
#run(*yamls) ⇒ Object
Run one or more processes. Specify the processes to run by passing one or more paths to process Yaml definitions.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dataloaderb/process_runner.rb', line 16 def run(*yamls) if yamls.empty? || yamls.flatten.empty? raise ArgumentError, "You must pass at least one argument to Dataloaderb::ProcessRunner#run" end creator = Dataloaderb::ConfCreator.new(yamls, @opts) # We now have a Hash of ProcessDefinitions in creator#processes. # We can also access the full XML for the entire set of processes via # creator#to_xml. # We can access a specific process via creator#processes['processName']. begin create_configuration(creator.to_xml) creator.processes.each do |name, definition| execute_process(name) end ensure remove_configuration end end |