scene_player 0.0.0 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad37852f9a0ef1cd0c0b0b59eaf9faf47fd795f648ba99578432b08fca6d5425
4
- data.tar.gz: b704003f7f5b5037352df921660a7a205679ab6d9b590bddefa25a2dd3d1dcf1
3
+ metadata.gz: 487aff1a763013e27b35270376797438d8a7cefb54a9ea07b87603c452cc3c5a
4
+ data.tar.gz: 40990b60a3818a478568bd3c31615d4e7efecbb914b950d7bef55cecf4b82b8c
5
5
  SHA512:
6
- metadata.gz: 341ce1d9603304e5a3d94d3d21ec596af3cd6944c9dec170fafb4216d233b516b24b2c9f337ecf7d7e5002b41ac1eab0562322d794641e814d034c31c5b31dc3
7
- data.tar.gz: 305356fc36a2ba1efbdb46a5f98750e916a182b464ca6f14620a6ea4fc738f94a1b869a4d4386db95fc5d5455851616c9113fa1bec9e672381ec0acd8ec28b8c
6
+ metadata.gz: 370a5271c984eed8a8539749a00de2e9d0d1599f9b2c56f6be219a89ace4c586096720de5ff2b394bc12a32ac65e9e34b4360eea40625fd36feda96eee2b2152
7
+ data.tar.gz: d1196cc080ba82bbcecc30c723d6bdca1521309ebd5d4750dd9f90070b5571e9067cefe38c91a27e1426713c9bbc2c04db4e1257fba13a2b118fd853ca58c8c1
data/bin/act ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'main'
4
+
5
+ run(ARGV[0])
@@ -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
- class Scene_Player
2
- def self.hi
3
- puts "Hello, I'am Tom, I'am a player."
4
- end
5
- end
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.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: