shutup 0.0.6 → 0.1.0

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: 88343c0c82a295e8f22cb9eee1eebadaa69b5e5d
4
- data.tar.gz: d5de0f49322665566e37adc653cf58cba51cbc7b
3
+ metadata.gz: ed38d3ad472c3617454780095ffbc75051d9c9dd
4
+ data.tar.gz: da39132e53d2ec826a14264a3ec538f6fec6f527
5
5
  SHA512:
6
- metadata.gz: ba9db614208223aa7a3ef0ed5b04da7c829dab6a73f5cb6081ca950e11abb20620ec6e4b405f680d19ecb5eaa39803d94a21df075a95d57a11fb0ff1b308d19f
7
- data.tar.gz: 31b0d557808b45e2f8ce143cc85f06dc77586448e9c8a28d7f264bed3ed588a8e145ebba35abb23bcdcbcb3115dfae5f647d1b714fab178ae7b9f100419c75d1
6
+ metadata.gz: 97ef42ca39c93993318d627ffe10b8abc8b3248cc818fa27e99825246b748f0c8afd072a9bb3401ce6fe032a024c6447338cbd310b583e6e6643658fbd0fff55
7
+ data.tar.gz: ba18c94c1b689ce8675e8e9461ff501b69318098f604ea05de8e519ae18c7bdf7824dbe79e9322f81e19cb964de5a0b99df510f9a59a6ec43dc45ebc24c995b6
data/exe/shutup CHANGED
@@ -5,4 +5,4 @@ require 'shutup'
5
5
 
6
6
  puts "Killing the process."
7
7
 
8
- Shutup::Rails.hit! && Shutup::Rails.delete_pid
8
+ Shutup.process(name: :server)
@@ -0,0 +1,34 @@
1
+ module Shutup
2
+ class Server
3
+ class << self
4
+ def current_dir
5
+ File.expand_path(File.dirname('.'))
6
+ end
7
+
8
+ def pid_file
9
+ "#{current_dir}/tmp/pids/server.pid"
10
+ end
11
+
12
+ def pid
13
+ begin
14
+ File.read(pid_file)
15
+ rescue => e
16
+ e.message << ' Are you sure that the process is running?'
17
+ raise(e)
18
+ end
19
+ end
20
+
21
+ def hit!
22
+ if pid
23
+ system "kill -9 #{pid}"
24
+ puts "Killed process id: #{pid}"
25
+ true
26
+ end
27
+ end
28
+
29
+ def delete_pid
30
+ File.delete(pid_file) if File.exist?(pid_file)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module Shutup
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/shutup.rb CHANGED
@@ -1,35 +1,15 @@
1
1
  require "shutup/version"
2
- module Shutup
3
- class Rails
4
- class << self
5
- def current_dir
6
- File.expand_path(File.dirname(File.dirname('.')))
7
- end
8
-
9
- def pid_file
10
- "#{current_dir}/tmp/pids/server.pid"
11
- end
2
+ require "shutup/server"
12
3
 
13
- def pid
14
- begin
15
- File.read(pid_file)
16
- rescue => e
17
- e.message << ' Are you sure that the process is running?'
18
- raise(e)
19
- end
20
- end
4
+ module Shutup
5
+ ALLOWED_SERVICES = %w(server)
21
6
 
22
- def hit!
23
- if pid
24
- system "kill -9 #{pid}"
25
- puts "Killed process id: #{pid}"
26
- true
27
- end
28
- end
7
+ def self.process(name:)
8
+ ALLOWED_SERVICES.include?(name) && send(name)
9
+ end
29
10
 
30
- def delete_pid
31
- File.delete(pid_file) if File.exist?(pid_file)
32
- end
33
- end
11
+ def self.server
12
+ Shutup::Server.hit! && Shutup::Server.delete_pid
34
13
  end
14
+
35
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shutup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorenzo Sinisi
@@ -71,6 +71,7 @@ files:
71
71
  - bin/setup
72
72
  - exe/shutup
73
73
  - lib/shutup.rb
74
+ - lib/shutup/server.rb
74
75
  - lib/shutup/version.rb
75
76
  - shutup.gemspec
76
77
  homepage: https://github.com/lorenzosinisi/shutup