easy_esi 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -2
- data/Gemfile.lock +35 -37
- data/Rakefile +6 -1
- data/Readme.md +1 -1
- data/VERSION +1 -1
- data/easy_esi.gemspec +8 -7
- data/lib/easy_esi.rb +17 -4
- data/test/easy_esi_test.rb +2 -50
- data/test/test_helper.rb +65 -0
- metadata +31 -51
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,67 +1,65 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actionpack (3.1.
|
5
|
-
activemodel (= 3.1.
|
6
|
-
activesupport (= 3.1.
|
4
|
+
actionpack (3.1.1)
|
5
|
+
activemodel (= 3.1.1)
|
6
|
+
activesupport (= 3.1.1)
|
7
7
|
builder (~> 3.0.0)
|
8
8
|
erubis (~> 2.7.0)
|
9
9
|
i18n (~> 0.6)
|
10
|
-
rack (~> 1.3.
|
11
|
-
rack-cache (~> 1.
|
12
|
-
rack-mount (~> 0.8.
|
13
|
-
rack-test (~> 0.6.
|
14
|
-
sprockets (~> 2.0.
|
15
|
-
|
16
|
-
|
17
|
-
activesupport (= 3.1.0.rc4)
|
18
|
-
bcrypt-ruby (~> 2.1.4)
|
10
|
+
rack (~> 1.3.2)
|
11
|
+
rack-cache (~> 1.1)
|
12
|
+
rack-mount (~> 0.8.2)
|
13
|
+
rack-test (~> 0.6.1)
|
14
|
+
sprockets (~> 2.0.2)
|
15
|
+
activemodel (3.1.1)
|
16
|
+
activesupport (= 3.1.1)
|
19
17
|
builder (~> 3.0.0)
|
20
18
|
i18n (~> 0.6)
|
21
|
-
activesupport (3.1.
|
19
|
+
activesupport (3.1.1)
|
22
20
|
multi_json (~> 1.0)
|
23
|
-
bcrypt-ruby (2.1.4)
|
24
21
|
builder (3.0.0)
|
25
|
-
diff-lcs (1.1.
|
22
|
+
diff-lcs (1.1.3)
|
26
23
|
erubis (2.7.0)
|
27
24
|
git (1.2.5)
|
28
|
-
hike (1.1
|
25
|
+
hike (1.2.1)
|
29
26
|
i18n (0.6.0)
|
30
|
-
jeweler (1.6.
|
27
|
+
jeweler (1.6.4)
|
31
28
|
bundler (~> 1.0)
|
32
29
|
git (>= 1.2.5)
|
33
30
|
rake
|
34
31
|
multi_json (1.0.3)
|
35
|
-
|
36
|
-
|
32
|
+
mynyml-redgreen (0.7.1)
|
33
|
+
term-ansicolor (>= 1.0.4)
|
34
|
+
rack (1.3.5)
|
35
|
+
rack-cache (1.1)
|
37
36
|
rack (>= 0.4)
|
38
|
-
rack-mount (0.8.
|
37
|
+
rack-mount (0.8.3)
|
39
38
|
rack (>= 1.0.0)
|
40
|
-
rack-test (0.6.
|
39
|
+
rack-test (0.6.1)
|
41
40
|
rack (>= 1.0)
|
42
|
-
rake (0.9.2)
|
43
|
-
|
44
|
-
|
45
|
-
rspec-
|
46
|
-
rspec-
|
47
|
-
|
48
|
-
rspec-
|
49
|
-
rspec-expectations (2.6.0)
|
41
|
+
rake (0.9.2.2)
|
42
|
+
rspec (2.7.0)
|
43
|
+
rspec-core (~> 2.7.0)
|
44
|
+
rspec-expectations (~> 2.7.0)
|
45
|
+
rspec-mocks (~> 2.7.0)
|
46
|
+
rspec-core (2.7.1)
|
47
|
+
rspec-expectations (2.7.0)
|
50
48
|
diff-lcs (~> 1.1.2)
|
51
|
-
rspec-mocks (2.
|
52
|
-
sprockets (2.0.
|
53
|
-
hike (~> 1.
|
49
|
+
rspec-mocks (2.7.0)
|
50
|
+
sprockets (2.0.3)
|
51
|
+
hike (~> 1.2)
|
54
52
|
rack (~> 1.0)
|
55
|
-
tilt (
|
56
|
-
|
57
|
-
|
53
|
+
tilt (~> 1.1, != 1.3.0)
|
54
|
+
term-ansicolor (1.0.5)
|
55
|
+
tilt (1.3.3)
|
58
56
|
|
59
57
|
PLATFORMS
|
60
58
|
ruby
|
61
59
|
|
62
60
|
DEPENDENCIES
|
63
|
-
actionpack (~> 3
|
61
|
+
actionpack (~> 3)
|
64
62
|
jeweler
|
63
|
+
mynyml-redgreen
|
65
64
|
rake
|
66
|
-
redgreen
|
67
65
|
rspec (~> 2)
|
data/Rakefile
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require 'rake/testtask'
|
2
|
-
Rake::TestTask.new(:
|
2
|
+
Rake::TestTask.new(:test) do |test|
|
3
3
|
test.libs << 'lib'
|
4
4
|
test.pattern = 'test/**/*_test.rb'
|
5
5
|
test.verbose = true
|
6
6
|
end
|
7
7
|
|
8
|
+
task :default do
|
9
|
+
sh "RAILS=3.0.10 && (bundle || bundle install) && bundle exec rake test"
|
10
|
+
sh "RAILS=3.1.0 && (bundle || bundle install) && bundle exec rake test"
|
11
|
+
end
|
12
|
+
|
8
13
|
begin
|
9
14
|
require 'jeweler'
|
10
15
|
Jeweler::Tasks.new do |gem|
|
data/Readme.md
CHANGED
@@ -31,7 +31,7 @@ Has no effect for non-esi controllers!
|
|
31
31
|
IS NOW
|
32
32
|
<%= esi_render :partial => 'profile', :locals => {:local_variable => :foo} %>
|
33
33
|
|
34
|
-
### Realize that
|
34
|
+
### Realize that it's that simple (10s)
|
35
35
|
|
36
36
|
Behind the scenes
|
37
37
|
=================
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/easy_esi.gemspec
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.2.
|
7
|
+
s.name = "easy_esi"
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date =
|
13
|
-
s.email =
|
12
|
+
s.date = "2011-10-27"
|
13
|
+
s.email = "michael@grosser.it"
|
14
14
|
s.files = [
|
15
15
|
"CHANGELOG",
|
16
16
|
"Gemfile",
|
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
"init.rb",
|
23
23
|
"lib/easy_esi.rb",
|
24
24
|
"test/easy_esi_test.rb",
|
25
|
+
"test/test_helper.rb",
|
25
26
|
"test/views/esi_disabled/_a_partial.erb",
|
26
27
|
"test/views/esi_disabled/show.erb",
|
27
28
|
"test/views/esi_disabled/test_filter.erb",
|
@@ -32,10 +33,10 @@ Gem::Specification.new do |s|
|
|
32
33
|
"test/views/esi_enabled/show.erb",
|
33
34
|
"test/views/esi_enabled/with_hash.erb"
|
34
35
|
]
|
35
|
-
s.homepage =
|
36
|
+
s.homepage = "http://github.com/grosser/easy_esi"
|
36
37
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version =
|
38
|
-
s.summary =
|
38
|
+
s.rubygems_version = "1.8.10"
|
39
|
+
s.summary = "Rails: Cached pages with updated partials"
|
39
40
|
|
40
41
|
if s.respond_to? :specification_version then
|
41
42
|
s.specification_version = 3
|
data/lib/easy_esi.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class EasyEsi
|
2
2
|
VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
|
3
|
-
|
3
|
+
|
4
4
|
def self.include_for(data)
|
5
5
|
%{<esi:include src="#{serialize(data)}"/>}.html_safe
|
6
6
|
end
|
@@ -60,7 +60,11 @@ class ActionController::Caching::Actions::ActionCacheFilter
|
|
60
60
|
end
|
61
61
|
|
62
62
|
class ActionController::Base
|
63
|
-
|
63
|
+
if respond_to?(:class_attribute)
|
64
|
+
class_attribute :esi_enabled
|
65
|
+
else
|
66
|
+
class_inheritable_accessor :esi_enabled
|
67
|
+
end
|
64
68
|
|
65
69
|
def self.enable_esi
|
66
70
|
self.esi_enabled = true
|
@@ -70,8 +74,17 @@ class ActionController::Base
|
|
70
74
|
protected
|
71
75
|
|
72
76
|
def render_esi
|
73
|
-
return if @do_not_replace_esi
|
74
|
-
|
77
|
+
return if @do_not_replace_esi
|
78
|
+
|
79
|
+
if response_body.kind_of?(Array) # Ruby 1.9
|
80
|
+
self.response_body = response_body.map { |body| render_and_replace_esi(body) }
|
81
|
+
elsif response_body.kind_of?(String)
|
82
|
+
self.response_body = render_and_replace_esi(response_body)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def render_and_replace_esi text
|
87
|
+
EasyEsi.replace_includes(text) do |data|
|
75
88
|
data = {:partial => data} if data.kind_of?(String)
|
76
89
|
_render_template(data)
|
77
90
|
end
|
data/test/easy_esi_test.rb
CHANGED
@@ -1,31 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'rspec'
|
3
|
-
require 'active_support/all'
|
4
|
-
require 'action_pack'
|
5
|
-
require 'action_controller'
|
6
|
-
require 'action_dispatch/testing/test_process'
|
7
|
-
require 'test/unit'
|
8
|
-
require 'redgreen'
|
9
|
-
$LOAD_PATH << 'lib'
|
10
|
-
require 'init'
|
11
|
-
|
12
|
-
# fake checks
|
13
|
-
require 'ostruct'
|
14
|
-
module ActionController::UrlFor
|
15
|
-
def _routes
|
16
|
-
helpers = OpenStruct.new
|
17
|
-
helpers.url_helpers = Module.new
|
18
|
-
helpers
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
ActionController::Base.cache_store = :memory_store
|
23
|
-
|
24
|
-
ROUTES = ActionDispatch::Routing::RouteSet.new
|
25
|
-
ROUTES.draw do
|
26
|
-
match ':controller(/:action(/:id(.:format)))'
|
27
|
-
end
|
28
|
-
ROUTES.finalize!
|
1
|
+
require './test/test_helper'
|
29
2
|
|
30
3
|
class EsiDisabledController < ActionController::Base
|
31
4
|
self.view_paths = 'test/views'
|
@@ -44,23 +17,6 @@ class EsiDisabledController < ActionController::Base
|
|
44
17
|
def uncached
|
45
18
|
render :action => :show
|
46
19
|
end
|
47
|
-
|
48
|
-
def self._routes
|
49
|
-
ROUTES
|
50
|
-
end
|
51
|
-
|
52
|
-
def url_for(*args)
|
53
|
-
'xxx'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# funky patch to get @routes working, in 'setup' did not work
|
58
|
-
module ActionController::TestCase::Behavior
|
59
|
-
def process_with_routes(*args)
|
60
|
-
@routes = ROUTES
|
61
|
-
process_without_routes(*args)
|
62
|
-
end
|
63
|
-
alias_method_chain :process, :routes
|
64
20
|
end
|
65
21
|
|
66
22
|
class EsiDisabledTest < ActionController::TestCase
|
@@ -118,10 +74,6 @@ class EsiEnabledController < EsiDisabledController
|
|
118
74
|
def send_a_file
|
119
75
|
send_file "VERSION"
|
120
76
|
end
|
121
|
-
|
122
|
-
def url_for(*args)
|
123
|
-
'xxx'
|
124
|
-
end
|
125
77
|
end
|
126
78
|
|
127
79
|
class EsiEnabledTest < ActionController::TestCase
|
@@ -164,7 +116,7 @@ class EsiEnabledTest < ActionController::TestCase
|
|
164
116
|
end
|
165
117
|
|
166
118
|
test "it can serialize arbitrary data" do
|
167
|
-
data = {'src' => 'something else', 1 =>
|
119
|
+
data = {'src' => 'something else', 1 => 'x', 2 => ['"','/','___----']}
|
168
120
|
get :serialize, :render_data => data
|
169
121
|
@response.body.strip.should == data.inspect
|
170
122
|
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rspec'
|
3
|
+
require 'active_support/all'
|
4
|
+
require 'action_pack'
|
5
|
+
require 'action_controller'
|
6
|
+
require 'test/unit'
|
7
|
+
require 'redgreen'
|
8
|
+
$LOAD_PATH << 'lib'
|
9
|
+
require './init'
|
10
|
+
|
11
|
+
ActionController::Base.cache_store = :memory_store
|
12
|
+
|
13
|
+
if ActionPack::VERSION::MAJOR > 2
|
14
|
+
require 'action_dispatch/testing/test_process'
|
15
|
+
|
16
|
+
# fake checks
|
17
|
+
require 'ostruct'
|
18
|
+
module ActionController::UrlFor
|
19
|
+
def _routes
|
20
|
+
helpers = OpenStruct.new
|
21
|
+
helpers.url_helpers = Module.new
|
22
|
+
helpers
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
ROUTES = ActionDispatch::Routing::RouteSet.new
|
27
|
+
ROUTES.draw do
|
28
|
+
match ':controller(/:action(/:id(.:format)))'
|
29
|
+
end
|
30
|
+
ROUTES.finalize!
|
31
|
+
|
32
|
+
# funky patch to get @routes working, in 'setup' did not work
|
33
|
+
module ActionController::TestCase::Behavior
|
34
|
+
def process_with_routes(*args)
|
35
|
+
@routes = ROUTES
|
36
|
+
process_without_routes(*args)
|
37
|
+
end
|
38
|
+
alias_method_chain :process, :routes
|
39
|
+
end
|
40
|
+
|
41
|
+
class ActionController::Base
|
42
|
+
self.view_paths = 'test/views'
|
43
|
+
|
44
|
+
def self._routes
|
45
|
+
ROUTES
|
46
|
+
end
|
47
|
+
|
48
|
+
def url_for(*args)
|
49
|
+
'xxx'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
require 'action_controller/test_process'
|
54
|
+
|
55
|
+
ActionController::Routing::Routes.reload rescue nil
|
56
|
+
ActionController::Base.cache_store = :memory_store
|
57
|
+
|
58
|
+
class ActionController::Base
|
59
|
+
before_filter :set_view_paths
|
60
|
+
|
61
|
+
def set_view_paths
|
62
|
+
@template.view_paths = 'test/views'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,33 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy_esi
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.3
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 2
|
10
|
-
version: 0.2.2
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Grosser
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2011-10-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activerecord
|
16
|
+
requirement: &74588230 !ruby/object:Gem::Requirement
|
23
17
|
none: false
|
24
|
-
requirements:
|
25
|
-
- -
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :runtime
|
32
|
-
name: activerecord
|
33
|
-
version_requirements: *id001
|
34
23
|
prerelease: false
|
24
|
+
version_requirements: *74588230
|
35
25
|
description:
|
36
26
|
email: michael@grosser.it
|
37
27
|
executables: []
|
38
|
-
|
39
28
|
extensions: []
|
40
|
-
|
41
29
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
30
|
+
files:
|
44
31
|
- CHANGELOG
|
45
32
|
- Gemfile
|
46
33
|
- Gemfile.lock
|
@@ -51,6 +38,7 @@ files:
|
|
51
38
|
- init.rb
|
52
39
|
- lib/easy_esi.rb
|
53
40
|
- test/easy_esi_test.rb
|
41
|
+
- test/test_helper.rb
|
54
42
|
- test/views/esi_disabled/_a_partial.erb
|
55
43
|
- test/views/esi_disabled/show.erb
|
56
44
|
- test/views/esi_disabled/test_filter.erb
|
@@ -60,39 +48,31 @@ files:
|
|
60
48
|
- test/views/esi_enabled/serialize.erb
|
61
49
|
- test/views/esi_enabled/show.erb
|
62
50
|
- test/views/esi_enabled/with_hash.erb
|
63
|
-
has_rdoc: true
|
64
51
|
homepage: http://github.com/grosser/easy_esi
|
65
52
|
licenses: []
|
66
|
-
|
67
53
|
post_install_message:
|
68
54
|
rdoc_options: []
|
69
|
-
|
70
|
-
require_paths:
|
55
|
+
require_paths:
|
71
56
|
- lib
|
72
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
58
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
segments:
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
segments:
|
79
64
|
- 0
|
80
|
-
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
hash: -437317745
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
67
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
88
|
-
- 0
|
89
|
-
version: "0"
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
90
72
|
requirements: []
|
91
|
-
|
92
73
|
rubyforge_project:
|
93
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.8.10
|
94
75
|
signing_key:
|
95
76
|
specification_version: 3
|
96
|
-
summary:
|
77
|
+
summary: ! 'Rails: Cached pages with updated partials'
|
97
78
|
test_files: []
|
98
|
-
|