watch_tower 0.0.1.beta8 → 0.0.1.beta9

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,7 +40,15 @@ module WatchTower
40
40
  aliases: "-p",
41
41
  default: 9282,
42
42
  desc: "Set the server's port."
43
+ method_option :debug,
44
+ type: :boolean,
45
+ required: false,
46
+ aliases: "-d",
47
+ default: false,
48
+ desc: "Run in debug mode."
43
49
  def start
50
+ # Set the logger to debug mode if necessary
51
+ LOG.level = Logger::DEBUG if options[:debug]
44
52
  if Config[:enabled] &&
45
53
  (!options[:bootloader] || (options[:bootloader] && Config[:launch_on_boot]))
46
54
  LOG.info "Starting WatchTower."
@@ -62,16 +70,24 @@ module WatchTower
62
70
  else
63
71
  LOG.debug "#{__FILE__}:#{__LINE__}: Running WatchTower in the background."
64
72
  pid = fork do
65
- # Try to replace ruby with WatchTower in the command line (for ps)
66
- $0 = 'watchtower' unless $0 == 'watchtower'
67
-
68
- # Tell ruby that we are a daemon
69
- Process.daemon
70
-
71
- # Start WatchTower
72
- start_watch_tower
73
-
74
- LOG.debug "#{__FILE__}:#{__LINE__}: WatchTower has finished."
73
+ begin
74
+ # Try to replace ruby with WatchTower in the command line (for ps)
75
+ $0 = 'watchtower' unless $0 == 'watchtower'
76
+
77
+ # Tell ruby that we are a daemon
78
+ Process.daemon
79
+
80
+ # Start WatchTower
81
+ start_watch_tower
82
+
83
+ LOG.debug "#{__FILE__}:#{__LINE__}: WatchTower has finished."
84
+ rescue => e
85
+ LOG.fatal "#{__FILE__}:#{__LINE__ - 2}: The process raised an exception \#{e.message}"
86
+ LOG.fatal "#{__FILE__}:#{__LINE__ - 3}: ==== Backtrace ===="
87
+ e.backtrace.each do |trace|
88
+ LOG.fatal "#{__FILE__}:#{__LINE__ - 5}: \#{trace}"
89
+ end
90
+ end
75
91
  end
76
92
  end
77
93
  end
@@ -139,4 +155,4 @@ module WatchTower
139
155
  end
140
156
  end
141
157
  end
142
- end
158
+ end
@@ -26,14 +26,14 @@ module WatchTower
26
26
  #
27
27
  # Child class should implement this method
28
28
  def name
29
- editor.try(:name).try(:get)
29
+ @name ||= editor.try(:name).try(:get)
30
30
  end
31
31
 
32
32
  # Returns the version of the editor
33
33
  #
34
34
  # Child class should implement this method
35
35
  def version
36
- editor.try(:version).try(:get)
36
+ @version ||= editor.try(:version).try(:get)
37
37
  end
38
38
 
39
39
  # Return the path of the document being edited
@@ -59,11 +59,11 @@ module WatchTower
59
59
  #
60
60
  # @return [String]
61
61
  def to_s
62
- "\#{self.class.to_s.split('::').last} Editor"
62
+ "\#{self.class.to_s.split('::').last} Editor Version \#{version}"
63
63
  end
64
64
  END
65
65
  end
66
66
  end
67
67
  end
68
68
  end
69
- end
69
+ end
@@ -29,7 +29,7 @@ module WatchTower
29
29
  #
30
30
  # @return [String]
31
31
  def to_s
32
- "\#{self.class.to_s.split('::').last} Editor"
32
+ "\#{self.class.to_s.split('::').last} Editor Version \#{version}"
33
33
  end
34
34
  END
35
35
  end
@@ -25,14 +25,27 @@ module WatchTower
25
25
  #
26
26
  # @return [String] The editor's version
27
27
  def version
28
- version = nil
28
+ return if @version
29
+
30
+ @version = nil
29
31
  if is_running?
30
- Open3.popen2 "#{editor} --version" do |stdin, stdout, wait_thr|
31
- version = stdout.read.scan(/^VIM - Vi IMproved (\d+\.\d+).*/).first.first
32
+ editor_command = editor
33
+ begin
34
+ Open3.popen2 "#{editor_command} --version" do |stdin, stdout, wait_thr|
35
+ parsed_stdout = stdout.read.scan(/^VIM - Vi IMproved (\d+\.\d+).*/)
36
+ LOG.info "#{__FILE__}:#{__LINE__ - 1}: Parsed vim --version: #{parsed_stdout.inspect}"
37
+ @version = parsed_stdout.try(:first).try(:first)
38
+ end
39
+
40
+ raise VimVersionNotPrinted if @version.nil?
41
+ rescue VimVersionNotPrinted
42
+ if editor_command =~ /gvim|mvim/
43
+ editor_command = WatchTower.which('vim')
44
+ retry
45
+ end
32
46
  end
33
47
  end
34
-
35
- version
48
+ @version
36
49
  end
37
50
 
38
51
  # Is it running ?
@@ -19,6 +19,8 @@ module WatchTower
19
19
  EditorError = Class.new WatchTowerError
20
20
  TextmateError = Class.new EditorError
21
21
  XcodeError = Class.new EditorError
22
+ VimError = Class.new EditorError
23
+ VimVersionNotPrinted = Class.new VimError
22
24
 
23
25
  # Exceptions raised by the Server module
24
26
  ServerError = Class.new WatchTowerError
@@ -58,12 +58,14 @@ module WatchTower
58
58
  App.run!(options)
59
59
 
60
60
  LOG.debug("#{__FILE__}:#{__LINE__}: The server has stopped.")
61
+
62
+ # Exit this thread immediately
61
63
  exit
62
- rescue Exception => e
63
- LOG.fatal "#{__FILE__}:#{__LINE__ - 4}: #{e}"
64
+ rescue => e
65
+ LOG.fatal "#{__FILE__}:#{__LINE__ - 4}: #{e}" unless e.message == 'exit'
64
66
  raise e
65
67
  end
66
68
  end
67
69
  end
68
70
  end
69
- end
71
+ end
@@ -4,7 +4,7 @@ module WatchTower
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
6
  TINY = 1
7
- PRE = 'beta8'
7
+ PRE = 'beta9'
8
8
 
9
9
  def self.version
10
10
  # Init the version
data/lib/watch_tower.rb CHANGED
@@ -40,6 +40,9 @@ module WatchTower
40
40
  # Create a logger
41
41
  LOG = Logger.new(File.join(LOG_PATH, "#{ENV['WATCH_TOWER_ENV']}.log"))
42
42
 
43
+ # Make it by default warn level
44
+ LOG.level = Logger::WARN
45
+
43
46
  # Threads
44
47
  # Hash
45
48
  @@threads = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watch_tower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.beta8
4
+ version: 0.0.1.beta9
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &6542020 !ruby/object:Gem::Requirement
16
+ requirement: &6394760 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *6542020
24
+ version_requirements: *6394760
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &6563580 !ruby/object:Gem::Requirement
27
+ requirement: &6393860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.6.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *6563580
35
+ version_requirements: *6393860
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activerecord
38
- requirement: &6561180 !ruby/object:Gem::Requirement
38
+ requirement: &6393200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 3.1.1
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *6561180
46
+ version_requirements: *6393200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sinatra
49
- requirement: &6560120 !ruby/object:Gem::Requirement
49
+ requirement: &6392100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.3.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *6560120
57
+ version_requirements: *6392100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sinatra-snap
60
- requirement: &6558920 !ruby/object:Gem::Requirement
60
+ requirement: &6389560 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.3.2
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *6558920
68
+ version_requirements: *6389560
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: haml
71
- requirement: &6557280 !ruby/object:Gem::Requirement
71
+ requirement: &6413760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 3.1.3
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *6557280
79
+ version_requirements: *6413760
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: grit
82
- requirement: &6574640 !ruby/object:Gem::Requirement
82
+ requirement: &6411520 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.4.1
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *6574640
90
+ version_requirements: *6411520
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: coffee-script
93
- requirement: &6573800 !ruby/object:Gem::Requirement
93
+ requirement: &6410160 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 2.2.0
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *6573800
101
+ version_requirements: *6410160
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: uglifier
104
- requirement: &6573120 !ruby/object:Gem::Requirement
104
+ requirement: &6409520 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 1.0.3
110
110
  type: :runtime
111
111
  prerelease: false
112
- version_requirements: *6573120
112
+ version_requirements: *6409520
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: sass
115
- requirement: &6571940 !ruby/object:Gem::Requirement
115
+ requirement: &6408340 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ~>
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 3.1.10
121
121
  type: :runtime
122
122
  prerelease: false
123
- version_requirements: *6571940
123
+ version_requirements: *6408340
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: sprockets
126
- requirement: &6570400 !ruby/object:Gem::Requirement
126
+ requirement: &6407700 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ~>
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: 2.0.2
132
132
  type: :runtime
133
133
  prerelease: false
134
- version_requirements: *6570400
134
+ version_requirements: *6407700
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: cronedit
137
- requirement: &6569280 !ruby/object:Gem::Requirement
137
+ requirement: &6407160 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ~>
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 0.3.0
143
143
  type: :runtime
144
144
  prerelease: false
145
- version_requirements: *6569280
145
+ version_requirements: *6407160
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: guard
148
- requirement: &6583600 !ruby/object:Gem::Requirement
148
+ requirement: &6406660 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ~>
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: 0.8.4
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *6583600
156
+ version_requirements: *6406660
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: guard-bundler
159
- requirement: &6582220 !ruby/object:Gem::Requirement
159
+ requirement: &6406040 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ~>
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: 0.1.3
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *6582220
167
+ version_requirements: *6406040
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: guard-rspec
170
- requirement: &6581500 !ruby/object:Gem::Requirement
170
+ requirement: &6422300 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ~>
@@ -175,10 +175,10 @@ dependencies:
175
175
  version: 0.4.5
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *6581500
178
+ version_requirements: *6422300
179
179
  - !ruby/object:Gem::Dependency
180
180
  name: guard-sprockets2
181
- requirement: &6580240 !ruby/object:Gem::Requirement
181
+ requirement: &6420140 !ruby/object:Gem::Requirement
182
182
  none: false
183
183
  requirements:
184
184
  - - ~>
@@ -186,10 +186,10 @@ dependencies:
186
186
  version: 0.0.5
187
187
  type: :development
188
188
  prerelease: false
189
- version_requirements: *6580240
189
+ version_requirements: *6420140
190
190
  - !ruby/object:Gem::Dependency
191
191
  name: yard
192
- requirement: &6579440 !ruby/object:Gem::Requirement
192
+ requirement: &6418960 !ruby/object:Gem::Requirement
193
193
  none: false
194
194
  requirements:
195
195
  - - ~>
@@ -197,10 +197,10 @@ dependencies:
197
197
  version: 0.7.2
198
198
  type: :development
199
199
  prerelease: false
200
- version_requirements: *6579440
200
+ version_requirements: *6418960
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: rspec
203
- requirement: &6577800 !ruby/object:Gem::Requirement
203
+ requirement: &6417860 !ruby/object:Gem::Requirement
204
204
  none: false
205
205
  requirements:
206
206
  - - ~>
@@ -208,10 +208,10 @@ dependencies:
208
208
  version: 2.6.0
209
209
  type: :development
210
210
  prerelease: false
211
- version_requirements: *6577800
211
+ version_requirements: *6417860
212
212
  - !ruby/object:Gem::Dependency
213
213
  name: rspec-rails
214
- requirement: &6592720 !ruby/object:Gem::Requirement
214
+ requirement: &6416460 !ruby/object:Gem::Requirement
215
215
  none: false
216
216
  requirements:
217
217
  - - ~>
@@ -219,10 +219,10 @@ dependencies:
219
219
  version: 2.6.1
220
220
  type: :development
221
221
  prerelease: false
222
- version_requirements: *6592720
222
+ version_requirements: *6416460
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: capybara
225
- requirement: &6591440 !ruby/object:Gem::Requirement
225
+ requirement: &6442520 !ruby/object:Gem::Requirement
226
226
  none: false
227
227
  requirements:
228
228
  - - ~>
@@ -230,10 +230,10 @@ dependencies:
230
230
  version: 1.1.1
231
231
  type: :development
232
232
  prerelease: false
233
- version_requirements: *6591440
233
+ version_requirements: *6442520
234
234
  - !ruby/object:Gem::Dependency
235
235
  name: launchy
236
- requirement: &6588580 !ruby/object:Gem::Requirement
236
+ requirement: &6441520 !ruby/object:Gem::Requirement
237
237
  none: false
238
238
  requirements:
239
239
  - - ~>
@@ -241,10 +241,10 @@ dependencies:
241
241
  version: 2.0.5
242
242
  type: :development
243
243
  prerelease: false
244
- version_requirements: *6588580
244
+ version_requirements: *6441520
245
245
  - !ruby/object:Gem::Dependency
246
246
  name: mocha
247
- requirement: &6587320 !ruby/object:Gem::Requirement
247
+ requirement: &6439040 !ruby/object:Gem::Requirement
248
248
  none: false
249
249
  requirements:
250
250
  - - ~>
@@ -252,10 +252,10 @@ dependencies:
252
252
  version: 0.10.0
253
253
  type: :development
254
254
  prerelease: false
255
- version_requirements: *6587320
255
+ version_requirements: *6439040
256
256
  - !ruby/object:Gem::Dependency
257
257
  name: factory_girl
258
- requirement: &6585700 !ruby/object:Gem::Requirement
258
+ requirement: &6437260 !ruby/object:Gem::Requirement
259
259
  none: false
260
260
  requirements:
261
261
  - - ~>
@@ -263,10 +263,10 @@ dependencies:
263
263
  version: 2.1.2
264
264
  type: :development
265
265
  prerelease: false
266
- version_requirements: *6585700
266
+ version_requirements: *6437260
267
267
  - !ruby/object:Gem::Dependency
268
268
  name: timecop
269
- requirement: &6605860 !ruby/object:Gem::Requirement
269
+ requirement: &6435880 !ruby/object:Gem::Requirement
270
270
  none: false
271
271
  requirements:
272
272
  - - ~>
@@ -274,10 +274,10 @@ dependencies:
274
274
  version: 0.3.5
275
275
  type: :development
276
276
  prerelease: false
277
- version_requirements: *6605860
277
+ version_requirements: *6435880
278
278
  - !ruby/object:Gem::Dependency
279
279
  name: pry
280
- requirement: &6603500 !ruby/object:Gem::Requirement
280
+ requirement: &6434980 !ruby/object:Gem::Requirement
281
281
  none: false
282
282
  requirements:
283
283
  - - ~>
@@ -285,7 +285,7 @@ dependencies:
285
285
  version: 0.9.6.2
286
286
  type: :development
287
287
  prerelease: false
288
- version_requirements: *6603500
288
+ version_requirements: *6434980
289
289
  description: ! 'Did you ever want to keep track of how much time you _really_ spend
290
290
  on all of
291
291