lib/robot-controller/robots.rb in robot-controller-0.3.4 vs lib/robot-controller/robots.rb in robot-controller-0.3.5
- old
+ new
@@ -25,11 +25,11 @@
# parse_lanes('A , B') == ['A', 'B']
# parse_lanes('A,B,C') == ['A','B','C']
# parse_lanes('A-C,E') == ['A-C', 'E']
def parse_lanes(lanes_spec)
return ['default'] if lanes_spec.split(/,/).collect {|l| l.strip}.join('') == ''
- lanes_spec.split(/,/).collect {|l| l.strip }
+ lanes_spec.split(/,/).collect {|l| l.strip }.uniq
end
# build_queues('z','A') => ['z_A']
# build_queues('z','A,C') => ['z_A', 'z_C']
def build_queues(robot, lanes)
@@ -39,23 +39,24 @@
end
queues
end
# main entry point
- def load(env)
- # read the YAML file
- robots_fn = File.join('config', 'environments', "robots_#{env}.yml")
+ def load(robots_fn, dir = 'config/environments', host = nil)
+ # Validate parameters
+ robots_fn = File.join(dir, robots_fn) if dir
unless File.file?(robots_fn)
raise RuntimeError, "FileNotFound: #{robots_fn}"
end
+ # read the YAML file
puts "Loading #{robots_fn}"
robots = YAML.load_file(robots_fn)
# puts robots
# determine current host
- host = `hostname -s`.strip
+ host = `hostname -s`.strip unless host
# puts host
# host = 'sul-robots1-dev' # XXX
unless robots.include?(host)
raise RuntimeError, "HostMismatch: #{host} not defined in #{robots_fn}"
@@ -91,8 +92,5 @@
r << {:robot => robot[0], :queues => queues, :n => robot[2] }
end
r
end
end
-
-ROBOTS = RobotConfigParser.new.load(ENV['ROBOT_ENVIRONMENT'] || 'development')
-# puts ROBOTS
\ No newline at end of file