frank 0.1.3 → 0.2.0
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/README.md +42 -1
- data/Rakefile +6 -3
- data/VERSION +1 -1
- data/bin/frank +3 -26
- data/bin/frankup +1 -0
- data/frank.gemspec +65 -12
- data/lib/frank.rb +10 -3
- data/lib/frank/base.rb +80 -55
- data/lib/frank/imager.rb +39 -0
- data/lib/frank/lorem.rb +54 -0
- data/lib/frank/output.rb +7 -8
- data/lib/frank/rescue.rb +6 -6
- data/lib/frank/statik.rb +23 -21
- data/lib/frank/template_helpers.rb +8 -2
- data/lib/frank/templates/404.haml +1 -1
- data/lib/frank/templates/imager/frank0.jpg +0 -0
- data/lib/frank/templates/imager/frank1.jpg +0 -0
- data/lib/frank/templates/imager/frank2.jpg +0 -0
- data/lib/frank/templates/imager/frank3.jpg +0 -0
- data/lib/frank/templates/imager/frank4.jpg +0 -0
- data/lib/frank/templates/imager/frank5.jpg +0 -0
- data/lib/frank/templates/imager/frank6.jpg +0 -0
- data/lib/frank/templates/imager/frank7.jpg +0 -0
- data/lib/frank/templates/imager/frank8.jpg +0 -0
- data/lib/frank/templates/imager/frank9.png +0 -0
- data/test/helper.rb +29 -0
- data/test/suite.rb +4 -0
- data/test/template/dynamic/_partial.haml +1 -0
- data/test/template/dynamic/builder.builder +1 -0
- data/test/template/dynamic/coffee.coffee +1 -0
- data/test/template/dynamic/erb.erb +1 -0
- data/test/template/dynamic/helper_test.haml +1 -0
- data/test/template/dynamic/index.haml +2 -0
- data/test/template/dynamic/layout.haml +2 -0
- data/test/template/dynamic/layout2.haml +2 -0
- data/test/template/dynamic/layout2_test.haml +1 -0
- data/test/template/dynamic/layout_test.haml +1 -0
- data/test/template/dynamic/liquid.liquid +1 -0
- data/test/template/dynamic/lorem_test.haml +4 -0
- data/test/template/dynamic/markdown.md +1 -0
- data/test/template/dynamic/mustache.mustache +1 -0
- data/test/template/dynamic/partial_test.haml +2 -0
- data/test/template/dynamic/redcloth.textile +1 -0
- data/test/template/dynamic/sass.sass +2 -0
- data/test/template/helpers.rb +5 -0
- data/test/template/settings.yml +67 -0
- data/test/template/static/static.html +1 -0
- data/test/test_base.rb +81 -0
- data/test/test_helpers.rb +53 -0
- data/test/test_output.rb +81 -0
- data/test/test_render.rb +89 -0
- metadata +71 -7
@@ -0,0 +1 @@
|
|
1
|
+
hello from static
|
data/test/test_base.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestBase < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def app
|
6
|
+
proj_dir = File.join(File.dirname(__FILE__), 'template')
|
7
|
+
settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
|
8
|
+
Frank.new do
|
9
|
+
settings.each do |name, value|
|
10
|
+
set name.to_s, value
|
11
|
+
end
|
12
|
+
set :environment, :test
|
13
|
+
set :proj_dir, proj_dir
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'Frank::Base' do
|
18
|
+
|
19
|
+
should 'have all required settings set' do
|
20
|
+
assert_not_nil app.proj_dir
|
21
|
+
assert_not_nil app.server
|
22
|
+
assert_not_nil app.static_folder
|
23
|
+
assert_not_nil app.dynamic_folder
|
24
|
+
assert_not_nil app.templates
|
25
|
+
end
|
26
|
+
|
27
|
+
should 'render a dynamic template given a request' do
|
28
|
+
get '/'
|
29
|
+
|
30
|
+
assert last_response.ok?
|
31
|
+
assert_equal "<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n", last_response.body
|
32
|
+
end
|
33
|
+
|
34
|
+
should 'render a dynamic css without a layout' do
|
35
|
+
get '/sass.css'
|
36
|
+
|
37
|
+
assert last_response.ok?
|
38
|
+
assert_equal "#hello-worlds {\n background: red; }\n", last_response.body
|
39
|
+
end
|
40
|
+
|
41
|
+
should 'render a dynamic javascript without a layout' do
|
42
|
+
get '/coffee.js'
|
43
|
+
|
44
|
+
assert last_response.ok?
|
45
|
+
assert_equal "(function(){\n var greeting;\n greeting = \"Hello CoffeeScript\";\n})();", last_response.body
|
46
|
+
end
|
47
|
+
|
48
|
+
should 'render 404 page if template not found' do
|
49
|
+
get '/not_here.css'
|
50
|
+
|
51
|
+
assert !last_response.ok?
|
52
|
+
assert_equal 'text/html', last_response.content_type
|
53
|
+
assert_match 'Not Found', last_response.body
|
54
|
+
end
|
55
|
+
|
56
|
+
should 'render 500 page for error' do
|
57
|
+
get '/?brok=en'
|
58
|
+
|
59
|
+
assert !last_response.ok?
|
60
|
+
assert_equal 'text/html', last_response.content_type
|
61
|
+
assert_match "undefined local variable or method `non_method'", last_response.body
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'Frank.stub' do
|
67
|
+
|
68
|
+
should 'stub out a project' do
|
69
|
+
out = capture_stdout { Frank.stub('stubbed') }
|
70
|
+
assert_equal Dir.entries('stubbed'), Dir.entries(File.join(LIBDIR, 'template'))
|
71
|
+
putss = "\n-----------------------\n Frank:\n - Creating 'stubbed'\n - Copying Frank template\n\n Congratulations, 'stubbed' is ready to go.\n\n"
|
72
|
+
assert_equal putss, out.string
|
73
|
+
end
|
74
|
+
|
75
|
+
teardown do
|
76
|
+
FileUtils.rm_r File.join(Dir.pwd, 'stubbed')
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestBase < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'Frank::TemplateHelpers' do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
proj_dir = File.join(File.dirname(__FILE__), 'template')
|
9
|
+
settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
|
10
|
+
require File.join(proj_dir, 'helpers')
|
11
|
+
@frank = Frank.new do
|
12
|
+
settings.each do |name, value|
|
13
|
+
set name.to_s, value
|
14
|
+
end
|
15
|
+
set :environment, :test
|
16
|
+
set :proj_dir, proj_dir
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'render haml and use hello_helper' do
|
21
|
+
template = @frank.render_path('helper_test.haml')
|
22
|
+
assert_equal "<div id='layout'>\n <h1>hello from helper</h1>\n</div>\n", template
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'Lorem' do
|
26
|
+
should 'render haml with 3 random lorem words' do
|
27
|
+
template = @frank.render_path('lorem_test.haml')
|
28
|
+
reg = /<p class='words'>(?:\w+\s?){3}<\/p>/
|
29
|
+
assert_match reg, template
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'render haml with 2 random lorem sentences' do
|
33
|
+
template = @frank.render_path('lorem_test.haml')
|
34
|
+
reg = /<p class='sentences'>(?:[^.]+.){2}<\/p>/
|
35
|
+
assert_match reg, template
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'render haml with 1 random lorem paragraph' do
|
39
|
+
template = @frank.render_path('lorem_test.haml')
|
40
|
+
reg = /<p class='paragraphs'>(?:[^\n]+(?:\n\n)?){1}<\/p>/m
|
41
|
+
assert_match reg, template
|
42
|
+
end
|
43
|
+
|
44
|
+
should 'render image url using imager' do
|
45
|
+
template = @frank.render_path('lorem_test.haml')
|
46
|
+
reg = /<img src='\/_img\/400x300.jpg\?random' \/>/
|
47
|
+
assert_match reg, template
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/test/test_output.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestBase < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'Frank::Output' do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
proj_dir = File.join(File.dirname(__FILE__), 'template')
|
9
|
+
settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
|
10
|
+
require File.join(proj_dir, 'helpers')
|
11
|
+
@frank = Frank::Output.new do
|
12
|
+
settings.each do |name, value|
|
13
|
+
set name.to_s, value
|
14
|
+
end
|
15
|
+
set :environment, :test
|
16
|
+
set :proj_dir, proj_dir
|
17
|
+
set :output_folder, 'output'
|
18
|
+
end.dump
|
19
|
+
end
|
20
|
+
|
21
|
+
should 'create the output folder' do
|
22
|
+
assert File.exist? File.join(File.dirname(__FILE__), 'template/output')
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'create index.html' do
|
26
|
+
output = File.join(File.dirname(__FILE__), 'template/output/index.html')
|
27
|
+
assert_equal "<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n", IO.read(output)
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'create partial_test.html' do
|
31
|
+
output = File.join(File.dirname(__FILE__), 'template/output/partial_test.html')
|
32
|
+
assert_equal "<div id='layout'>\n <h1>hello worlds</h1>\n <p>hello from partial</p>\n</div>\n", IO.read(output)
|
33
|
+
end
|
34
|
+
|
35
|
+
should 'create erb.html' do
|
36
|
+
output = File.join(File.dirname(__FILE__), 'template/output/erb.html')
|
37
|
+
assert_equal "<h1>hello worlds</h1>\n", IO.read(output)
|
38
|
+
end
|
39
|
+
|
40
|
+
should 'create redcloth.html' do
|
41
|
+
output = File.join(File.dirname(__FILE__), 'template/output/redcloth.html')
|
42
|
+
assert_equal "<h1>hello worlds</h1>", IO.read(output)
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'create markdown.html' do
|
46
|
+
output = File.join(File.dirname(__FILE__), 'template/output/markdown.html')
|
47
|
+
assert_equal "<h1>hello worlds</h1>\n", IO.read(output)
|
48
|
+
end
|
49
|
+
|
50
|
+
should 'create mustache.html' do
|
51
|
+
output = File.join(File.dirname(__FILE__), 'template/output/mustache.html')
|
52
|
+
assert_equal "<h1>hello worlds</h1>\n", IO.read(output)
|
53
|
+
end
|
54
|
+
|
55
|
+
should 'create liquid.html' do
|
56
|
+
output = File.join(File.dirname(__FILE__), 'template/output/liquid.html')
|
57
|
+
assert_equal "<h1>hello worlds</h1>", IO.read(output)
|
58
|
+
end
|
59
|
+
|
60
|
+
should 'create builder.html' do
|
61
|
+
output = File.join(File.dirname(__FILE__), 'template/output/builder.html')
|
62
|
+
assert_equal "<h1>hello worlds</h1>\n", IO.read(output)
|
63
|
+
end
|
64
|
+
|
65
|
+
should 'copy static.html' do
|
66
|
+
output = File.join(File.dirname(__FILE__), 'template/output/static.html')
|
67
|
+
assert_equal "hello from static", IO.read(output)
|
68
|
+
end
|
69
|
+
|
70
|
+
should 'not create partials' do
|
71
|
+
assert !File.exist?(File.join(File.dirname(__FILE__), 'template/output/_partial.html'))
|
72
|
+
end
|
73
|
+
|
74
|
+
teardown do
|
75
|
+
FileUtils.rm_r File.join(File.dirname(__FILE__), 'template/output')
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/test/test_render.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TestBase < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context 'Frank::Base' do
|
6
|
+
|
7
|
+
setup do
|
8
|
+
proj_dir = File.join(File.dirname(__FILE__), 'template')
|
9
|
+
settings = YAML.load_file(File.join(proj_dir, 'settings.yml'))
|
10
|
+
@frank = Frank.new do
|
11
|
+
settings.each do |name, value|
|
12
|
+
set name.to_s, value
|
13
|
+
end
|
14
|
+
set :environment, :test
|
15
|
+
set :proj_dir, proj_dir
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'layouts' do
|
20
|
+
|
21
|
+
should 'render template using layout' do
|
22
|
+
template = @frank.render_path('layout_test.haml')
|
23
|
+
assert_equal "<div id='layout'>\n <h1>hi inside layout</h1>\n</div>\n", template
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'render template using layout2' do
|
27
|
+
template = @frank.render_path('layout2_test.haml')
|
28
|
+
assert_equal "<div id='layout2'>\n <h1>hi inside layout2</h1>\n</div>\n", template
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'render haml template' do
|
34
|
+
template = @frank.render_path('index.haml')
|
35
|
+
assert_equal "<div id='layout'>\n <h1>hello worlds</h1>\n</div>\n", template
|
36
|
+
end
|
37
|
+
|
38
|
+
should 'render haml template with a haml partial' do
|
39
|
+
template = @frank.render_path('partial_test.haml')
|
40
|
+
assert_equal "<div id='layout'>\n <h1>hello worlds</h1>\n <p>hello from partial</p>\n</div>\n", template
|
41
|
+
end
|
42
|
+
|
43
|
+
should 'render sass template' do
|
44
|
+
template = @frank.render_path('sass.sass')
|
45
|
+
assert_equal "#hello-worlds {\n background: red; }\n", template
|
46
|
+
end
|
47
|
+
|
48
|
+
should 'render coffee template' do
|
49
|
+
template = @frank.render_path('coffee.coffee')
|
50
|
+
assert_equal "(function(){\n var greeting;\n greeting = \"Hello CoffeeScript\";\n})();", template
|
51
|
+
end
|
52
|
+
|
53
|
+
should 'render erb template' do
|
54
|
+
template = @frank.render_path('erb.erb')
|
55
|
+
assert_equal "<h1>hello worlds</h1>\n", template
|
56
|
+
end
|
57
|
+
|
58
|
+
should 'render redcloth template' do
|
59
|
+
template = @frank.render_path('redcloth.textile')
|
60
|
+
assert_equal "<h1>hello worlds</h1>", template
|
61
|
+
end
|
62
|
+
|
63
|
+
should 'render rdiscount template' do
|
64
|
+
template = @frank.render_path('markdown.md')
|
65
|
+
assert_equal "<h1>hello worlds</h1>\n", template
|
66
|
+
end
|
67
|
+
|
68
|
+
should 'render mustache template' do
|
69
|
+
template = @frank.render_path('mustache.mustache')
|
70
|
+
assert_equal "<h1>hello worlds</h1>\n", template
|
71
|
+
end
|
72
|
+
|
73
|
+
should 'render liquid template' do
|
74
|
+
template = @frank.render_path('liquid.liquid')
|
75
|
+
assert_equal "<h1>hello worlds</h1>", template
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'render builder template' do
|
79
|
+
template = @frank.render_path('builder.builder')
|
80
|
+
assert_equal "<h1>hello worlds</h1>\n", template
|
81
|
+
end
|
82
|
+
|
83
|
+
should 'raise template error' do
|
84
|
+
assert_raise(Frank::TemplateError) { @frank.render_path('not_a.template') }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- blahed
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2010-02-
|
13
|
+
date: 2010-02-26 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: "0"
|
24
|
+
version: "1.0"
|
25
25
|
version:
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: mongrel
|
@@ -31,7 +31,7 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: "0"
|
34
|
+
version: "1.0"
|
35
35
|
version:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: haml
|
@@ -41,7 +41,27 @@ dependencies:
|
|
41
41
|
requirements:
|
42
42
|
- - ">="
|
43
43
|
- !ruby/object:Gem::Version
|
44
|
-
version: "0"
|
44
|
+
version: "2.0"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: shoulda
|
48
|
+
type: :development
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "2.0"
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rack-test
|
58
|
+
type: :development
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0.5"
|
45
65
|
version:
|
46
66
|
description: Create/Dump static builds using whatever templating/helper languages you wish
|
47
67
|
email: travis.dunn@thisismedium.com
|
@@ -66,6 +86,8 @@ files:
|
|
66
86
|
- frank.gemspec
|
67
87
|
- lib/frank.rb
|
68
88
|
- lib/frank/base.rb
|
89
|
+
- lib/frank/imager.rb
|
90
|
+
- lib/frank/lorem.rb
|
69
91
|
- lib/frank/output.rb
|
70
92
|
- lib/frank/rescue.rb
|
71
93
|
- lib/frank/statik.rb
|
@@ -74,6 +96,16 @@ files:
|
|
74
96
|
- lib/frank/templates/500.haml
|
75
97
|
- lib/frank/templates/frank-404.png
|
76
98
|
- lib/frank/templates/frank-500.png
|
99
|
+
- lib/frank/templates/imager/frank0.jpg
|
100
|
+
- lib/frank/templates/imager/frank1.jpg
|
101
|
+
- lib/frank/templates/imager/frank2.jpg
|
102
|
+
- lib/frank/templates/imager/frank3.jpg
|
103
|
+
- lib/frank/templates/imager/frank4.jpg
|
104
|
+
- lib/frank/templates/imager/frank5.jpg
|
105
|
+
- lib/frank/templates/imager/frank6.jpg
|
106
|
+
- lib/frank/templates/imager/frank7.jpg
|
107
|
+
- lib/frank/templates/imager/frank8.jpg
|
108
|
+
- lib/frank/templates/imager/frank9.png
|
77
109
|
- lib/frank/tilt.rb
|
78
110
|
- lib/template/dynamic/css/frank.sass
|
79
111
|
- lib/template/dynamic/index.haml
|
@@ -82,6 +114,32 @@ files:
|
|
82
114
|
- lib/template/settings.yml
|
83
115
|
- lib/template/static/images/frank-med.png
|
84
116
|
- lib/template/static/js/frank.js
|
117
|
+
- test/helper.rb
|
118
|
+
- test/suite.rb
|
119
|
+
- test/template/dynamic/_partial.haml
|
120
|
+
- test/template/dynamic/builder.builder
|
121
|
+
- test/template/dynamic/coffee.coffee
|
122
|
+
- test/template/dynamic/erb.erb
|
123
|
+
- test/template/dynamic/helper_test.haml
|
124
|
+
- test/template/dynamic/index.haml
|
125
|
+
- test/template/dynamic/layout.haml
|
126
|
+
- test/template/dynamic/layout2.haml
|
127
|
+
- test/template/dynamic/layout2_test.haml
|
128
|
+
- test/template/dynamic/layout_test.haml
|
129
|
+
- test/template/dynamic/liquid.liquid
|
130
|
+
- test/template/dynamic/lorem_test.haml
|
131
|
+
- test/template/dynamic/markdown.md
|
132
|
+
- test/template/dynamic/mustache.mustache
|
133
|
+
- test/template/dynamic/partial_test.haml
|
134
|
+
- test/template/dynamic/redcloth.textile
|
135
|
+
- test/template/dynamic/sass.sass
|
136
|
+
- test/template/helpers.rb
|
137
|
+
- test/template/settings.yml
|
138
|
+
- test/template/static/static.html
|
139
|
+
- test/test_base.rb
|
140
|
+
- test/test_helpers.rb
|
141
|
+
- test/test_output.rb
|
142
|
+
- test/test_render.rb
|
85
143
|
has_rdoc: true
|
86
144
|
homepage: http://github.com/blahed/frank
|
87
145
|
licenses: []
|
@@ -110,5 +168,11 @@ rubygems_version: 1.3.5
|
|
110
168
|
signing_key:
|
111
169
|
specification_version: 3
|
112
170
|
summary: Stupidly Simple Static Slinger
|
113
|
-
test_files:
|
114
|
-
|
171
|
+
test_files:
|
172
|
+
- test/helper.rb
|
173
|
+
- test/suite.rb
|
174
|
+
- test/template/helpers.rb
|
175
|
+
- test/test_base.rb
|
176
|
+
- test/test_helpers.rb
|
177
|
+
- test/test_output.rb
|
178
|
+
- test/test_render.rb
|