bdimcheff-staticmatic 0.10.1
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/LICENSE +20 -0
- data/README.markdown +50 -0
- data/Rakefile +31 -0
- data/VERSION.yml +4 -0
- data/bin/staticmatic +23 -0
- data/lib/staticmatic.rb +20 -0
- data/lib/staticmatic/base.rb +87 -0
- data/lib/staticmatic/configuration.rb +18 -0
- data/lib/staticmatic/error.rb +17 -0
- data/lib/staticmatic/helpers.rb +197 -0
- data/lib/staticmatic/mixins/build.rb +46 -0
- data/lib/staticmatic/mixins/helpers.rb +15 -0
- data/lib/staticmatic/mixins/render.rb +125 -0
- data/lib/staticmatic/mixins/rescue.rb +12 -0
- data/lib/staticmatic/mixins/server.rb +6 -0
- data/lib/staticmatic/mixins/setup.rb +20 -0
- data/lib/staticmatic/server.rb +94 -0
- data/lib/staticmatic/template_error.rb +40 -0
- data/lib/staticmatic/templates/default/application.haml +7 -0
- data/lib/staticmatic/templates/default/application.sass +4 -0
- data/lib/staticmatic/templates/default/index.haml +1 -0
- data/lib/staticmatic/templates/rescues/default.haml +7 -0
- data/lib/staticmatic/templates/rescues/template.haml +18 -0
- data/test/base_test.rb +13 -0
- data/test/helpers_test.rb +12 -0
- data/test/render_test.rb +30 -0
- data/test/rescue_test.rb +36 -0
- data/test/sandbox/test_site/configuration.rb +0 -0
- data/test/sandbox/test_site/site/index.html +10 -0
- data/test/sandbox/test_site/site/stylesheets/application.css +2 -0
- data/test/sandbox/test_site/src/helpers/application_helper.rb +5 -0
- data/test/sandbox/test_site/src/layouts/alternate_layout.haml +3 -0
- data/test/sandbox/test_site/src/layouts/application.haml +7 -0
- data/test/sandbox/test_site/src/layouts/projects.haml +1 -0
- data/test/sandbox/test_site/src/pages/hello_world.erb +1 -0
- data/test/sandbox/test_site/src/pages/index.haml +5 -0
- data/test/sandbox/test_site/src/pages/layout_test.haml +2 -0
- data/test/sandbox/test_site/src/pages/page_with_error.haml +5 -0
- data/test/sandbox/test_site/src/pages/page_with_partial_error.haml +3 -0
- data/test/sandbox/test_site/src/partials/menu.haml +1 -0
- data/test/sandbox/test_site/src/partials/partial_with_error.haml +1 -0
- data/test/sandbox/test_site/src/stylesheets/application.sass +2 -0
- data/test/sandbox/test_site/src/stylesheets/css_with_error.sass +5 -0
- data/test/server_test.rb +12 -0
- data/test/setup_test.rb +25 -0
- data/test/template_error_test.rb +23 -0
- data/test/test_helper.rb +20 -0
- metadata +128 -0
data/test/render_test.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
|
+
|
3
|
+
class StaticMatic::RenderTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_staticmatic
|
6
|
+
end
|
7
|
+
|
8
|
+
should "generate content with a layout" do
|
9
|
+
content = @staticmatic.generate_html_with_layout("index")
|
10
|
+
assert_match "StaticMatic", content
|
11
|
+
assert_match "This is some test content", content
|
12
|
+
end
|
13
|
+
|
14
|
+
should "generate html with layout assigned in template" do
|
15
|
+
content = @staticmatic.generate_html_with_layout("layout_test")
|
16
|
+
assert_match "Alternate Layout", content
|
17
|
+
end
|
18
|
+
|
19
|
+
should "generate css" do
|
20
|
+
content = @staticmatic.generate_css("application")
|
21
|
+
end
|
22
|
+
|
23
|
+
should "find source filename from path" do
|
24
|
+
assert_equal "application", @staticmatic.source_template_from_path("@base_dir/src/stylesheets/application.css")[1]
|
25
|
+
end
|
26
|
+
|
27
|
+
should "find layout from passed path" do
|
28
|
+
assert_equal "projects", @staticmatic.determine_layout("test/projects")
|
29
|
+
end
|
30
|
+
end
|
data/test/rescue_test.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
|
+
|
3
|
+
class StaticMatic::RescueTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_staticmatic
|
6
|
+
end
|
7
|
+
|
8
|
+
should "catch haml template errors" do
|
9
|
+
output = @staticmatic.generate_html_with_layout("page_with_error")
|
10
|
+
assert_match /StaticMatic::TemplateError/, output
|
11
|
+
end
|
12
|
+
|
13
|
+
should "catch sass template errors" do
|
14
|
+
output = @staticmatic.generate_css("css_with_error")
|
15
|
+
assert_match /StaticMatic::TemplateError/, output
|
16
|
+
end
|
17
|
+
|
18
|
+
should "re-raise and catch partial errors" do
|
19
|
+
begin
|
20
|
+
@staticmatic.generate_html("page_with_partial_error")
|
21
|
+
rescue StaticMatic::TemplateError => template_error
|
22
|
+
assert_match /partials\/partial_with_error/, template_error.filename
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
should "handle non-template errors" do
|
27
|
+
begin
|
28
|
+
raise Exception.new("This is an exception")
|
29
|
+
rescue Exception => e
|
30
|
+
output = @staticmatic.render_rescue_from_error(e)
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_match /Exception/, output
|
34
|
+
assert_match /This is an exception/, output
|
35
|
+
end
|
36
|
+
end
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>StaticMatic</title>
|
5
|
+
<link rel="stylesheet" href="stylesheets/application.css" media="all"/>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>StaticMatic!</h1>
|
9
|
+
</body>
|
10
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
%h1 Sub dir test
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= "Hello World!" %>
|
@@ -0,0 +1 @@
|
|
1
|
+
My Menu
|
@@ -0,0 +1 @@
|
|
1
|
+
- bang!
|
data/test/server_test.rb
ADDED
data/test/setup_test.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
|
+
|
3
|
+
class StaticMatic::SetupTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_staticmatic
|
6
|
+
end
|
7
|
+
|
8
|
+
should "setup directories" do
|
9
|
+
tmp_dir = File.dirname(__FILE__) + '/sandbox/tmp'
|
10
|
+
staticmatic = StaticMatic::Base.new(tmp_dir)
|
11
|
+
staticmatic.run('setup')
|
12
|
+
|
13
|
+
StaticMatic::Base.base_dirs.each do |dir|
|
14
|
+
assert File.exists?("#{tmp_dir}/#{dir}"), "Should create #{dir}"
|
15
|
+
end
|
16
|
+
|
17
|
+
StaticMatic::Base.base_dirs.reverse.each do |dir|
|
18
|
+
Dir.entries("#{tmp_dir}/#{dir}").each do |file|
|
19
|
+
next if file.match(/^\./)
|
20
|
+
File.delete("#{tmp_dir}/#{dir}/#{file}")
|
21
|
+
end
|
22
|
+
Dir.delete("#{tmp_dir}/#{dir}") if File.exists?("#{tmp_dir}/#{dir}")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/test_helper"
|
2
|
+
|
3
|
+
class StaticMatic::TemplateTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
setup_staticmatic
|
6
|
+
|
7
|
+
template_file = File.join(TEST_SITE_PATH, "src", "pages", "page_with_error.haml")
|
8
|
+
|
9
|
+
begin
|
10
|
+
@staticmatic.generate_html_from_template_source(File.read(template_file))
|
11
|
+
rescue Exception => e
|
12
|
+
@template_error = StaticMatic::TemplateError.new(template_file, e)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
should "extract source around line number" do
|
17
|
+
assert_match /\- bang\!/, @template_error.source_extract
|
18
|
+
end
|
19
|
+
|
20
|
+
should "extract line number from backtrace" do
|
21
|
+
assert_equal "3", @template_error.line_number
|
22
|
+
end
|
23
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'stringio'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/../lib/staticmatic'
|
6
|
+
|
7
|
+
TEST_SITE_PATH = File.join(File.dirname(__FILE__), "sandbox", "test_site")
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
def self.should(description, &block)
|
11
|
+
test_name = "test_should_#{description.gsub(/[\s]/,'_')}".to_sym
|
12
|
+
raise "#{test_name} is already defined in #{self}" if self.instance_methods.include?(test_name.to_s)
|
13
|
+
define_method(test_name, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_staticmatic
|
18
|
+
@staticmatic = StaticMatic::Base.new(TEST_SITE_PATH)
|
19
|
+
end
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bdimcheff-staticmatic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stephen Bartholomew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-25 00:00:00 -07:00
|
13
|
+
default_executable: staticmatic
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: haml
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: mongrel
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.5
|
34
|
+
version:
|
35
|
+
description: Lightweight Static Site Framework
|
36
|
+
email: steve@curve21.com
|
37
|
+
executables:
|
38
|
+
- staticmatic
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.markdown
|
44
|
+
files:
|
45
|
+
- LICENSE
|
46
|
+
- README.markdown
|
47
|
+
- Rakefile
|
48
|
+
- VERSION.yml
|
49
|
+
- bin/staticmatic
|
50
|
+
- lib/staticmatic.rb
|
51
|
+
- lib/staticmatic/base.rb
|
52
|
+
- lib/staticmatic/configuration.rb
|
53
|
+
- lib/staticmatic/error.rb
|
54
|
+
- lib/staticmatic/helpers.rb
|
55
|
+
- lib/staticmatic/mixins/build.rb
|
56
|
+
- lib/staticmatic/mixins/helpers.rb
|
57
|
+
- lib/staticmatic/mixins/render.rb
|
58
|
+
- lib/staticmatic/mixins/rescue.rb
|
59
|
+
- lib/staticmatic/mixins/server.rb
|
60
|
+
- lib/staticmatic/mixins/setup.rb
|
61
|
+
- lib/staticmatic/server.rb
|
62
|
+
- lib/staticmatic/template_error.rb
|
63
|
+
- lib/staticmatic/templates/default/application.haml
|
64
|
+
- lib/staticmatic/templates/default/application.sass
|
65
|
+
- lib/staticmatic/templates/default/index.haml
|
66
|
+
- lib/staticmatic/templates/rescues/default.haml
|
67
|
+
- lib/staticmatic/templates/rescues/template.haml
|
68
|
+
- test/base_test.rb
|
69
|
+
- test/helpers_test.rb
|
70
|
+
- test/render_test.rb
|
71
|
+
- test/rescue_test.rb
|
72
|
+
- test/sandbox/test_site/configuration.rb
|
73
|
+
- test/sandbox/test_site/site/index.html
|
74
|
+
- test/sandbox/test_site/site/stylesheets/application.css
|
75
|
+
- test/sandbox/test_site/src/helpers/application_helper.rb
|
76
|
+
- test/sandbox/test_site/src/layouts/alternate_layout.haml
|
77
|
+
- test/sandbox/test_site/src/layouts/application.haml
|
78
|
+
- test/sandbox/test_site/src/layouts/projects.haml
|
79
|
+
- test/sandbox/test_site/src/pages/hello_world.erb
|
80
|
+
- test/sandbox/test_site/src/pages/index.haml
|
81
|
+
- test/sandbox/test_site/src/pages/layout_test.haml
|
82
|
+
- test/sandbox/test_site/src/pages/page_with_error.haml
|
83
|
+
- test/sandbox/test_site/src/pages/page_with_partial_error.haml
|
84
|
+
- test/sandbox/test_site/src/partials/menu.haml
|
85
|
+
- test/sandbox/test_site/src/partials/partial_with_error.haml
|
86
|
+
- test/sandbox/test_site/src/stylesheets/application.sass
|
87
|
+
- test/sandbox/test_site/src/stylesheets/css_with_error.sass
|
88
|
+
- test/server_test.rb
|
89
|
+
- test/setup_test.rb
|
90
|
+
- test/template_error_test.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
has_rdoc: false
|
93
|
+
homepage: http://staticmatic.net
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options:
|
96
|
+
- --charset=UTF-8
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: "0"
|
110
|
+
version:
|
111
|
+
requirements: []
|
112
|
+
|
113
|
+
rubyforge_project: staticmatic
|
114
|
+
rubygems_version: 1.2.0
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Lightweight Static Site Framework
|
118
|
+
test_files:
|
119
|
+
- test/base_test.rb
|
120
|
+
- test/helpers_test.rb
|
121
|
+
- test/render_test.rb
|
122
|
+
- test/rescue_test.rb
|
123
|
+
- test/sandbox/test_site/configuration.rb
|
124
|
+
- test/sandbox/test_site/src/helpers/application_helper.rb
|
125
|
+
- test/server_test.rb
|
126
|
+
- test/setup_test.rb
|
127
|
+
- test/template_error_test.rb
|
128
|
+
- test/test_helper.rb
|