alerty 0.0.1 → 0.0.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: ec90bd21ce7f831f3a1a688bc29b41eaeec57261
4
- data.tar.gz: 0aa77f32295f188671b203cbdc797b30dcb1f707
3
+ metadata.gz: 8f1c92b7d3ec37c17af10d78fba346435c7be67e
4
+ data.tar.gz: 84616ba361045f8b94e544eea7626734077f212a
5
5
  SHA512:
6
- metadata.gz: aa300f5950d396569873bfc8773999a6e9c0ea0d8d903458927b77701c808aa9cb6c7369e91f94c397865e97a6d93fe66db0203db8f11baaf7e8ec6188c31462
7
- data.tar.gz: b903dacd0f3df02636e17ff068f34769a65fc76e5b7570600a49896410f655d27e30cb638db7bb186bdec8917c3c1ab330dc0dcc5c59f2ade48fbbbcff305acc
6
+ metadata.gz: 0479571dc19db4fb6c52f5fa1dca7cf023c15ce6947a68207ba41770027bda7fece31b4580ea11236f82e7a6ce84d3b04256026cce205956c2013a7d19e78d2c
7
+ data.tar.gz: 2547fee4e93f27d12acc0bc7eceb78ba376e329bc65850d35ae013875a2ef5032b5a1ead04571384343392fc2cd9ec3cfc839b7f3131e2609f200f09ab97d2bb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # 0.0.2 (2015/08/13)
2
+
3
+ Enchancements:
4
+
5
+ * Allow to configure timeout and lock_path in config file (options outcome)
6
+ * Allow to configure log_path and log_level as command options (options outcome)
7
+
1
8
  # 0.0.1 (2015/08/13)
2
9
 
3
10
  first version
data/README.md CHANGED
@@ -17,7 +17,10 @@ gem install alerty
17
17
  You can write a configuration file located at `/etc/sysconfig/alerty` (You can configure this path by `ALERTY_CONFIG_FILE` environment variable, or `-c` option):
18
18
 
19
19
  ```
20
+ log_path: STDOUT
20
21
  log_level: 'debug'
22
+ timeout: 10
23
+ lock_path: /tmp/lock
21
24
  plugins:
22
25
  - type: stdout
23
26
  ```
@@ -34,9 +37,11 @@ $ alerty -c example.yml -- ls -l /something_not_exist
34
37
 
35
38
  ```
36
39
  $ bin/alerty -h
37
- -c, --config CONFIG_PATH config file path (default: /etc/sysconfig/alerty)
40
+ -c, --config CONFIG_FILE config file path (default: /etc/sysconfig/alerty)
41
+ --log LOG_FILE log file path (default: STDOUT)
42
+ --log-level LOG_LEVEL log level (default: warn
38
43
  -t, --timeout SECONDS timeout the command (default: no timeout)
39
- -l, --lock LOCK_FILE exclusive lock file not to run the same command duplicatedly (default: no lock)
44
+ -l, --lock LOCK_FILE exclusive lock file to prevent running a command duplicatedly (default: no lock)
40
45
  ```
41
46
 
42
47
  ## Plugins
data/alerty.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "alerty"
3
- gem.version = '0.0.1'
3
+ gem.version = '0.0.2'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/alerty'
data/example.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  log_path: log/alerty.log
2
2
  log_level: debug
3
+ timeout: 10
4
+ lock_path: log/lock
3
5
  plugins:
4
6
  - type: stdout
5
7
  - type: file
data/lib/alerty/cli.rb CHANGED
@@ -14,24 +14,24 @@ class Alerty
14
14
  end
15
15
  end
16
16
 
17
- opts = {
18
- config: '/etc/sysconfig/alerty',
19
- timeout: nil,
20
- exclusive: nil,
17
+ opts = {}
18
+ op.on('-c', '--config CONFIG_FILE', "config file path (default: /etc/sysconfig/alerty)") {|v|
19
+ opts[:config_path] = v
21
20
  }
22
-
23
- op.on('-c', '--config CONFIG_FILE', "config file path (default: #{opts[:config]})") {|v|
24
- opts[:config] = v
21
+ op.on('--log LOG_FILE', "log file path (default: STDOUT)") {|v|
22
+ opts[:log_path] = v
23
+ }
24
+ op.on('--log-level LOG_LEVEL', "log level (default: warn)") {|v|
25
+ opts[:log_level] = v
25
26
  }
26
27
  op.on('-t', '--timeout SECONDS', "timeout the command (default: no timeout)") {|v|
27
28
  opts[:timeout] = v.to_i
28
29
  }
29
30
  op.on('-l', '--lock LOCK_FILE', "exclusive lock file to prevent running a command duplicatedly (default: no lock)") {|v|
30
- opts[:exclusive] = v
31
+ opts[:lock_path] = v
31
32
  }
32
33
 
33
34
  op.parse!(argv)
34
-
35
35
  opts[:command] = argv.join(' ')
36
36
 
37
37
  if opts[:command].empty?
@@ -48,8 +48,8 @@ class Alerty
48
48
  usage e.message
49
49
  end
50
50
 
51
- Config.configure(config_path: opts[:config]) if opts[:config]
51
+ Config.configure(opts)
52
52
  Config.plugins # load plugins in early stage
53
- Command.new(command: opts[:command], opts: opts).run!
53
+ Command.new(command: opts[:command]).run!
54
54
  end
55
55
  end
@@ -2,9 +2,9 @@ require 'frontkick'
2
2
 
3
3
  class Alerty
4
4
  class Command
5
- def initialize(command: , opts: {})
5
+ def initialize(command:)
6
6
  @command = command
7
- @opts = opts
7
+ @opts = { timeout: Config.timeout, exclusive: Config.lock_path }
8
8
  end
9
9
 
10
10
  def run!
data/lib/alerty/config.rb CHANGED
@@ -4,12 +4,14 @@ require 'hashie/mash'
4
4
  class Alerty
5
5
  class Config
6
6
  class << self
7
- def configure(config_path: )
8
- @config_path = config_path
7
+ attr_reader :opts
8
+
9
+ def configure(opts)
10
+ @opts = opts
9
11
  end
10
12
 
11
13
  def config_path
12
- @config_path ||= ENV['ALERTY_CONFIG_PATH'] || '/etc/sysconfig/alerty'
14
+ @config_path ||= opts[:config_path] || ENV['ALERTY_CONFIG_PATH'] || '/etc/sysconfig/alerty'
13
15
  end
14
16
 
15
17
  def config
@@ -17,11 +19,19 @@ class Alerty
17
19
  end
18
20
 
19
21
  def log_path
20
- config.log_path || 'STDOUT'
22
+ opts[:log_path] || config.log_path || 'STDOUT'
21
23
  end
22
24
 
23
25
  def log_level
24
- config.log_level || 'warn'
26
+ opts[:log_level] || config.log_level || 'warn'
27
+ end
28
+
29
+ def timeout
30
+ opts[:timeout] || config.timeout
31
+ end
32
+
33
+ def lock_path
34
+ opts[:lock_path] || config.lock_path
25
35
  end
26
36
 
27
37
  def plugins
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alerty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo