scene_player 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a94b89573bf7cf575902889947549b3e6d725a34badc3b50d86a032d1666898b
4
- data.tar.gz: 5d4e9e4d92a19089b4fef680cd084a27d8e58de98c9fe105999a5996aa1dad5f
3
+ metadata.gz: 51578cfcaff2c8dfab299217a1043f1bd09e2e231809fa874ca92a7eb6863fce
4
+ data.tar.gz: 0c61a947aa060e1363b35668473a358ad433b7050497f3c26c7d48ae4b8c2a3a
5
5
  SHA512:
6
- metadata.gz: 778406a3ad1a4050aa75e0afe137880fad457974c69dbc05abfa60655afbf3b929a849eb9d42856be8fea822aef4b219a66491bf623b18c83fc6be4309c5beae
7
- data.tar.gz: afab5992095b0e6337c2ced7eecfae35f8aace28033c4bbdb38a72e561fc10d01a17c219842000d62b199d47c0e71701a1d6f5a78114d978eaa1ea2f1b4fea57
6
+ metadata.gz: ba56ecc055f856d599e28dde813ac20701637730d105ca942c16863eb36b63b3a451589d02c2ddac5f8edefd2e919a5ebfe653fd77a820c5429b5dd70b633d26
7
+ data.tar.gz: ffa9e15819ee65bdb8ff23f0a5fea41bb71901379152a765fe32ac4981f71c7cd9199a36558ea591045c5aa71dc7fe5819fc955866fd697528605dc2c07ce420
@@ -0,0 +1,27 @@
1
+
2
+
3
+ class CMDKeywordsFactory
4
+ @windows_cmd_keywords = {
5
+ cd: "cd",
6
+ cp: "copy",
7
+ rm: "del/s/q",
8
+ and: "&"
9
+ }
10
+
11
+ @linux_cmd_keywords = {
12
+ cd: "cd",
13
+ cp: "cp",
14
+ rm: "rm",
15
+ and: "&&"
16
+ }
17
+ def self.get_cmd_keywords(os)
18
+ case os
19
+ when :windows
20
+ @windows_cmd_keywords
21
+ when :macosx
22
+ @linux_cmd_keywords
23
+ else
24
+ nil
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ def os
2
+ @os ||= (
3
+ host_os = RbConfig::CONFIG['host_os']
4
+ case host_os
5
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
6
+ :windows
7
+ when /darwin|mac os/
8
+ :macosx
9
+ when /linux/
10
+ :linux
11
+ when /solaris|bsd/
12
+ :unix
13
+ else
14
+ raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
15
+ end
16
+ )
17
+ end
@@ -1,5 +1,7 @@
1
1
  require "toml"
2
2
  require_relative "domain/scene.rb"
3
+ require_relative "infra/os.rb"
4
+ require_relative "infra/cmd_keywords.rb"
3
5
 
4
6
  def run(scene_name)
5
7
  if scene_name == "-v"
@@ -7,6 +9,17 @@ def run(scene_name)
7
9
  return
8
10
  end
9
11
 
12
+ os = os()
13
+ cmd_keywords = CMDKeywordsFactory.get_cmd_keywords(os)
14
+ if cmd_keywords == nil
15
+ puts "暂不支持 #{os} 操作系统"
16
+ return
17
+ end
18
+ cd = cmd_keywords[:cd]
19
+ cp = cmd_keywords[:cp]
20
+ rm = cmd_keywords[:rm]
21
+ join = cmd_keywords[:and]
22
+
10
23
  dir_pwd = Dir.pwd
11
24
  filepath = File.join(dir_pwd, 'playbook.toml')
12
25
  playbook = TOML.load_file(filepath)
@@ -18,7 +31,7 @@ def run(scene_name)
18
31
  else
19
32
  place = scene.place
20
33
  place = (place.start_with? "~") ? dir_pwd + place[1..-1] : place
21
- goToPlace = "cd #{place}"
34
+ goToPlace = "#{cd} #{place}"
22
35
  actions = scene.actions
23
36
  commands = Array.new
24
37
  props = scene.props
@@ -28,12 +41,12 @@ def run(scene_name)
28
41
  placeProps = Array.new
29
42
  cleanProps = Array.new
30
43
  for prop in props
31
- placeProps.push("cp #{File.join(dir_pwd, prop)} #{place}/#{prop}")
32
- cleanProps.push("rm #{prop}")
44
+ placeProps.push("#{cp} #{File.join(dir_pwd, prop)} #{place}/#{prop}")
45
+ cleanProps.push("#{rm} #{prop}")
33
46
  end
34
47
  commands.push(placeProps, goToPlace).concat(actions).push(cleanProps)
35
48
  end
36
- act = commands.join(" && ")
49
+ act = commands.join(" #{join} ")
37
50
  system act
38
51
  end
39
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scene_player
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shi Yanxun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-02 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml
@@ -39,6 +39,8 @@ extra_rdoc_files: []
39
39
  files:
40
40
  - bin/act
41
41
  - lib/domain/scene.rb
42
+ - lib/infra/cmd_keywords.rb
43
+ - lib/infra/os.rb
42
44
  - lib/main.rb
43
45
  - lib/scene_player.rb
44
46
  homepage: http://rubygems.org/gems/scene_player
@@ -61,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
63
  version: '0'
62
64
  requirements: []
63
65
  rubyforge_project:
64
- rubygems_version: 2.7.3
66
+ rubygems_version: 2.7.6
65
67
  signing_key:
66
68
  specification_version: 4
67
69
  summary: Scene Player!