le1t0-deprec 2.1.6.071 → 2.1.6.072

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,17 +35,24 @@ module Deprec2
35
35
 
36
36
  def compare_files(app, local_file, remote_file)
37
37
  stage = exists?(:stage) ? fetch(:stage).to_s : ''
38
-
39
- run "cat #{remote_file}" do |channel, stream, data|
40
- local_file_full_path = local_file[0,1] == "/" ? local_file :
41
- (File.exists?(File.join('config', stage, channel.properties[:host], app.to_s, local_file)) ? File.join('config', stage, channel.properties[:host], app.to_s, local_file) : File.join('config', stage, app.to_s, local_file))
42
- tmp_file = File.join('/', 'tmp', "#{(channel.properties[:host] + remote_file).gsub(/\/\./, '_')}_#{Time.now.strftime("%Y%m%d%H%M%S")}.tmp")
43
- File.open(tmp_file, "w") do |f|
44
- f.write data
45
- end
46
- puts `diff #{local_file} #{tmp_file}`
38
+ tmpdir = "/tmp/#{Time.now.strftime("%Y%m%d%H%M%S")}.deprec"
39
+
40
+ FileUtils.mkdir_p(tmpdir)
41
+ begin
42
+ download(remote_file, File.join(tmpdir, "$CAPISTRANO:HOST$#{remote_file.gsub(/[\/\.]/, '_')}.tmp"), { :via => :scp, :silent => true })
43
+ rescue Exception
44
+ # ignore errors, it just means the file doesn't exist on a specific server. This can be the case if the file only
45
+ # gets uploaded to servers with a specific role for example.
46
+ end
47
+ Dir.new(tmpdir).entries.collect { |e| File.file?(File.join(tmpdir, e)) ? File.join(tmpdir, e) : nil }.compact.each do |tmp_file|
48
+ hostname = File.basename(tmp_file).split(/_/).first
49
+ local_file_full_path = (File.exists?(File.join('config', stage, hostname, app.to_s, local_file)) ?
50
+ File.join('config', stage, hostname, app.to_s, local_file) :
51
+ File.join('config', stage, app.to_s, local_file))
52
+ puts `diff -u #{local_file_full_path} #{tmp_file}`
47
53
  FileUtils.rm_f(tmp_file)
48
54
  end
55
+ FileUtils.rmdir(tmpdir)
49
56
  end
50
57
 
51
58
  # Render template (usually a config file)
data/lib/deprec.rb CHANGED
@@ -42,6 +42,7 @@ Capistrano::Configuration.instance.deprec.namespaces.keys.each do |ns_name|
42
42
  unless ns.respond_to?(:check_roles)
43
43
  Capistrano::Configuration.instance.namespace :deprec do
44
44
  namespace ns_name do
45
+ desc "check if all roles are defined for :#{ns_name}"
45
46
  task :check_roles do
46
47
  user_defined_roles = roles.keys
47
48
  recipe_declared_roles = Capistrano::Configuration.instance.deprec.send(ns_name).tasks.collect { |k,v| v.options.has_key?(:roles) ? v.options[:roles] : nil }.compact.flatten.uniq
@@ -56,25 +57,24 @@ Capistrano::Configuration.instance.deprec.namespaces.keys.each do |ns_name|
56
57
  unless ns.respond_to?(:diff_config)
57
58
  Capistrano::Configuration.instance.namespace :deprec do
58
59
  namespace ns_name do
60
+ desc "perform local/remote diff on project configs for :#{ns_name}"
59
61
  task :diff_config_project do
60
- return unless defined?(PROJECT_CONFIG_FILES) && PROJECT_CONFIG_FILES[ns_name]
61
-
62
62
  PROJECT_CONFIG_FILES[ns_name].each do |config_file|
63
- deprec2.compare_files(ns_name, config_file[:template], config_file[:path])
64
- end
63
+ deprec2.compare_files(ns_name, config_file[:path], config_file[:path])
64
+ end if defined?(PROJECT_CONFIG_FILES) && PROJECT_CONFIG_FILES[ns_name]
65
65
  end
66
66
 
67
+ desc "perform local/remote diff on system configs for :#{ns_name}"
67
68
  task :diff_config_system do
68
- return unless defined?(SYSTEM_CONFIG_FILES) && SYSTEM_CONFIG_FILES[ns_name]
69
-
70
69
  SYSTEM_CONFIG_FILES[ns_name].each do |config_file|
71
- deprec2.compare_files(ns_name, config_file[:template], config_file[:path])
72
- end
70
+ deprec2.compare_files(ns_name, config_file[:path], config_file[:path])
71
+ end if defined?(SYSTEM_CONFIG_FILES) && SYSTEM_CONFIG_FILES[ns_name]
73
72
  end
74
73
 
74
+ desc "perform local/remote diff on all configs for :#{ns_name}"
75
75
  task :diff_config do
76
- diff_config_project
77
76
  diff_config_system
77
+ diff_config_project
78
78
  end
79
79
  end
80
80
  end
metadata CHANGED
@@ -1,8 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: le1t0-deprec
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 2.1.6.071
4
+ hash: 239
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 1
9
+ - 6
10
+ - 72
11
+ version: 2.1.6.072
6
12
  platform: ruby
7
13
  authors:
8
14
  - Le1t0
@@ -21,7 +27,13 @@ dependencies:
21
27
  requirements:
22
28
  - - "="
23
29
  - !ruby/object:Gem::Version
24
- version: 2.5.18.022
30
+ hash: 33
31
+ segments:
32
+ - 2
33
+ - 5
34
+ - 18
35
+ - 23
36
+ version: 2.5.18.023
25
37
  type: :runtime
26
38
  version_requirements: *id001
27
39
  description: " This project provides libraries of Capistrano tasks and extensions to \n remove the repetative manual work associated with installing services \n on linux servers.\n"
@@ -279,17 +291,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
291
  requirements:
280
292
  - - ">="
281
293
  - !ruby/object:Gem::Version
294
+ hash: 3
295
+ segments:
296
+ - 0
282
297
  version: "0"
283
298
  required_rubygems_version: !ruby/object:Gem::Requirement
284
299
  none: false
285
300
  requirements:
286
301
  - - ">="
287
302
  - !ruby/object:Gem::Version
303
+ hash: 3
304
+ segments:
305
+ - 0
288
306
  version: "0"
289
307
  requirements: []
290
308
 
291
309
  rubyforge_project:
292
- rubygems_version: 1.5.0
310
+ rubygems_version: 1.3.7
293
311
  signing_key:
294
312
  specification_version: 3
295
313
  summary: deployment recipes for capistrano