tenter 0.1.0 → 0.1.1

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: f38e303b6f15e746b96586d2a2a6e0e3ca0a2c4746cef91fec0bb455c03fd934
4
- data.tar.gz: 38319bec27ca53fefc5fdb9f011e0607e3d47741df22f8586482615b9971d3aa
3
+ metadata.gz: 2cec3086122a566c922ffaeeda6e9d086c3dc78cd4900666e6e0ae2edefb15a3
4
+ data.tar.gz: 9dacc38cf020d66efa977acdbf2dfab90527b926445b5f7aa5e1e57206a7c0b0
5
5
  SHA512:
6
- metadata.gz: 768b2d4c62fea0a0c2574bfb873ff8c07e7ab1a4fc535a8c32244bf8d8827e728db234aaf13fbe1febe35c6fe9e00a36a44430a19e6ec2485ad898a6927cbd31
7
- data.tar.gz: b0281208e5189a643e7bd512f8f3a930e983c5f9f3fd106a41750fea263d54bd3c2eded9d4738802c86f9be647b9dc55364ea29cabf6749d5c109e073a7560bf
6
+ metadata.gz: b535883fe1cd070d1f8706a895c043db077950bb8e2c0d622e310e026831feed390a79980e5b0d39510c1abbed8f0f3b1072b8c4df0d92d390200724d2396193
7
+ data.tar.gz: 660effd30f91a6d47745ee803d73b5f0082183c49268aca2bf7fa3cabb52dfd03bef29d683c282d12081ce6c3362ca80a3e6e4b2be319184972f69b616344b0e
@@ -10,7 +10,8 @@ module Tenter
10
10
  { doc_root: "/var/www/",
11
11
  config_filename: "hooks.yaml",
12
12
  command_dir: "commands",
13
- log_file: "log/commands.log" }
13
+ log_file: "log/commands.log",
14
+ timestamp: true }
14
15
  end
15
16
 
16
17
  def self.reset
@@ -30,10 +30,15 @@ module Tenter
30
30
  msg = "Command not found"
31
31
  halt 400, msg unless File.file? command["path"]
32
32
 
33
- msg = "[#{Time.now}] Initiating: #{command["path"]}\n"
33
+ ts = Tenter.settings[:timestamp] ? "[#{Time.now}] " : ""
34
+ msg = ts + "Initiating: #{command["path"]}\n"
34
35
  Tenter::Utils.append_to_log command["log"], msg
35
36
 
36
- pid = command["proc"].call
37
+ pid = if defined?(Bundler) && Bundler.respond_to?(:with_clean_env)
38
+ Bundler.with_clean_env { command["proc"].call }
39
+ else
40
+ command["proc"].call
41
+ end
37
42
  (ENV["APP_ENV"] != "test") ? Process.detach(pid) : Process.wait(pid)
38
43
  end
39
44
 
@@ -21,20 +21,23 @@ module Tenter
21
21
  end
22
22
 
23
23
  def self.command(command_name, site_dir)
24
- ts = %q{ | xargs -L 1 sh -c 'printf "[%s] %s\n" "$(date +%Y-%m-%d\ %H:%M:%S\ %z )" "$*" ' sh}
24
+ site_path = File.join(Tenter.settings[:doc_root], site_dir)
25
25
  command = {}
26
- command["pwd"] = File.join(Tenter.settings[:doc_root], site_dir)
27
- command["path"] = File.join(command["pwd"],
28
- Tenter.settings[:command_dir],
29
- command_name)
26
+ command["dir"] = File.join(site_path, Tenter.settings[:command_dir])
27
+ command["path"] = File.join(command["dir"], command_name)
30
28
  command["log"] = unless Tenter.settings[:log_file].nil?
31
- File.join(command["pwd"], Tenter.settings[:log_file])
29
+ File.join(site_path, Tenter.settings[:log_file])
32
30
  else
33
31
  "/dev/null"
34
32
  end
35
33
  command["proc"] = Proc.new {
36
- spawn command["path"] + ts, { :chdir => command["pwd"],
37
- :out => [ command["log"], "a" ] }
34
+ ts = if Tenter.settings[:timestamp]
35
+ %q{ | xargs -L 1 sh -c 'printf "[%s] %s\n" "$(date +%Y-%m-%d\ %H:%M:%S\ %z )" "$*" ' sh}
36
+ else
37
+ ""
38
+ end
39
+ spawn command["path"] + ts, { :chdir => command["dir"],
40
+ [ :out, :err ] => [ command["log"], "a" ] }
38
41
  }
39
42
 
40
43
  return command
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tenter
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-07 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra