goat 0.3.42 → 0.3.45

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'goat'
3
- s.version = '0.3.42'
3
+ s.version = '0.3.45'
4
4
  s.summary = 'Pre-release beta version of Goat'
5
5
  s.author = 'Patrick Collison'
6
6
  s.email = 'patrick@collison.ie'
@@ -351,31 +351,33 @@ module Goat
351
351
  hook = find_hook(meth, path)
352
352
  hdrs = {}
353
353
  resp = nil
354
+ req = Rack::Request.new(env)
354
355
 
355
- begin
356
- req = Rack::Request.new(env)
356
+ Dynamic.let(:current_request => req) do
357
+ begin
357
358
 
358
- app = @app_class.new(req)
359
+ app = @app_class.new(req)
359
360
 
360
- begin
361
- run_before_handlers(app)
361
+ begin
362
+ run_before_handlers(app)
363
+ rescue Halt => halt
364
+ return halt.response.to_a
365
+ end
366
+
367
+ if hook
368
+ resp = hook.handle_request(app)
369
+ else
370
+ raise NotFoundError.new(path)
371
+ end
362
372
  rescue Halt => halt
363
- return halt.response.to_a
373
+ resp = halt.response
374
+ rescue Exception => e
375
+ resp = resp_for_error(e, app)
364
376
  end
365
377
 
366
- if hook
367
- resp = hook.handle_request(app)
368
- else
369
- raise NotFoundError.new(path)
370
- end
371
- rescue Halt => halt
372
- resp = halt.response
373
- rescue Exception => e
374
- resp = resp_for_error(e, app)
378
+ run_after_handlers(app)
375
379
  end
376
380
 
377
- run_after_handlers(app)
378
-
379
381
  resp.to_a
380
382
  end
381
383
  end
@@ -590,12 +592,22 @@ module Goat
590
592
 
591
593
  args << IndifferentHash.from_hash(reqargs)
592
594
 
593
- resp = app.respond_with_hook("rpc_#{rpc}", *args)
594
- resp = opts[:is_get] ? resp.to_json : [200, {}, '']
595
+ had_error = false
596
+ begin
597
+ resp = app.respond_with_hook("rpc_#{rpc}", *args)
598
+ resp = opts[:is_get] ? resp.to_json : [200, {}, '']
599
+ rescue Exception => e
600
+ had_error = true
601
+ # even though the actual response returned here doesn't matter too much,
602
+ # we want to call the error handler to make sure any app logic for handling
603
+ # errors is called.
604
+ resp = req_handler.resp_for_error(e, app)
605
+ end
595
606
 
596
- if opts[:live]
607
+ if opts[:live] && !had_error
597
608
  component.update
598
609
  end
610
+
599
611
  end
600
612
  end
601
613
  end
@@ -1268,7 +1280,7 @@ module Goat
1268
1280
  end
1269
1281
 
1270
1282
  def live_spec
1271
- @live_spec ? @live_spec : raise("No live_spec specified")
1283
+ @live_spec
1272
1284
  end
1273
1285
 
1274
1286
  def erb(*args, &blk)
@@ -40,21 +40,24 @@ module Goat
40
40
  end
41
41
 
42
42
  def self.command
43
- @command || "ruby #{$0} #{ARGV.join(' ')}"
43
+ @command || (['ruby', $0] + ARGV)
44
44
  end
45
45
 
46
- def initialize(dir, interval)
47
- @dir = dir
46
+ def initialize(interval, opts={})
47
+ @dirs = opts[:dirs] || []
48
+ @files = opts[:files] || []
48
49
  @interval = interval
49
50
  @cache = {}
50
51
  end
51
52
 
52
53
  def filter_loadpaths
53
- self.class.full_loadpaths.select {|f| f.downcase.start_with?(@dir.downcase)}
54
+ self.class.full_loadpaths.select do |f|
55
+ @dirs.any? { |d| f.downcase.start_with?(d.downcase) }
56
+ end
54
57
  end
55
58
 
56
59
  def watchpaths
57
- @paths ||= filter_loadpaths
60
+ @paths ||= (filter_loadpaths + @files)
58
61
  end
59
62
 
60
63
  def update_cache
@@ -66,7 +69,13 @@ module Goat
66
69
  def reload
67
70
  EM.stop
68
71
  IO.closefrom(3)
69
- Kernel.exec(self.class.command)
72
+ case self.class.command
73
+ when String: cmd = [self.class.command]
74
+ when Array: cmd = self.class.command
75
+ else
76
+ raise "Reload command must be a string or an array"
77
+ end
78
+ Kernel.exec(*cmd)
70
79
  end
71
80
 
72
81
  def maybe_reload
@@ -215,11 +215,12 @@ Goat.LoadingIndicator = {
215
215
  function show() {
216
216
  ld.indicatorActive = true;
217
217
  $(ld.where).prepend(ld.indicator);
218
+ $(ld.where).show();
218
219
  }
219
220
 
220
221
  function hide() {
221
222
  if(ld.indicatorActive)
222
- ld.indicator.remove();
223
+ $(ld.where).hide();
223
224
  }
224
225
 
225
226
  $(document).ready(function() {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 71
4
+ hash: 73
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 42
10
- version: 0.3.42
9
+ - 45
10
+ version: 0.3.45
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Collison
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-15 00:00:00 +00:00
18
+ date: 2011-03-01 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency