hatecf 0.1.1 → 0.2.0

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: f676f5ae2e918677f40a743d982a5ffcbd061a3c0d2dd7bc043ee85c3d6c5da8
4
- data.tar.gz: 1ab539b2ddde0464b7ed36dd02958afae19929c721513fe3b89e58cf29001c9d
3
+ metadata.gz: e1b4ef8bbe6a61660fa428de1cf061be314514244a3d5d94f766167133ecf0a9
4
+ data.tar.gz: fb1bd239e0475e6f56540c0588deb1f6bd2532d43aaadc80c760ffe6dbf2f324
5
5
  SHA512:
6
- metadata.gz: d78d49b37f6b614aa53062626d98c2bf4642882b688b7f436be3ea6a383f25722fd9393b3773ca5fbc66a1babbfeb668ee5ece7dfb2d0d627b55135b86023412
7
- data.tar.gz: 9806d0189e2f2ff6e21a85e98a17386b0ffe079208f871dd3a78c292d17e5ffb4b0d3d0f72ff9ecf9e5e263ac5b22f36598a79596753a91a2a79d48776b977b4
6
+ metadata.gz: 2234677084a122e92cb02b91e7e9015829f7f3225bc29078557263b1dc8704036d6fe3cc3ae7cfe128c0529d95f0fb865d44dc1be0251d3a581c5e3cf3faa7b4
7
+ data.tar.gz: fe8c113c6f812fc6d355788904bfaad665bc171dc11b6d43347b685117fa7af6981ff13e799c9193176a94c7a9a54313ba426a4b6d3a25ffd842f77db2204777
data/bootstrap_ruby CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/bin/sh
2
- dpkg -s ruby > /dev/null || (echo "machine has no ruby; installing..."; apt-get install --no-install-recommends -y ruby)
2
+ which ruby > /dev/null || (echo "machine has no ruby; installing..."; apt-get install --no-install-recommends -y ruby)
data/lib/local.rb CHANGED
@@ -66,6 +66,8 @@ module Local
66
66
  @local_files = []
67
67
 
68
68
  require 'pathname'
69
+ # TODO: we are not able to copy directories with this,
70
+ # but we should be
69
71
  def copy_local_files_to(dir)
70
72
  @local_files.each do |local_file|
71
73
  # dublicating the whole directory stucture
@@ -87,11 +89,14 @@ module Local
87
89
  end
88
90
  end
89
91
 
92
+ @performed = false
90
93
  require 'tmpdir'
91
94
  def perform!
95
+ return if @performed # just for compatibility with < 0.2
96
+ # when manual invoke of peform! was needed
92
97
  die "no target host specified!" if (@target[:host] || "").empty?
93
- script_path = File.expand_path(ENV["_"])
94
- script_dir = File.dirname(File.expand_path(ENV["_"]))
98
+ script_path = File.expand_path ENV["_"]
99
+ script_dir = File.dirname script_path
95
100
  status = nil
96
101
  Dir.mktmpdir "hatecf" do |tmp_dir|
97
102
  debug "using temporary dir #{tmp_dir}"
@@ -117,6 +122,7 @@ module Local
117
122
  pid, status = Process.wait2(Process.spawn(cmd))
118
123
  debug "exit status: #{status.exitstatus}"
119
124
  end
125
+ @performed = true
120
126
  # FIXME: this always returns the status of "; rm" above, doesn't it?
121
127
  exit status.exitstatus
122
128
  end
data/lib/local_dsl.rb CHANGED
@@ -215,7 +215,11 @@ class RemoteFile
215
215
  end
216
216
  end
217
217
 
218
- def perform!
218
+ def perform! # legacy, not needed since 0.2
219
+ Local.perform!
220
+ end
221
+
222
+ Kernel.at_exit do
219
223
  Local.perform!
220
224
  end
221
225
 
data/remote/remote.rb CHANGED
@@ -341,7 +341,7 @@ module Remote
341
341
  end
342
342
  end
343
343
 
344
- # TODO: the dst is a dir case
344
+ # TODO: handle "dst is a dir" case
345
345
  def cp(src, dst, mode)
346
346
  src = src.remote_path if src.is_a? LocalFile
347
347
  dst = File.expand_path dst
@@ -376,10 +376,12 @@ module Remote
376
376
  end
377
377
  end
378
378
 
379
+ # TODO: handle "dst is a dir" case
380
+ # TODO: relative path case
379
381
  def ln_s(src, dst)
380
382
  src = File.expand_path src
381
383
  dst = File.expand_path dst
382
- if File.exist?(dst) &&File.lstat(dst).symlink? && File.readlink(dst) == src
384
+ if File.exist?(dst) && File.lstat(dst).symlink? && File.readlink(dst) == src
383
385
  ok "#{dst} leads to #{src}"
384
386
  else
385
387
  destructive "ln -s #{src} #{dst}" do
@@ -388,8 +390,6 @@ module Remote
388
390
  end
389
391
  end
390
392
 
391
- #attr_accessor :impressionating_user
392
-
393
393
  def spawn(cmd, expect_status: nil)
394
394
  expect_status = [expect_status] unless expect_status.nil? || expect_status.respond_to?(:include?)
395
395
  stdout_r, stdout_w = IO.pipe
@@ -510,4 +510,11 @@ module Remote
510
510
  @verbose = true
511
511
  end
512
512
  end.parse!
513
+
514
+ @performed = false
515
+ def perform!
516
+ return if @performed
517
+ info "ok: #{ok_counter}, changed: #{changed_counter}"
518
+ @performed = true
519
+ end
513
520
  end
data/remote/remote_dsl.rb CHANGED
@@ -181,8 +181,12 @@ def remote_file(path)
181
181
  Remote::RemoteFile.new(path)
182
182
  end
183
183
 
184
- def perform!
185
- Remote.info "ok: #{Remote.ok_counter}, changed: #{Remote.changed_counter}"
184
+ def perform! # legacy, not needed since 0.2
185
+ Remote.perform!
186
+ end
187
+
188
+ Kernel.at_exit do
189
+ Remote.perform!
186
190
  end
187
191
 
188
192
  # Monkey-patching
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatecf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Markov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-30 00:00:00.000000000 Z
11
+ date: 2025-01-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Configuration management engine like Ansible but without YAML and 30
14
14
  times faster