install_theme 0.5.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +15 -0
- data/Manifest.txt +7 -0
- data/Rakefile +1 -1
- data/lib/install_theme.rb +45 -14
- data/lib/install_theme/cli.rb +10 -6
- data/lib/install_theme/templates/app/helpers/template_helper.rb +11 -0
- data/spec/expected/rails/bloganje/app/helpers/template_helper.rb +11 -0
- data/spec/expected/rails/bloganje/app/views/layouts/_header.html.erb +1 -0
- data/spec/expected/rails/bloganje/app/views/layouts/_header.html.haml +1 -0
- data/spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.erb +32 -0
- data/spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.haml +63 -0
- data/spec/expected/rails/bloganje/app/views/layouts/application.html.erb +2 -2
- data/spec/expected/rails/bloganje/app/views/layouts/application.html.haml +2 -2
- data/spec/expected/rails/the-hobbit-website-template/app/helpers/template_helper.rb +11 -0
- data/spec/expected/rails/the-hobbit-website-template/app/views/layouts/application.html.erb +2 -2
- data/spec/install_theme_haml_spec.rb +17 -20
- data/spec/install_theme_spec.rb +22 -34
- data/spec/spec_helper.rb +6 -5
- metadata +10 -3
data/History.txt
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
=== 0.6.0 / 2009-10-02
|
2
|
+
|
3
|
+
Major:
|
4
|
+
|
5
|
+
* the extracted partials are now converted into app/views/layouts/_section.html.erb/haml partials and automatically loaded if not overridden
|
6
|
+
* Partials extracted from template become default partial contents using #render_or_default
|
7
|
+
To override, either use content_for(:label) [as before] or add a _label.html.erb/haml partial
|
8
|
+
in your controller's app/views/my_controller folder
|
9
|
+
* Contents removed for <%= yield %> are now included in the original_templates/index.html.erb/haml file for future reference
|
10
|
+
|
11
|
+
Minor:
|
12
|
+
|
13
|
+
* remove .erb files if successfully converted to .haml [Jack Chen and Dr Nic Williams]
|
14
|
+
* Extract the CLI arguments after doing the options parsing, so that it can find -h + -v helper flags [Jack Chen and Dr Nic Williams]
|
15
|
+
|
1
16
|
=== 0.5.2 / 2009-09-29
|
2
17
|
|
3
18
|
NOTE: Haml output can be improved by installing haml from http://github.com/drnic/haml
|
data/Manifest.txt
CHANGED
@@ -6,6 +6,7 @@ bin/install_theme
|
|
6
6
|
lib/install_theme.rb
|
7
7
|
lib/install_theme/cli.rb
|
8
8
|
lib/install_theme/install_theme_generator.rb
|
9
|
+
lib/install_theme/templates/app/helpers/template_helper.rb
|
9
10
|
script/console
|
10
11
|
script/destroy
|
11
12
|
script/generate
|
@@ -57,6 +58,11 @@ spec/expected/rails/bloganje/README
|
|
57
58
|
spec/expected/rails/bloganje/Rakefile
|
58
59
|
spec/expected/rails/bloganje/app/controllers/application_controller.rb
|
59
60
|
spec/expected/rails/bloganje/app/helpers/application_helper.rb
|
61
|
+
spec/expected/rails/bloganje/app/helpers/template_helper.rb
|
62
|
+
spec/expected/rails/bloganje/app/views/layouts/_header.html.erb
|
63
|
+
spec/expected/rails/bloganje/app/views/layouts/_header.html.haml
|
64
|
+
spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.erb
|
65
|
+
spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.haml
|
60
66
|
spec/expected/rails/bloganje/app/views/layouts/application.html.erb
|
61
67
|
spec/expected/rails/bloganje/app/views/layouts/application.html.haml
|
62
68
|
spec/expected/rails/bloganje/config/boot.rb
|
@@ -160,6 +166,7 @@ spec/expected/rails/the-hobbit-website-template/README
|
|
160
166
|
spec/expected/rails/the-hobbit-website-template/Rakefile
|
161
167
|
spec/expected/rails/the-hobbit-website-template/app/controllers/application_controller.rb
|
162
168
|
spec/expected/rails/the-hobbit-website-template/app/helpers/application_helper.rb
|
169
|
+
spec/expected/rails/the-hobbit-website-template/app/helpers/template_helper.rb
|
163
170
|
spec/expected/rails/the-hobbit-website-template/app/views/layouts/application.html.erb
|
164
171
|
spec/expected/rails/the-hobbit-website-template/config/boot.rb
|
165
172
|
spec/expected/rails/the-hobbit-website-template/config/database.yml
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ $hoe = Hoe.spec 'install_theme' do
|
|
13
13
|
self.rubyforge_name = "drnicutilities"
|
14
14
|
extra_deps << ['hpricot','>= 0.8.1']
|
15
15
|
extra_deps << ['rubigen','>= 1.5.2']
|
16
|
-
extra_deps << ['haml', '>= 2.
|
16
|
+
extra_deps << ['haml', '>= 2.3.0']
|
17
17
|
extra_dev_deps << ['rails', '2.3.4']
|
18
18
|
end
|
19
19
|
|
data/lib/install_theme.rb
CHANGED
@@ -10,13 +10,13 @@ require 'sass/css'
|
|
10
10
|
require 'haml/exec'
|
11
11
|
|
12
12
|
class InstallTheme
|
13
|
-
VERSION = "0.
|
13
|
+
VERSION = "0.6.0"
|
14
14
|
|
15
15
|
attr_reader :template_root, :rails_root, :index_path, :template_type
|
16
16
|
attr_reader :stylesheet_dir, :javascript_dir, :image_dir
|
17
17
|
attr_reader :content_id, :inside_yields
|
18
18
|
attr_reader :stdout
|
19
|
-
attr_reader :
|
19
|
+
attr_reader :original_named_yields, :original_body_content
|
20
20
|
|
21
21
|
def initialize(options = {})
|
22
22
|
@template_root = File.expand_path(options[:template_root] || File.dirname('.'))
|
@@ -35,11 +35,13 @@ class InstallTheme
|
|
35
35
|
|
36
36
|
def apply_to_target(options = {})
|
37
37
|
@stdout = options[:stdout] || @stdout || $stdout
|
38
|
-
@
|
38
|
+
@original_named_yields = {}
|
39
39
|
convert_file_to_layout(index_path, 'app/views/layouts/application.html.erb')
|
40
40
|
convert_to_haml('app/views/layouts/application.html.erb') if haml?
|
41
41
|
prepare_sample_controller_and_view
|
42
|
+
prepare_layout_partials
|
42
43
|
prepare_assets
|
44
|
+
prepare_helpers
|
43
45
|
run_generator(options)
|
44
46
|
show_readme
|
45
47
|
end
|
@@ -72,16 +74,7 @@ class InstallTheme
|
|
72
74
|
|
73
75
|
def convert_file_to_layout(html_path, layout_path)
|
74
76
|
File.open(File.join(template_temp_path, layout_path), "w") do |f|
|
75
|
-
|
76
|
-
doc = Hpricot(index_file)
|
77
|
-
doc.search("##{content_id},.#{content_id}").each { |elm| elm.inner_html = "<%= yield %>" }
|
78
|
-
inside_yields.to_a.each do |name, css_path|
|
79
|
-
doc.search(css_path).each do |elm|
|
80
|
-
inside_yields_originals[name] = elm.inner_html.strip
|
81
|
-
elm.inner_html = "<%= yield(:#{name}) %>"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
contents = doc.to_html
|
77
|
+
contents = File.read(File.join(template_root, html_path)).gsub(/\r/, '')
|
85
78
|
template_images.each do |file|
|
86
79
|
image = File.basename(file)
|
87
80
|
contents.gsub!(%r{(["'])/?[\w_\-\/]*#{image}}, '\1/images/' + image)
|
@@ -100,6 +93,20 @@ class InstallTheme
|
|
100
93
|
contents.gsub!(%r{(["'])/?#{javascript_dir}}, '\1/javascripts') unless javascript_dir.blank?
|
101
94
|
|
102
95
|
contents.sub!(%r{\s*</head>}, "\n <%= yield(:head) %>\n</head>")
|
96
|
+
|
97
|
+
doc = Hpricot(contents)
|
98
|
+
doc.search("##{content_id},.#{content_id}").each do |elm|
|
99
|
+
@original_body_content = elm.inner_html.strip
|
100
|
+
elm.inner_html = "<%= yield %>"
|
101
|
+
end
|
102
|
+
inside_yields.to_a.each do |name, css_path|
|
103
|
+
doc.search(css_path).each do |elm|
|
104
|
+
original_named_yields[name] = elm.inner_html.strip
|
105
|
+
elm.inner_html = "<%= yield(:#{name}) || render_or_default('#{name}') %>"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
contents = doc.to_html
|
109
|
+
|
103
110
|
f << contents
|
104
111
|
end
|
105
112
|
end
|
@@ -146,13 +153,29 @@ class InstallTheme
|
|
146
153
|
File.open("app/views/original_template/index.html.erb", "w") do |f|
|
147
154
|
f << "<p>You are using named yields. Here are examples how to use them:</p>\n"
|
148
155
|
f << show_content_for(:head, '<script></script>')
|
149
|
-
|
156
|
+
original_named_yields.to_a.each do |key, original_contents|
|
150
157
|
f << show_content_for(key, original_contents)
|
158
|
+
f << "\n"
|
159
|
+
end
|
160
|
+
f << "\n\n"
|
161
|
+
if original_body_content
|
162
|
+
f << "<!-- original body content -->"
|
163
|
+
f << original_body_content
|
151
164
|
end
|
152
165
|
end
|
153
166
|
end
|
154
167
|
convert_to_haml('app/views/original_template/index.html.erb') if haml?
|
155
168
|
end
|
169
|
+
|
170
|
+
def prepare_layout_partials
|
171
|
+
original_named_yields.to_a.each do |key, original_contents|
|
172
|
+
partial_file = "app/views/layouts/_#{key}.html.erb"
|
173
|
+
File.open(File.join(template_temp_path, partial_file), "w") do |f|
|
174
|
+
f << original_contents.strip
|
175
|
+
end
|
176
|
+
convert_to_haml(partial_file) if haml?
|
177
|
+
end
|
178
|
+
end
|
156
179
|
|
157
180
|
def prepare_assets
|
158
181
|
template_stylesheets.each do |file|
|
@@ -172,6 +195,14 @@ class InstallTheme
|
|
172
195
|
end
|
173
196
|
end
|
174
197
|
|
198
|
+
def prepare_helpers
|
199
|
+
root = File.join(File.dirname(__FILE__), "install_theme", "templates")
|
200
|
+
Dir[File.join(root, "**/*")].each do |f|
|
201
|
+
templates_file = f.gsub(root, "").gsub(%r{^/}, '')
|
202
|
+
FileUtils.cp_r(f, File.join(template_temp_path, templates_file))
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
175
206
|
def run_generator(options)
|
176
207
|
# now use rubigen to install the files into the rails app
|
177
208
|
# so users can get conflict resolution options from command line
|
data/lib/install_theme/cli.rb
CHANGED
@@ -4,15 +4,12 @@ class InstallTheme
|
|
4
4
|
class CLI
|
5
5
|
def self.execute(stdout, arguments=[])
|
6
6
|
options = {}
|
7
|
-
options[:template_root] = arguments.shift
|
8
|
-
options[:rails_root] = arguments.shift
|
9
|
-
options[:content_id] = arguments.shift
|
10
7
|
parser = OptionParser.new do |opts|
|
11
8
|
opts.banner = <<-BANNER.gsub(/^ /,'')
|
12
9
|
Use any HTML template as a theme generator for your Rails app.
|
13
|
-
|
10
|
+
|
14
11
|
Usage: #{File.basename($0)} path/to/template path/to/rails_app content_id [options]
|
15
|
-
|
12
|
+
|
16
13
|
Options are:
|
17
14
|
BANNER
|
18
15
|
opts.separator ""
|
@@ -34,10 +31,17 @@ class InstallTheme
|
|
34
31
|
options[:inside_yields][key.strip.to_sym] = css_path.strip
|
35
32
|
end
|
36
33
|
opts.on("-h", "--help",
|
37
|
-
"Show this help message.") { stdout.puts opts; exit }
|
34
|
+
"Show this help message.") { |arg| stdout.puts opts; exit }
|
35
|
+
opts.on("-v", "--version",
|
36
|
+
"Show the version (which is #{InstallTheme::VERSION})."
|
37
|
+
) { |arg| stdout.puts InstallTheme::VERSION; exit }
|
38
38
|
opts.parse!(arguments)
|
39
39
|
end
|
40
|
+
options[:template_root] = arguments.shift
|
41
|
+
options[:rails_root] = arguments.shift
|
42
|
+
options[:content_id] = arguments.shift
|
40
43
|
unless options[:template_root] && options[:rails_root]
|
44
|
+
stdout.puts "trying"
|
41
45
|
stdout.puts parser; exit
|
42
46
|
end
|
43
47
|
InstallTheme.new(options).apply_to_target
|
@@ -0,0 +1 @@
|
|
1
|
+
My eCommerce Admin area
|
@@ -0,0 +1 @@
|
|
1
|
+
My eCommerce Admin area
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<ul>
|
2
|
+
<li><h3><a href="#" class="house">Dashboard</a></h3>
|
3
|
+
<ul>
|
4
|
+
<li><a href="#" class="report">Sales Report</a></li>
|
5
|
+
<li><a href="#" class="report_seo">SEO Report</a></li>
|
6
|
+
<li><a href="#" class="search">Search</a></li>
|
7
|
+
</ul>
|
8
|
+
</li>
|
9
|
+
<li><h3><a href="#" class="folder_table">Orders</a></h3>
|
10
|
+
<ul>
|
11
|
+
<li><a href="#" class="addorder">New order</a></li>
|
12
|
+
<li><a href="#" class="shipping">Shipments</a></li>
|
13
|
+
<li><a href="#" class="invoices">Invoices</a></li>
|
14
|
+
</ul>
|
15
|
+
</li>
|
16
|
+
<li><h3><a href="#" class="manage">Manage</a></h3>
|
17
|
+
<ul>
|
18
|
+
<li><a href="#" class="manage_page">Pages</a></li>
|
19
|
+
<li><a href="#" class="cart">Products</a></li>
|
20
|
+
<li><a href="#" class="folder">Product categories</a></li>
|
21
|
+
<li><a href="#" class="promotions">Promotions</a></li>
|
22
|
+
</ul>
|
23
|
+
</li>
|
24
|
+
<li><h3><a href="#" class="user">Users</a></h3>
|
25
|
+
<ul>
|
26
|
+
<li><a href="#" class="useradd">Add user</a></li>
|
27
|
+
<li><a href="#" class="group">User groups</a></li>
|
28
|
+
<li><a href="#" class="search">Find user</a></li>
|
29
|
+
<li><a href="#" class="online">Users online</a></li>
|
30
|
+
</ul>
|
31
|
+
</li>
|
32
|
+
</ul>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
%ul
|
2
|
+
%li
|
3
|
+
%h3
|
4
|
+
%a.house{ :href => "#" }
|
5
|
+
Dashboard
|
6
|
+
%ul
|
7
|
+
%li
|
8
|
+
%a.report{ :href => "#" }
|
9
|
+
Sales Report
|
10
|
+
%li
|
11
|
+
%a.report_seo{ :href => "#" }
|
12
|
+
SEO Report
|
13
|
+
%li
|
14
|
+
%a.search{ :href => "#" }
|
15
|
+
Search
|
16
|
+
%li
|
17
|
+
%h3
|
18
|
+
%a.folder_table{ :href => "#" }
|
19
|
+
Orders
|
20
|
+
%ul
|
21
|
+
%li
|
22
|
+
%a.addorder{ :href => "#" }
|
23
|
+
New order
|
24
|
+
%li
|
25
|
+
%a.shipping{ :href => "#" }
|
26
|
+
Shipments
|
27
|
+
%li
|
28
|
+
%a.invoices{ :href => "#" }
|
29
|
+
Invoices
|
30
|
+
%li
|
31
|
+
%h3
|
32
|
+
%a.manage{ :href => "#" }
|
33
|
+
Manage
|
34
|
+
%ul
|
35
|
+
%li
|
36
|
+
%a.manage_page{ :href => "#" }
|
37
|
+
Pages
|
38
|
+
%li
|
39
|
+
%a.cart{ :href => "#" }
|
40
|
+
Products
|
41
|
+
%li
|
42
|
+
%a.folder{ :href => "#" }
|
43
|
+
Product categories
|
44
|
+
%li
|
45
|
+
%a.promotions{ :href => "#" }
|
46
|
+
Promotions
|
47
|
+
%li
|
48
|
+
%h3
|
49
|
+
%a.user{ :href => "#" }
|
50
|
+
Users
|
51
|
+
%ul
|
52
|
+
%li
|
53
|
+
%a.useradd{ :href => "#" }
|
54
|
+
Add user
|
55
|
+
%li
|
56
|
+
%a.group{ :href => "#" }
|
57
|
+
User groups
|
58
|
+
%li
|
59
|
+
%a.search{ :href => "#" }
|
60
|
+
Find user
|
61
|
+
%li
|
62
|
+
%a.online{ :href => "#" }
|
63
|
+
Users online
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<body>
|
19
19
|
<div id="container">
|
20
20
|
<div id="header">
|
21
|
-
<h2><%= yield(:header) %></h2>
|
21
|
+
<h2><%= yield(:header) || render_or_default('header') %></h2>
|
22
22
|
<div id="topmenu">
|
23
23
|
<ul>
|
24
24
|
<li class="current"><a href="index.html">Dashboard</a></li>
|
@@ -43,7 +43,7 @@
|
|
43
43
|
</div>
|
44
44
|
<div id="wrapper">
|
45
45
|
<div id="content"><%= yield %></div>
|
46
|
-
<div id="sidebar"><%= yield(:sidebar) %></div>
|
46
|
+
<div id="sidebar"><%= yield(:sidebar) || render_or_default('sidebar') %></div>
|
47
47
|
</div>
|
48
48
|
<div id="footer">
|
49
49
|
<div id="credits">
|
@@ -18,7 +18,7 @@
|
|
18
18
|
#container
|
19
19
|
#header
|
20
20
|
%h2
|
21
|
-
= yield(:header)
|
21
|
+
= yield(:header) || render_or_default('header')
|
22
22
|
#topmenu
|
23
23
|
%ul
|
24
24
|
%li.current
|
@@ -61,7 +61,7 @@
|
|
61
61
|
#content
|
62
62
|
= yield
|
63
63
|
#sidebar
|
64
|
-
= yield(:sidebar)
|
64
|
+
= yield(:sidebar) || render_or_default('sidebar')
|
65
65
|
#footer
|
66
66
|
#credits
|
67
67
|
Template by
|
@@ -19,13 +19,13 @@
|
|
19
19
|
|
20
20
|
<div class="top">
|
21
21
|
|
22
|
-
<div class="navigation"><%= yield(:menu) %></div>
|
22
|
+
<div class="navigation"><%= yield(:menu) || render_or_default('menu') %></div>
|
23
23
|
|
24
24
|
<div class="pattern"><span></span></div>
|
25
25
|
|
26
26
|
<div class="header">
|
27
27
|
<h1>The Hobbit</h1>
|
28
|
-
<p><%= yield(:subtitle) %></p>
|
28
|
+
<p><%= yield(:subtitle) || render_or_default('subtitle') %></p>
|
29
29
|
</div>
|
30
30
|
|
31
31
|
<div class="pattern"><span></span></div>
|
@@ -15,26 +15,22 @@ describe InstallTheme do
|
|
15
15
|
@expected_application = File.dirname(__FILE__) + "/expected/rails/bloganje"
|
16
16
|
end
|
17
17
|
it { @theme.should be_haml }
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
diff = `diff #{expected} #{actual} 2> /dev/null`
|
35
|
-
rputs diff unless diff.strip.empty?
|
36
|
-
diff.strip.should == ""
|
37
|
-
end
|
18
|
+
|
19
|
+
%w[app/views/layouts/application.html.haml
|
20
|
+
app/views/layouts/_header.html.haml
|
21
|
+
app/views/layouts/_sidebar.html.haml
|
22
|
+
app/helpers/template_helper.rb
|
23
|
+
public/stylesheets/sass/style.sass].each do |matching_file|
|
24
|
+
it do
|
25
|
+
expected = clean_file File.join(@expected_application, matching_file), 'expected'
|
26
|
+
actual = clean_file File.join(@target_application, matching_file), 'actual'
|
27
|
+
diff = `diff #{expected} #{actual} 2> /dev/null`
|
28
|
+
rputs diff unless diff.strip.empty?
|
29
|
+
diff.strip.should == ""
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
38
34
|
it { File.should be_exist(File.join(@target_application, "app/views/original_template/index.html.haml")) }
|
39
35
|
context "sample template /original_template/index.html.haml" do
|
40
36
|
subject do
|
@@ -42,6 +38,7 @@ describe InstallTheme do
|
|
42
38
|
end
|
43
39
|
it { should include("- content_for :head do\n %script") }
|
44
40
|
it { should include("- content_for :header do\n My eCommerce Admin area") }
|
41
|
+
it { should include('#rightnow') }
|
45
42
|
end
|
46
43
|
end
|
47
44
|
end
|
data/spec/install_theme_spec.rb
CHANGED
@@ -17,22 +17,16 @@ describe InstallTheme do
|
|
17
17
|
it { @theme.stylesheet_dir.should == "css" }
|
18
18
|
it { @theme.image_dir.should == "img" }
|
19
19
|
it { @theme.should be_erb }
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
rputs diff unless diff.strip.empty?
|
27
|
-
diff.strip.should == ""
|
28
|
-
end
|
29
|
-
|
30
|
-
%w[public/stylesheets/style.css
|
20
|
+
|
21
|
+
%w[app/views/layouts/application.html.erb
|
22
|
+
app/views/layouts/_header.html.erb
|
23
|
+
app/views/layouts/_sidebar.html.erb
|
24
|
+
app/helpers/template_helper.rb
|
25
|
+
public/stylesheets/style.css
|
31
26
|
public/stylesheets/theme.css].each do |matching_file|
|
32
|
-
it { File.should be_exist(File.join(@target_application, matching_file)) }
|
33
27
|
it do
|
34
|
-
expected = File.join(@expected_application, matching_file)
|
35
|
-
actual = File.join(@target_application, matching_file)
|
28
|
+
expected = clean_file File.join(@expected_application, matching_file), 'expected'
|
29
|
+
actual = clean_file File.join(@target_application, matching_file), 'actual'
|
36
30
|
diff = `diff #{expected} #{actual} 2> /dev/null`
|
37
31
|
rputs diff unless diff.strip.empty?
|
38
32
|
diff.strip.should == ""
|
@@ -44,6 +38,7 @@ describe InstallTheme do
|
|
44
38
|
end
|
45
39
|
it { should include("<% content_for :head do -%>\n <script></script>\n<% end -%>") }
|
46
40
|
it { should include("<% content_for :header do -%>\n My eCommerce Admin area\n<% end -%>") }
|
41
|
+
it { should include('<div id="rightnow">') }
|
47
42
|
end
|
48
43
|
end
|
49
44
|
|
@@ -62,27 +57,20 @@ describe InstallTheme do
|
|
62
57
|
end
|
63
58
|
it { @theme.stylesheet_dir.should == "" }
|
64
59
|
it { @theme.image_dir.should == "img" }
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
it do
|
78
|
-
expected = clean_file File.join(@expected_application, matching_file)
|
79
|
-
actual = clean_file File.join(@target_application, matching_file)
|
80
|
-
diff = `diff #{expected} #{actual} 2> /dev/null`
|
81
|
-
rputs diff unless diff.strip.empty?
|
82
|
-
diff.strip.should == ""
|
83
|
-
end
|
60
|
+
|
61
|
+
%w[app/views/layouts/application.html.erb
|
62
|
+
app/helpers/template_helper.rb
|
63
|
+
public/stylesheets/default.css].each do |matching_file|
|
64
|
+
it { File.should be_exist(File.join(@target_application, matching_file)) }
|
65
|
+
it { File.should be_exist(File.join(@expected_application, matching_file)) }
|
66
|
+
it do
|
67
|
+
expected = clean_file File.join(@expected_application, matching_file), 'expected'
|
68
|
+
actual = clean_file File.join(@target_application, matching_file), 'actual'
|
69
|
+
diff = `diff #{expected} #{actual} 2> /dev/null`
|
70
|
+
rputs diff unless diff.strip.empty?
|
71
|
+
diff.strip.should == ""
|
84
72
|
end
|
85
|
-
|
73
|
+
end
|
86
74
|
end
|
87
75
|
end
|
88
76
|
|
data/spec/spec_helper.rb
CHANGED
@@ -18,20 +18,21 @@ module Kernel
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def clean_html(orig_file)
|
21
|
+
def clean_html(orig_file, scope)
|
22
22
|
tmp_dir = ENV['TMPDIR'] || '/tmp'
|
23
|
-
file = File.join(tmp_dir,
|
23
|
+
file = File.join(tmp_dir, "#{scope}_clean_html.html")
|
24
24
|
File.open(file, "w") do |f|
|
25
25
|
f << Hpricot(open(orig_file)).to_html
|
26
26
|
end
|
27
27
|
file
|
28
28
|
end
|
29
29
|
|
30
|
-
def clean_file(orig_file)
|
30
|
+
def clean_file(orig_file, scope)
|
31
|
+
return clean_html(orig_file, scope) if orig_file =~ /html/
|
31
32
|
tmp_dir = ENV['TMPDIR'] || '/tmp'
|
32
|
-
file = File.join(tmp_dir,
|
33
|
+
file = File.join(tmp_dir, "#{scope}_clean_html.html")
|
33
34
|
File.open(file, "w") do |f|
|
34
|
-
f << File.open(orig_file).readlines.join("\n")
|
35
|
+
f << File.open(orig_file).readlines.map {|line| line.strip}.join("\n")
|
35
36
|
end
|
36
37
|
file
|
37
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: install_theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dr Nic Williams
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-02 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.
|
43
|
+
version: 2.3.0
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: rails
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/install_theme.rb
|
90
90
|
- lib/install_theme/cli.rb
|
91
91
|
- lib/install_theme/install_theme_generator.rb
|
92
|
+
- lib/install_theme/templates/app/helpers/template_helper.rb
|
92
93
|
- script/console
|
93
94
|
- script/destroy
|
94
95
|
- script/generate
|
@@ -140,6 +141,11 @@ files:
|
|
140
141
|
- spec/expected/rails/bloganje/Rakefile
|
141
142
|
- spec/expected/rails/bloganje/app/controllers/application_controller.rb
|
142
143
|
- spec/expected/rails/bloganje/app/helpers/application_helper.rb
|
144
|
+
- spec/expected/rails/bloganje/app/helpers/template_helper.rb
|
145
|
+
- spec/expected/rails/bloganje/app/views/layouts/_header.html.erb
|
146
|
+
- spec/expected/rails/bloganje/app/views/layouts/_header.html.haml
|
147
|
+
- spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.erb
|
148
|
+
- spec/expected/rails/bloganje/app/views/layouts/_sidebar.html.haml
|
143
149
|
- spec/expected/rails/bloganje/app/views/layouts/application.html.erb
|
144
150
|
- spec/expected/rails/bloganje/app/views/layouts/application.html.haml
|
145
151
|
- spec/expected/rails/bloganje/config/boot.rb
|
@@ -243,6 +249,7 @@ files:
|
|
243
249
|
- spec/expected/rails/the-hobbit-website-template/Rakefile
|
244
250
|
- spec/expected/rails/the-hobbit-website-template/app/controllers/application_controller.rb
|
245
251
|
- spec/expected/rails/the-hobbit-website-template/app/helpers/application_helper.rb
|
252
|
+
- spec/expected/rails/the-hobbit-website-template/app/helpers/template_helper.rb
|
246
253
|
- spec/expected/rails/the-hobbit-website-template/app/views/layouts/application.html.erb
|
247
254
|
- spec/expected/rails/the-hobbit-website-template/config/boot.rb
|
248
255
|
- spec/expected/rails/the-hobbit-website-template/config/database.yml
|