dronejob 1.0.3 → 1.0.4

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: dcc5382dd0f52edabfea18b2b88953e96ded21f7
4
- data.tar.gz: f682bf69fbd79bb557d75acb5df2778d7eeb2aa4
3
+ metadata.gz: 228486e1f34d82c4c9383f275f2747fec2bb87a3
4
+ data.tar.gz: 7f54c109f367a215126f247e28ed3b771871fd34
5
5
  SHA512:
6
- metadata.gz: fe7d008500c92512d507a0c684b615e18173aa392638affe1766638f3d704f31cc9740997e851bcf961b9a036c7558b8861d459dff6425f0f2a75368d4a1183f
7
- data.tar.gz: d0824a0944f77dabe82eed36b79f96282d1ef865889493a2e068b079d522f6a6e73d75775861f21c162eac0b1f71e01510d58ece1b2753ec5eac94bb9e77bd93
6
+ metadata.gz: e91a7bc50704804be80cb4eb41ce79a89945a40eb103788c55ee4ab566d8a8e19c6314998699b78ca855cb10ddfa695f3fbcfdff6e53acde6c4f5cc4f2d9e152
7
+ data.tar.gz: bea2eb4c05e8fbef73f98c60c2af2b2ca14aee6c0ad6ccf3c7f15e78dd45e3857fceb44078d9a759fd58a87f296e9e6aae496be6dfd735bcb2795e98d38e2b85
data/Gemfile.lock CHANGED
@@ -1,11 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dronejob (1.0.3)
4
+ dronejob (1.0.4)
5
5
  activejob (~> 4.2)
6
6
  bundler (~> 1.11)
7
7
  git (~> 1.2)
8
+ haml (~> 4.0)
9
+ open_uri_redirections (~> 0.2)
8
10
  rake (~> 10.5)
11
+ rubyzip (~> 1.1)
9
12
  sidekiq (~> 4.1.0)
10
13
  sidekiq-status (~> 0.6.0)
11
14
  thor (~> 0.19)
@@ -29,16 +32,19 @@ GEM
29
32
  git (1.3.0)
30
33
  globalid (0.3.6)
31
34
  activesupport (>= 4.1.0)
35
+ haml (4.0.7)
36
+ tilt
32
37
  i18n (0.7.0)
33
38
  json (1.8.3)
34
39
  method_source (0.8.2)
35
40
  minitest (5.8.4)
41
+ open_uri_redirections (0.2.1)
36
42
  pry (0.10.3)
37
43
  coderay (~> 1.1.0)
38
44
  method_source (~> 0.8.1)
39
45
  slop (~> 3.4)
40
46
  rake (10.5.0)
41
- redis (3.2.2)
47
+ redis (3.3.0)
42
48
  rspec (3.4.0)
43
49
  rspec-core (~> 3.4.0)
44
50
  rspec-expectations (~> 3.4.0)
@@ -52,7 +58,8 @@ GEM
52
58
  diff-lcs (>= 1.2.0, < 2.0)
53
59
  rspec-support (~> 3.4.0)
54
60
  rspec-support (3.4.1)
55
- sidekiq (4.1.0)
61
+ rubyzip (1.2.0)
62
+ sidekiq (4.1.1)
56
63
  concurrent-ruby (~> 1.0)
57
64
  connection_pool (~> 2.2, >= 2.2.0)
58
65
  redis (~> 3.2, >= 3.2.1)
@@ -61,6 +68,7 @@ GEM
61
68
  slop (3.6.0)
62
69
  thor (0.19.1)
63
70
  thread_safe (0.3.5)
71
+ tilt (2.0.2)
64
72
  tzinfo (1.2.2)
65
73
  thread_safe (~> 0.1)
66
74
 
data/dronejob.gemspec CHANGED
@@ -19,7 +19,10 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency "git", "~> 1.2"
20
20
  s.add_runtime_dependency "thor", "~> 0.19"
21
21
  s.add_runtime_dependency "sidekiq", "~> 4.1.0"
22
+ s.add_runtime_dependency "haml", "~> 4.0"
22
23
  s.add_runtime_dependency "sidekiq-status", "~> 0.6.0"
24
+ s.add_runtime_dependency "open_uri_redirections", "~> 0.2"
25
+ s.add_runtime_dependency "rubyzip", "~> 1.1"
23
26
  s.add_runtime_dependency "activejob", "~> 4.2"
24
27
  s.add_development_dependency "rspec", "~> 3.3"
25
28
  s.add_development_dependency "pry", "~> 0.10"
@@ -1,5 +1,3 @@
1
- require "psych"
2
-
3
1
  module Dronejob
4
2
  module Modules
5
3
  module AttrStore
@@ -25,12 +23,13 @@ module Dronejob
25
23
  self.class.attr_stores.each do |key|
26
24
  variables[key] = instance_variable_get("@#{key}")
27
25
  end
28
- file_write("dronejob.yml", Psych.dump(variables))
26
+ yaml_file = working_dir.file("dronejob.yml")
27
+ yaml_file.write(Psych.dump(variables))
29
28
  end
30
29
 
31
30
  def load_variables
32
- yaml_file = File.join(working_dir, "dronejob.yml")
33
- variables = File.exists?(yaml_file) ? Psych.load_file(yaml_file) : {}
31
+ yaml_file = working_dir.file("dronejob.yml")
32
+ variables = yaml_file.exists? ? yaml_file.read_yaml : {}
34
33
  variables.each do |key, value|
35
34
  instance_variable_set("@#{key}", value)
36
35
  end
@@ -13,7 +13,7 @@ module Dronejob
13
13
  create_working_dir
14
14
  load_variables
15
15
 
16
- git_init(@working_dir)
16
+ git_init(@working_dir.full_path)
17
17
  git_collect_commits
18
18
  git_commit("start")
19
19
  if param(:from)
@@ -44,6 +44,10 @@ module Dronejob
44
44
  log(:error, message)
45
45
  end
46
46
 
47
+ def error!(message)
48
+ throw message
49
+ end
50
+
47
51
  def critical(message)
48
52
  log(:critical, message)
49
53
  end
@@ -54,8 +58,7 @@ module Dronejob
54
58
 
55
59
  def emergency(message)
56
60
  log(:emergency, message)
57
- end
58
-
61
+ end
59
62
  end
60
63
  end
61
64
  end
@@ -17,6 +17,10 @@ module Dronejob
17
17
  @options
18
18
  end
19
19
 
20
+ def option(key)
21
+ options.send(key)
22
+ end
23
+
20
24
  def default_options
21
25
  {redis_url: "redis://127.0.0.1:6379"}
22
26
  end
@@ -27,7 +31,7 @@ module Dronejob
27
31
  end
28
32
 
29
33
  def option(key)
30
- self.class.options.send(key)
34
+ self.class.option(key)
31
35
  end
32
36
 
33
37
  end
@@ -30,6 +30,22 @@ module Dronejob
30
30
  elsif skip_phase?(phase)
31
31
  info("skipping...")
32
32
  else
33
+ # Require libraries
34
+ if !config[:require].nil?
35
+ config[:require].each do |library|
36
+ require library
37
+ end
38
+ end
39
+
40
+ # Include helpers
41
+ if !config[:helpers].nil?
42
+ config[:helpers].each do |helper|
43
+ helper_path = "helpers/#{helper}"
44
+ require "./app/#{helper_path}"
45
+ self.class.include helper_path.camelcase.constantize
46
+ end
47
+ end
48
+
33
49
  block.call(phase, config)
34
50
  end
35
51
  end
@@ -11,69 +11,66 @@ module Dronejob
11
11
  cattr_accessor(:output_path) { "tmp/jobs" }
12
12
  end
13
13
 
14
- def file(path)
15
- WorkspaceFile.new(working_dir, path)
14
+ def file(path, &block)
15
+ f = working_dir.file(path)
16
+ if !block.nil?
17
+ block.call(f)
18
+ f.write
19
+ end
20
+ f
16
21
  end
17
22
 
18
23
  def dir(path)
19
- WorkspaceDir.new(working_dir, path)
24
+ working_dir.dir(path)
20
25
  end
21
26
 
22
27
  def create_working_dir
23
- @working_dir = File.join(self.class.output_path, uuid)
24
- FileUtils.mkdir_p(@working_dir)
25
- end
26
-
27
- def file_write(target_path, contents)
28
- full_path = File.join(working_dir, target_path)
29
- open(full_path, "wb"){|file| file << contents}
30
- full_path
28
+ @working_dir = WorkspaceDir.new(File.join(self.class.output_path, uuid))
29
+ @working_dir.create
30
+ @working_dir
31
31
  end
32
32
 
33
- def file_create_path(*args)
34
- path = File.join(working_dir, *args)
35
- FileUtils.mkdir_p(path)
36
- path
37
- end
38
-
39
- def file_replace_contents(target_path, &block)
40
- binding.pry
41
- contents = File.open(target_path).read
42
- contents = block.call(contents)
43
- file_write(target_path, contents)
33
+ def asset_file(path)
34
+ WorkspaceDir.new("app/assets").file(path)
44
35
  end
45
36
 
46
- def file_delete_path(*args)
47
- binding.pry
48
- path = File.join(*args)
49
- FileUtils.rm_rf(path)
50
- path
51
- end
52
-
53
- def file_parse_haml(haml_path, output_path, options={})
54
- binding.pry
55
- engine = Haml::Engine.new(haml_path)
56
- open(output_path, 'wb') do |file|
57
- file << engine.render(Object.new, options)
58
- end
59
- end
60
-
61
- def file_root_dir
62
- binding.pry
63
- File.expand_path("../../../", __FILE__)
64
- end
65
-
66
- def file_data_path(target_path)
67
- binding.pry
68
- File.join(Gem.datadir("app-drone"), target_path)
69
- end
70
-
71
- def file_data_contents(target_path)
72
- binding.pry
73
- path = file_data_path(target_path)
74
- File.open(path).read
75
- end
76
-
37
+ # def file_replace_contents(target_path, &block)
38
+ # binding.pry
39
+ # contents = File.open(target_path).read
40
+ # contents = block.call(contents)
41
+ # file_write(target_path, contents)
42
+ # end
43
+ #
44
+ # def file_delete_path(*args)
45
+ # binding.pry
46
+ # path = File.join(*args)
47
+ # FileUtils.rm_rf(path)
48
+ # path
49
+ # end
50
+ #
51
+ # def file_parse_haml(haml_path, output_path, options={})
52
+ # binding.pry
53
+ # engine = Haml::Engine.new(haml_path)
54
+ # open(output_path, 'wb') do |file|
55
+ # file << engine.render(Object.new, options)
56
+ # end
57
+ # end
58
+ #
59
+ # def file_root_dir
60
+ # binding.pry
61
+ # File.expand_path("../../../", __FILE__)
62
+ # end
63
+ #
64
+ # def file_data_path(target_path)
65
+ # binding.pry
66
+ # File.join(Gem.datadir("app-drone"), target_path)
67
+ # end
68
+ #
69
+ # def file_data_contents(target_path)
70
+ # binding.pry
71
+ # path = file_data_path(target_path)
72
+ # File.open(path).read
73
+ # end
77
74
  end
78
75
  end
79
76
  end
@@ -1,3 +1,3 @@
1
1
  module Dronejob
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -2,10 +2,34 @@ module Dronejob
2
2
  class WorkspaceDir
3
3
  attr_accessor :workspace, :path
4
4
 
5
- def initialize(workspace, path)
5
+ def initialize(workspace, path="")
6
6
  @workspace = workspace
7
7
  @path = path
8
8
  end
9
9
 
10
+ def full_path
11
+ File.join(@workspace, @path)
12
+ end
13
+
14
+ def create
15
+ FileUtils.mkdir_p(full_path)
16
+ self
17
+ end
18
+
19
+ def exists?
20
+ File.directory?(full_path)
21
+ end
22
+
23
+ def delete!
24
+ FileUtils.rm_rf(full_path)
25
+ end
26
+
27
+ def file(file_path)
28
+ WorkspaceFile.new(@workspace, File.join(@path, file_path))
29
+ end
30
+
31
+ def dir(dir_path)
32
+ WorkspaceDir.new(@workspace, File.join(@path, dir_path))
33
+ end
10
34
  end
11
35
  end
@@ -1,12 +1,14 @@
1
+ require "psych"
2
+ require "zip"
3
+ require "open-uri"
4
+ require "open_uri_redirections"
1
5
  module Dronejob
2
6
  class WorkspaceFile
3
7
  attr_accessor :workspace, :path
4
- attr_reader :contents
5
8
 
6
9
  def initialize(workspace, path)
7
10
  @workspace = workspace
8
11
  @path = path
9
- set(read) if exists?
10
12
  end
11
13
 
12
14
  def set(contents)
@@ -14,10 +16,27 @@ module Dronejob
14
16
  self
15
17
  end
16
18
 
19
+ def contents
20
+ @contents ||= read
21
+ end
22
+
17
23
  def replace(key, value)
18
- @contents.gsub!(key, value)
24
+ contents.gsub!(key, value)
19
25
  self
20
26
  end
27
+
28
+ def pbxproj_replace(data)
29
+ data.each do |key, value|
30
+ replace(/#{key} = .*;/, "#{key} = #{value};") if !value.nil?
31
+ end
32
+ end
33
+
34
+ def with_plist(&block)
35
+ require "plist"
36
+ plist = Plist.parse_xml(full_path)
37
+ block.call(plist)
38
+ write(Plist::Emit.dump(plist))
39
+ end
21
40
 
22
41
  def write(contents=nil)
23
42
  contents ||= @contents
@@ -39,5 +58,67 @@ module Dronejob
39
58
  File.open(full_path).read
40
59
  end
41
60
 
61
+ def read_json
62
+ JSON.parse(read)
63
+ end
64
+
65
+ def read_yaml
66
+ Psych.load_file(full_path)
67
+ end
68
+
69
+ def read_haml(options)
70
+ require "haml"
71
+ engine = Haml::Engine.new(read)
72
+ engine.render(Object.new, options)
73
+ end
74
+
75
+ def download!(url)
76
+ raise "file not found at #{url}" unless download(url)
77
+ self
78
+ end
79
+
80
+ def cdn_download!(key)
81
+ raise "cdn file not found at #{key}" unless cdn_download(key)
82
+ self
83
+ end
84
+
85
+ def cdn_download(key)
86
+ download("#{Dronejob::Base.option(:cdn_url)}/#{key}")
87
+ end
88
+
89
+ def download(url)
90
+ open(full_path, "wb") do |file|
91
+ file << open(url, { ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE, allow_redirections: :safe }).read
92
+ end
93
+ return self
94
+ rescue StandardError => e
95
+ binding.pry
96
+ return false
97
+ end
98
+
99
+ def extract(target_dir)
100
+ target_dir.create
101
+ Zip::File.open(full_path) do |zip_file|
102
+ zip_file.each do |entry|
103
+ entry.extract(File.join(target_dir.full_path, entry.name))
104
+ end
105
+ end
106
+ self
107
+ end
108
+
109
+ def acbaker(type, output_dir, delete=true)
110
+ require "acbaker"
111
+ output_dir.delete! if delete and output_dir.exists?
112
+ output_dir.create
113
+ config = WorkspaceDir.new("app/assets").file("acbaker/#{type}.json").read_json
114
+ acb = Acbaker::AssetPack.new(type, json: config)
115
+ acb.process(full_path, output_dir.full_path)
116
+ self
117
+ end
118
+
119
+ def dir
120
+ WorkspaceDir.new(@workspace, File.dirname(@path))
121
+ end
122
+
42
123
  end
43
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dronejob
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: haml
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: sidekiq-status
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,34 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: 0.6.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: open_uri_redirections
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.2'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubyzip
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '1.1'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.1'
97
139
  - !ruby/object:Gem::Dependency
98
140
  name: activejob
99
141
  requirement: !ruby/object:Gem::Requirement