guard-zeus 2.0.0.pre.alpha.pre.56 → 2.0.0.pre.alpha.pre.63

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +8 -8
  2. data/lib/guard/zeus/runner.rb +44 -19
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTc1NGY5MjAxNmM5OTIyNzU3NTRlZmY5ODI1MjhjNDA4ZDViNjllZg==
4
+ ZDg5NzlkYzU0M2UzMDI4NmIyNDIxYTdmYjAyY2EyYzc2ZWMyNzgyNg==
5
5
  data.tar.gz: !binary |-
6
- MDhhYWY0ZTQyNWQyNThjOTk4NzliMzM2NDdmOTAxMjExZDQ1NmRjOA==
6
+ MDg4MmQ5Y2FlZjY5ZTg5ODRlODQwN2I5OTk3M2U0NmJiOWNlYzQwZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWY0MTM0OTEzYjUxODY4MTFhM2IwODg1ZTk2NjQxMzI3ZGYxZmUwNjIxY2Vl
10
- YWQ5NzhkNjJiOGRmOTJhMGY1MjgzZGRhNGQyMmVjNWE0MzkwNjRhZDNiZjU5
11
- ZmNkNWNjZDBkNmUwN2QwMzBiOGQ0NzI3ODM0ZmE2N2IwMzliMDQ=
9
+ MzFhNGRkMGEyZjE0Y2E4YWRiMmU5NWJkM2E1ZDlkZmJmZTM5MTBhMTBjZGRk
10
+ NTFkMmZhNTAxOTkyMTAzYWIwMzQzNzBkNDJkOGNiZTk1NzQ3NWExZDgyZTUw
11
+ NTc4NmJiMmNjOWRjODE3NDQ1NmQ3YjI0Mjg2NDFlNWZhODk5MzU=
12
12
  data.tar.gz: !binary |-
13
- ODViZjBhOGRiMTUyYzFjZjAxNDVhZTQzZGU3NmVlNTE1OGQyOTc4MzYxMWQ3
14
- MjA4ZjFmZmE4NmFkZjE2YzVjMDdkOTVlZWQ0OTI3NmYwMWUwMDEwMTk1MmI3
15
- NTg2MWVjYzdiMmYzNWRlOGZiNzBiYzE2NTVkZTY3NTJkOTEwOGY=
13
+ ODFlMWU0NjY1YzYyZjUxM2Q4Y2MzMjY2ODE4NjU1NjE0MDE5YjhhNWVkMmU3
14
+ YTdlYjVhZWU3MDJlOGI3ZWJmNDg1ZmEyM2EyMDBiODVmM2JmNTYzMWI2NWY5
15
+ MTg5MTEzNGM4YWFkNTFhYzNlNjdkYjFlOGFiNTUxYTU1MWVjMGI=
@@ -13,13 +13,24 @@ module Guard
13
13
  UI.info "Guard::Zeus Initialized"
14
14
  end
15
15
 
16
+ def kill_zeus
17
+ stop_zeus
18
+ end
19
+
16
20
  def launch_zeus(action)
17
21
  UI.info "#{action}ing Zeus", :reset => true
18
- spawn_zeus zeus_serve_command, zeus_serve_options
19
- end
20
22
 
21
- def kill_zeus
22
- stop_zeus
23
+ # check for a current .zeus.sock
24
+ if File.exist? sockfile
25
+
26
+ # if it's active, use it
27
+ return if can_connect_to_socket?
28
+
29
+ # just delete it
30
+ delete_sockfile
31
+ end
32
+
33
+ spawn_zeus zeus_serve_command, zeus_serve_options
23
34
  end
24
35
 
25
36
  def run(paths)
@@ -37,14 +48,34 @@ module Guard
37
48
 
38
49
  private
39
50
 
40
- def sockfile
41
- File.join(Dir.pwd, ".zeus.sock")
51
+ def bundler?
52
+ @bundler ||= options[:bundler] != false && File.exist?("#{Dir.pwd}/Gemfile")
53
+ end
54
+
55
+ # Return a truthy socket, or catch the thrown exception
56
+ # and return false
57
+ def can_connect_to_socket?
58
+ UNIXSocket.open(sockfile)
59
+ rescue Errno::ECONNREFUSED
60
+ false
61
+ end
62
+
63
+ def delete_sockfile
64
+ File.delete(sockfile)
65
+ end
66
+
67
+ def rspec?
68
+ @rspec ||= options[:rspec] != false && File.exist?("#{Dir.pwd}/spec")
42
69
  end
43
70
 
44
71
  def run_command(cmd, options = '')
45
72
  system "#{cmd} #{options}"
46
73
  end
47
74
 
75
+ def sockfile
76
+ File.join(Dir.pwd, ".zeus.sock")
77
+ end
78
+
48
79
  def spawn_zeus(cmd, options = '')
49
80
  @zeus_pid = fork do
50
81
  exec "#{cmd} #{options}"
@@ -62,10 +93,16 @@ module Guard
62
93
  end
63
94
  rescue Errno::ECHILD
64
95
  end
65
- File.delete(sockfile) if File.exist? sockfile
96
+
97
+ delete_sockfile if File.exist? sockfile
98
+
66
99
  UI.info "Zeus Stopped", :reset => true
67
100
  end
68
101
 
102
+ def test_unit?
103
+ @test_unit ||= options[:test_unit] != false && File.exist?("#{Dir.pwd}/test/test_helper.rb")
104
+ end
105
+
69
106
  def zeus_push_command(paths)
70
107
  cmd_parts = []
71
108
  cmd_parts << "bundle exec" if bundler?
@@ -90,18 +127,6 @@ module Guard
90
127
  opt_parts << options[:cli] unless options[:cli].nil?
91
128
  opt_parts.join(' ')
92
129
  end
93
-
94
- def bundler?
95
- @bundler ||= options[:bundler] != false && File.exist?("#{Dir.pwd}/Gemfile")
96
- end
97
-
98
- def test_unit?
99
- @test_unit ||= options[:test_unit] != false && File.exist?("#{Dir.pwd}/test/test_helper.rb")
100
- end
101
-
102
- def rspec?
103
- @rspec ||= options[:rspec] != false && File.exist?("#{Dir.pwd}/spec")
104
- end
105
130
  end
106
131
  end
107
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: guard-zeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.pre.56
4
+ version: 2.0.0.pre.alpha.pre.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - jonathangreenberg
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-08-06 00:00:00.000000000 Z
13
+ date: 2014-08-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: guard