nomo 0.0.43 → 0.0.44

Sign up to get free protection for your applications and to get access to all the features.
data/lib/nomo.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'nomo/version'
2
+ require 'nomo/rack/middleware/unit_of_work'
2
3
  require 'nomo/rails/engine'
3
4
  require 'redis/namespace'
4
5
 
@@ -108,4 +109,16 @@ module Nomo
108
109
  Nomo.redis.publish(channel, msg)
109
110
  end
110
111
  end
112
+
113
+ def unit_of_work
114
+ begin
115
+ yield if block_given?
116
+ ensure
117
+ if @in_multi
118
+ Nomo.redis.discard
119
+ @in_multi = false
120
+ @updates = []
121
+ end
122
+ end
123
+ end
111
124
  end
@@ -0,0 +1,15 @@
1
+ module Nomo
2
+ module Rack
3
+ module Middleware
4
+ class UnitOfWork
5
+ def initialize(app)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ ::Nomo.unit_of_work { @app.call(env) }
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -8,6 +8,10 @@ module Nomo
8
8
  initializer "nomo.conditional_get" do
9
9
  config.to_prepare { ApplicationController.send :include, Nomo::ConditionalGet }
10
10
  end
11
+
12
+ initializer "nomo.rack_middleware" do |app|
13
+ app.config.middleware.use "Nomo::Rack::Middleware::UnitOfWork"
14
+ end
11
15
  end
12
16
  end
13
17
  end
data/lib/nomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nomo
2
- VERSION = "0.0.43"
2
+ VERSION = "0.0.44"
3
3
  end
@@ -13,9 +13,10 @@ $ ->
13
13
  if nomoKey
14
14
  connection.send(nomoKey)
15
15
  else
16
- $.ajax(
16
+ $.ajax
17
17
  type: 'HEAD',
18
- url: document.location.pathname)
18
+ dataType: 'html',
19
+ url: document.location.pathname
19
20
 
20
21
  connection.onmessage = (msg) ->
21
22
  if msg.data == nomoKey
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.44
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-19 00:00:00.000000000 Z
12
+ date: 2012-07-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70179045399300 !ruby/object:Gem::Requirement
16
+ requirement: &70290983063440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70179045399300
24
+ version_requirements: *70290983063440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redis-namespace
27
- requirement: &70179045398880 !ruby/object:Gem::Requirement
27
+ requirement: &70290986344160 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70179045398880
35
+ version_requirements: *70290986344160
36
36
  description: 304 Not Modified Headers made easy.
37
37
  email:
38
38
  - sausman@stackd.com
@@ -50,6 +50,7 @@ files:
50
50
  - lib/nomo/helpers.rb
51
51
  - lib/nomo/model.rb
52
52
  - lib/nomo/page.rb
53
+ - lib/nomo/rack/middleware/unit_of_work.rb
53
54
  - lib/nomo/rails/engine.rb
54
55
  - lib/nomo/version.rb
55
56
  - nomo.gemspec