insidious 0.1.2 → 0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/error.rb +2 -0
  3. data/lib/insidious.rb +9 -12
  4. metadata +5 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f3b5420e5516c3cd21fbaed58334201f1291491
4
- data.tar.gz: ba22bcfc123080795b1718c323883f769a08c4ae
3
+ metadata.gz: ad7509659f0b9ee6452f114f372f7fe80c9fda90
4
+ data.tar.gz: 7d19317732b6409eddcff3bca14161d4df0f30bf
5
5
  SHA512:
6
- metadata.gz: 976af5fdab4ed1485edb62496ab62bbd0a4d066e041e597f5ab765d422b854ec59b2292f426355086d0467c3283c8030a0a7f14c0f5327dc63c81271a113c329
7
- data.tar.gz: 9252ab485a52bea9547d2e9937fba4e1ebe2832d401cb7ed1b3651c072b749742e8c8dc73851d878f6deb756c6c7e52b84d4695c7fd858f674899d788954fe91
6
+ metadata.gz: 71ca90b365af0c14934e9eec46d20333cbc167b4d014dcb8177edd38d239c8f24d22c10832cf0125721f69a0102272650239f6322582b24ffe6528550ca6afd6
7
+ data.tar.gz: 07205f48fa03b51f78a7fc208d0f2392b511ad020b1d5268a8a2ced9d662d65726c11780e991c94ebfbfb9057d0cc99194a9fc3d316673410e2536a836483370
data/lib/error.rb ADDED
@@ -0,0 +1,2 @@
1
+ class InsidiousError < StandardError
2
+ end
data/lib/insidious.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'error'
2
+
1
3
  class Insidious
2
4
  attr_accessor :pid_file
3
5
  attr_accessor :pid
@@ -45,17 +47,12 @@ class Insidious
45
47
  # is already running, in which case insidious will exit with an error
46
48
  # code.
47
49
  def start!(&block)
48
- if pid_file && File.exists?(pid_file)
49
- begin
50
- Process.kill(0, pid)
51
- STDERR.puts("Daemon is already running with PID #{pid}")
52
- exit 2
53
- rescue Errno::ESRCH
54
- run!(&block)
55
- end
50
+ if running?
51
+ fail InsidiousError.new("Process is already running with PID #{pid}")
52
+ exit 2
56
53
  else
57
- if (pid_file.nil? && daemonize)
58
- STDERR.puts('No PID file is set but daemonize is set to true')
54
+ if pid_file.nil? && daemonize
55
+ fail InsidiousError.new('No PID file is set but daemonize is set to true')
59
56
  exit 1
60
57
  end
61
58
 
@@ -73,11 +70,11 @@ class Insidious
73
70
  Process.kill(:INT, pid)
74
71
  File.delete(pid_file)
75
72
  rescue Errno::ESRCH
76
- STDERR.puts("No daemon is running with PID #{pid}")
73
+ fail InsidiousError.new("No process is running with PID #{pid}")
77
74
  exit 3
78
75
  end
79
76
  else
80
- STDERR.puts("Couldn't find the PID file: '#{pid_file}'")
77
+ fail InsidiousError.new("Couldn't find the PID file: '#{pid_file}'")
81
78
  exit 1
82
79
  end
83
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insidious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - James White
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-04-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -20,6 +20,7 @@ files:
20
20
  - LICENSE
21
21
  - README.md
22
22
  - Rakefile
23
+ - lib/error.rb
23
24
  - lib/insidious.rb
24
25
  homepage: https://github.com/jamesrwhite/insidious
25
26
  licenses:
@@ -31,12 +32,12 @@ require_paths:
31
32
  - lib
32
33
  required_ruby_version: !ruby/object:Gem::Requirement
33
34
  requirements:
34
- - - '>='
35
+ - - ">="
35
36
  - !ruby/object:Gem::Version
36
37
  version: 1.9.3
37
38
  required_rubygems_version: !ruby/object:Gem::Requirement
38
39
  requirements:
39
- - - '>='
40
+ - - ">="
40
41
  - !ruby/object:Gem::Version
41
42
  version: '0'
42
43
  requirements: []