tuya-ci-DSL 0.1.0 → 0.1.2

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
  SHA1:
3
- metadata.gz: 204f1ee85290441a131eac43962c84950cb84f65
4
- data.tar.gz: a9ba70a216d33a98c760245f28be4fe6a49a8452
3
+ metadata.gz: d9601dceb5f3616b3e5724483ed54231aafaeba0
4
+ data.tar.gz: 6fe69ec922230449ca23329f1c39794765cd77e6
5
5
  SHA512:
6
- metadata.gz: 53a5269753be9410d5a2d83a78627606e885a310d767f8e8e70bed0bb9d6e66646cb388db6725a6019eee3385cc7cf120701b038bad0e923d1b8f3b3badc9955
7
- data.tar.gz: b59a278586172c456157ec82de6a109955c18911e3879d87c2fcc0a43a60360bd45719844167b2a3f786e3e0c68608458cf41572b9a9e8fc215ba9ca3d89dde6
6
+ metadata.gz: 7ef33bcabe9d78a88a0cc3dcb2a8103d7b298166f7a4eb0ff1aad3bf938262496d2ffdbe1b083b5b9d6837f24d93e2f50302c6422adf1180a459b848eed2b6b1
7
+ data.tar.gz: d29c4f984d8a1b3d50dd40aa5cf88347f3b9596ed6e2905e6f538bd52b715e7056741ffa8538f9240f20a87112faf7e25779e29984937d96f80da54d3f2fe372
@@ -13,7 +13,10 @@ module TuyaCIDSL
13
13
 
14
14
  def execute
15
15
  if @from_git
16
- `cp -a #{@folder_path} ./`
16
+ command_cp = "cp -a #{@folder_path} ./"
17
+ puts "Trigger will copy shell by:#{command_cp}"
18
+ system command_cp
19
+
17
20
  run_shell
18
21
  delete
19
22
  else
@@ -22,19 +25,13 @@ module TuyaCIDSL
22
25
  end
23
26
 
24
27
  def download(git)
28
+
25
29
  @from_git = true
30
+ git_downloader = TYCiCore::GitDownloader.new git
26
31
  @git = git
27
- @folder = git.scan(/^.*\/(.*).git$/)[0][0]
28
- @folder_path = "#{ENV['HOME']}/.dsl/#{folder}"
29
-
30
- if File.exist? @folder_path
31
- `git -C #{@folder_path} add .`
32
- `git -C #{@folder_path} reset --hard`
33
- `git -C #{@folder_path} fetch`
34
- `git -C #{@folder_path} rebase`
35
- else
36
- `git clone #{git} #{@folder_path}`
37
- end
32
+ @folder = git_downloader.folder
33
+ git_downloader.download '.dsl'
34
+ @folder_path = git_downloader.folder_path
38
35
  end
39
36
 
40
37
  private
@@ -9,12 +9,22 @@ class TuyaCIMonitor
9
9
  method = @methods[action.to_sym]
10
10
  begin
11
11
  method.call options if method
12
- rescue Exception
13
- puts "Trigger Exception cached, you can puts detail in your error method".red
14
- exe_error action, $!, $@, options
12
+ rescue Exception => e
13
+ if e.class == TuyaCIMonitorStopError
14
+ puts "Trigger Exception cached, tuya_stop_build has been used. the build is end here".red
15
+ raise $!
16
+ else
17
+ puts "Trigger Exception cached, you can puts detail in your error method".red
18
+ exe_error action, $!, $@, options
19
+ end
20
+
15
21
  ensure
16
22
  end
17
23
  end
24
+
25
+ def tuya_stop_build(message)
26
+ raise TuyaCIMonitorStopError, message
27
+ end
18
28
 
19
29
  def tuya_sh(shell)
20
30
  dsl = TuyaCIDSL::DSLExecute.new shell
@@ -65,6 +75,23 @@ class TuyaCIMonitor
65
75
  end
66
76
  end
67
77
 
78
+ class TuyaCIMonitorStopError < StandardError
79
+
80
+ attr_reader :object
81
+
82
+ # def initialize(object)
83
+ # @object = object
84
+ # end
85
+
86
+ # begin
87
+ # raise TuyaCIMonitorStopError.new("an object"), "a message"
88
+ # rescue TuyaCIMonitorStopError => e
89
+ # puts e.message # => "a message"
90
+ # puts e.object # => "an object"
91
+ # end
92
+
93
+ end
94
+
68
95
  class TuyaCIMonitorMethods
69
96
  attr_accessor :name, :args, :block
70
97
  def initialize
@@ -14,6 +14,18 @@ module TuyaCIDSL
14
14
  load_files
15
15
  end
16
16
 
17
+ def load_monitors_git(git)
18
+ git_downloader = TYCiCore::GitDownloader.new git
19
+ git_downloader.download '.dsl_common'
20
+ load_monitors_path git_downloader.folder_path
21
+ end
22
+
23
+ def load_monitors_path(path)
24
+ if File.exist? path
25
+ @files += Dir["#{path}/**/*"].reject{|o|File.directory?(o)}
26
+ end
27
+ end
28
+
17
29
  def load_monitors
18
30
  @files.each do |item|
19
31
  add_monitor item
@@ -55,9 +67,6 @@ module TuyaCIDSL
55
67
  if File.exist? "./#{@default_folder}/"
56
68
  @files += Dir["./#{@default_folder}/**/*"].reject{|o|File.directory?(o)}
57
69
  end
58
- # puts `pwd`
59
- # puts "files is now:"
60
- # puts @files
61
70
  end
62
71
 
63
72
  def add_monitor(file)
@@ -1,7 +1,7 @@
1
1
  module Tuya
2
2
  module Ci
3
3
  module DSL
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tuya-ci-DSL
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - fangdong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-16 00:00:00.000000000 Z
11
+ date: 2019-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler