deface 0.5.3 → 0.5.4
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/deface.gemspec +1 -1
- data/lib/deface/override.rb +3 -0
- data/spec/deface/template_spec.rb +91 -79
- metadata +8 -6
data/deface.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{deface}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.authors = ["Brian Quinn"]
|
11
11
|
s.description = %q{Deface is a library that allows you to customize ERB views in a Rails application without editing the underlying view.}
|
data/lib/deface/override.rb
CHANGED
@@ -2,116 +2,128 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module ActionView
|
4
4
|
describe Template do
|
5
|
-
|
5
|
+
before(:all) do
|
6
|
+
Deface::Override.all.clear
|
7
|
+
end
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
describe "with no overrides defined" do
|
10
|
+
before(:all) do
|
11
|
+
@updated_at = Time.now - 600
|
12
|
+
@template = ActionView::Template.new("<p>test</p>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html, :updated_at => @updated_at})
|
13
|
+
end
|
11
14
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
it "should initialize new template object" do
|
16
|
+
@template.is_a?(ActionView::Template).should == true
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
+
it "should return unmodified source" do
|
20
|
+
@template.source.should == "<p>test</p>"
|
19
21
|
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
23
|
+
it "should not change updated_at" do
|
24
|
+
@template.updated_at.should == @updated_at
|
25
|
+
end
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
describe "with a single remove override defined" do
|
29
|
+
before(:all) do
|
30
|
+
@updated_at = Time.now - 300
|
31
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :remove => "p", :text => "<h1>Argh!</h1>")
|
32
|
+
@template = ActionView::Template.new("<p>test</p><%= raw(text) %>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html, :updated_at => @updated_at})
|
30
33
|
end
|
31
34
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@template = ActionView::Template.new("<p>test</p>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html})
|
36
|
-
end
|
35
|
+
it "should return modified source" do
|
36
|
+
@template.source.should == "<%= raw(text) %>"
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
39
|
+
it "should change updated_at" do
|
40
|
+
@template.updated_at.should > @updated_at
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "with a single replace override defined" do
|
46
|
+
before(:all) do
|
47
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :replace => "p", :text => "<h1>Argh!</h1>")
|
48
|
+
@template = ActionView::Template.new("<p>test</p>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html})
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should return modified source" do
|
52
|
+
@template.source.should == "<h1>Argh!</h1>"
|
53
|
+
end
|
54
|
+
end
|
46
55
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
{:virtual_path=>"posts/index", :format=>:html})
|
51
|
-
end
|
56
|
+
describe "with a single insert_after override defined" do
|
57
|
+
before(:all) do
|
58
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :insert_after => "img.button", :text => "<% help %>")
|
52
59
|
|
53
|
-
|
54
|
-
|
55
|
-
|
60
|
+
@template = ActionView::Template.new("<div><img class=\"button\" src=\"path/to/button.png\"></div>",
|
61
|
+
"/path/to/file.erb",
|
62
|
+
ActionView::Template::Handlers::ERB,
|
63
|
+
{:virtual_path=>"posts/index", :format=>:html})
|
56
64
|
end
|
57
65
|
|
58
|
-
|
59
|
-
|
60
|
-
|
66
|
+
it "should return modified source" do
|
67
|
+
@template.source.gsub("\n", "").should == "<div><img class=\"button\" src=\"path/to/button.png\"><% help %></div>"
|
68
|
+
end
|
69
|
+
end
|
61
70
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
{:virtual_path=>"posts/index", :format=>:html})
|
66
|
-
end
|
71
|
+
describe "with a single insert_before override defined" do
|
72
|
+
before(:all) do
|
73
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :insert_after => "ul li:last", :text => "<%= help %>")
|
67
74
|
|
68
|
-
|
69
|
-
|
70
|
-
|
75
|
+
@template = ActionView::Template.new("<ul><li>first</li><li>second</li><li>third</li></ul>",
|
76
|
+
"/path/to/file.erb",
|
77
|
+
ActionView::Template::Handlers::ERB,
|
78
|
+
{:virtual_path=>"posts/index", :format=>:html})
|
71
79
|
end
|
72
80
|
|
73
|
-
|
74
|
-
|
75
|
-
|
81
|
+
it "should return modified source" do
|
82
|
+
@template.source.gsub("\n", "").should == "<ul><li>first</li><li>second</li><li>third</li><%= help %></ul>"
|
83
|
+
end
|
84
|
+
end
|
76
85
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
{:virtual_path=>"posts/index", :format=>:html})
|
81
|
-
end
|
86
|
+
describe "with a single insert_top override defined" do
|
87
|
+
before(:all) do
|
88
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :insert_top => "ul", :text => "<li>me first</li>")
|
82
89
|
|
83
|
-
|
84
|
-
|
85
|
-
|
90
|
+
@template = ActionView::Template.new("<ul><li>first</li><li>second</li><li>third</li></ul>",
|
91
|
+
"/path/to/file.erb",
|
92
|
+
ActionView::Template::Handlers::ERB,
|
93
|
+
{:virtual_path=>"posts/index", :format=>:html})
|
86
94
|
end
|
87
95
|
|
88
|
-
|
89
|
-
|
90
|
-
|
96
|
+
it "should return modified source" do
|
97
|
+
@template.source.gsub("\n", "").should == "<ul><li>me first</li><li>first</li><li>second</li><li>third</li></ul>"
|
98
|
+
end
|
99
|
+
end
|
91
100
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
{:virtual_path=>"posts/index", :format=>:html})
|
96
|
-
end
|
101
|
+
describe "with a single insert_bottom override defined" do
|
102
|
+
before(:all) do
|
103
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :insert_bottom => "ul", :text => "<li>I'm always last</li>")
|
97
104
|
|
98
|
-
|
99
|
-
|
100
|
-
|
105
|
+
@template = ActionView::Template.new("<ul><li>first</li><li>second</li><li>third</li></ul>",
|
106
|
+
"/path/to/file.erb",
|
107
|
+
ActionView::Template::Handlers::ERB,
|
108
|
+
{:virtual_path=>"posts/index", :format=>:html})
|
101
109
|
end
|
102
110
|
|
111
|
+
it "should return modified source" do
|
112
|
+
@template.source.gsub("\n", "").should == "<ul><li>first</li><li>second</li><li>third</li><li>I'm always last</li></ul>"
|
113
|
+
end
|
114
|
+
end
|
103
115
|
|
104
|
-
describe "with a single disabled override defined" do
|
105
|
-
before(:all) do
|
106
|
-
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :remove => "p", :text => "<h1>Argh!</h1>", :disabled => true)
|
107
|
-
@template = ActionView::Template.new("<p>test</p><%= raw(text) %>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html})
|
108
|
-
end
|
109
116
|
|
110
|
-
|
111
|
-
|
112
|
-
|
117
|
+
describe "with a single disabled override defined" do
|
118
|
+
before(:all) do
|
119
|
+
Deface::Override.new(:virtual_path => "posts/index", :name => "Posts#index", :remove => "p", :text => "<h1>Argh!</h1>", :disabled => true)
|
120
|
+
@template = ActionView::Template.new("<p>test</p><%= raw(text) %>", "/some/path/to/file.erb", ActionView::Template::Handlers::ERB, {:virtual_path=>"posts/index", :format=>:html})
|
113
121
|
end
|
114
122
|
|
123
|
+
it "should return unmodified source" do
|
124
|
+
@template.source.should == "<p>test</p><%= raw(text) %>"
|
125
|
+
end
|
115
126
|
end
|
127
|
+
|
116
128
|
end
|
117
129
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deface
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 4
|
10
|
+
version: 0.5.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Brian Quinn
|
@@ -15,7 +15,8 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-17 00:00:00 +01:00
|
19
|
+
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: nokogiri
|
@@ -79,6 +80,7 @@ files:
|
|
79
80
|
- spec/deface/template_spec.rb
|
80
81
|
- spec/spec_helper.rb
|
81
82
|
- tasks/deface.rake
|
83
|
+
has_rdoc: true
|
82
84
|
homepage: http://github.com/railsdog/deface
|
83
85
|
licenses: []
|
84
86
|
|
@@ -108,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
110
|
requirements: []
|
109
111
|
|
110
112
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.3.7
|
112
114
|
signing_key:
|
113
115
|
specification_version: 3
|
114
116
|
summary: Deface is a library that allows you to customize ERB views in Rails
|