class Object
Public Instance Methods
get_scene(scenes, name)
click to toggle source
# File lib/domain/scene.rb, line 12 def get_scene(scenes, name) Scene for scene in scenes scene_name = scene["name"] if scene_name == name return Scene.new(scene_name, scene["place"], scene["props"], scene["actions"]) end end end
os()
click to toggle source
# File lib/infra/os.rb, line 1 def os @os ||= ( host_os = RbConfig::CONFIG['host_os'] case host_os when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ :windows when /darwin|mac os/ :macosx when /linux/ :linux when /solaris|bsd/ :unix else raise Error::WebDriverError, "unknown os: #{host_os.inspect}" end ) end
run(scene_name)
click to toggle source
# File lib/main.rb, line 6 def run(scene_name) if scene_name == "-v" puts "0.0.3" return end os = os() cmd_keywords = CMDKeywordsFactory.get_cmd_keywords(os) if cmd_keywords == nil puts "暂不支持 #{os} 操作系统" return end cd = cmd_keywords[:cd] cp = cmd_keywords[:cp] rm = cmd_keywords[:rm] join = cmd_keywords[:and] dir_pwd = Dir.pwd filepath = File.join(dir_pwd, 'playbook.toml') playbook = TOML.load_file(filepath) scenes = playbook["scenes"] scene = get_scene(scenes, scene_name) if !scene.is_a?(Scene) puts "没有名称为#{scene_name}的场景" else place = scene.place place = (place.start_with? "~") ? dir_pwd + place[1..-1] : place goToPlace = "#{cd} #{place}" actions = scene.actions commands = Array.new props = scene.props if props.nil? commands.push(goToPlace).concat(actions) else placeProps = Array.new cleanProps = Array.new for prop in props placeProps.push("#{cp} #{File.join(dir_pwd, prop)} #{place}/#{prop}") cleanProps.push("#{rm} #{prop}") end commands.push(placeProps, goToPlace).concat(actions).push(cleanProps) end act = commands.join(" #{join} ") system act end end