scene_player 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/act +5 -0
- data/lib/domain/scene.rb +19 -0
- data/lib/main.rb +34 -0
- data/lib/scene_player.rb +8 -5
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 487aff1a763013e27b35270376797438d8a7cefb54a9ea07b87603c452cc3c5a
|
4
|
+
data.tar.gz: 40990b60a3818a478568bd3c31615d4e7efecbb914b950d7bef55cecf4b82b8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 370a5271c984eed8a8539749a00de2e9d0d1599f9b2c56f6be219a89ace4c586096720de5ff2b394bc12a32ac65e9e34b4360eea40625fd36feda96eee2b2152
|
7
|
+
data.tar.gz: d1196cc080ba82bbcecc30c723d6bdca1521309ebd5d4750dd9f90070b5571e9067cefe38c91a27e1426713c9bbc2c04db4e1257fba13a2b118fd853ca58c8c1
|
data/bin/act
ADDED
data/lib/domain/scene.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
class Scene
|
3
|
+
attr_reader :name, :place, :props, :actions
|
4
|
+
def initialize(name, place, props, actions)
|
5
|
+
@name = name
|
6
|
+
@place = place
|
7
|
+
@props = props
|
8
|
+
@actions = actions
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_scene(scenes, name) Scene
|
13
|
+
for scene in scenes
|
14
|
+
scene_name = scene["name"]
|
15
|
+
if scene_name == name
|
16
|
+
return Scene.new(scene_name, scene["place"], scene["props"], scene["actions"])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/main.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require "toml"
|
2
|
+
require_relative "domain/scene.rb"
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
def run(scene_name)
|
6
|
+
dir_pwd = Dir.pwd
|
7
|
+
filepath = File.join(dir_pwd, 'playbook.toml')
|
8
|
+
playbook = TOML.load_file(filepath)
|
9
|
+
scenes = playbook["scenes"]
|
10
|
+
|
11
|
+
scene = get_scene(scenes, scene_name)
|
12
|
+
if !scene.is_a?(Scene)
|
13
|
+
puts "没有名称为#{scene_name}的场景"
|
14
|
+
else
|
15
|
+
place = scene.place
|
16
|
+
goToPlace = "cd #{place}"
|
17
|
+
actions = scene.actions
|
18
|
+
commands = Array.new
|
19
|
+
props = scene.props
|
20
|
+
if props.nil?
|
21
|
+
commands.push(goToPlace).concat(actions)
|
22
|
+
else
|
23
|
+
placeProps = Array.new
|
24
|
+
cleanProps = Array.new
|
25
|
+
for prop in props
|
26
|
+
placeProps.push("cp #{File.join(dir_pwd, prop)} #{place}/#{prop}")
|
27
|
+
cleanProps.push("rm #{prop}")
|
28
|
+
end
|
29
|
+
commands.push(placeProps, goToPlace).concat(actions).push(cleanProps)
|
30
|
+
end
|
31
|
+
act = commands.join(" && ")
|
32
|
+
system act
|
33
|
+
end
|
34
|
+
end
|
data/lib/scene_player.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
# require_relative 'domain/scene.rb'
|
2
|
+
|
3
|
+
# class Scene_Player
|
4
|
+
# def self.hi(name)
|
5
|
+
# scene = Scene.new(name, "playground", ["ball"], ["run", "tick ball"])
|
6
|
+
# scene.describe
|
7
|
+
# end
|
8
|
+
# end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scene_player
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shi Yanxun
|
@@ -12,10 +12,14 @@ date: 2018-12-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: A simple hello world gem
|
14
14
|
email: jy01095902@126.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- act
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/act
|
21
|
+
- lib/domain/scene.rb
|
22
|
+
- lib/main.rb
|
19
23
|
- lib/scene_player.rb
|
20
24
|
homepage: http://rubygems.org/gems/scene_player
|
21
25
|
licenses:
|