mango 0.1.1 → 0.5.0.beta1

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.
Files changed (74) hide show
  1. data/.gitignore +6 -0
  2. data/.yardopts +6 -0
  3. data/README.mdown +62 -29
  4. data/Rakefile +62 -0
  5. data/VERSION +1 -0
  6. data/bin/mango +5 -0
  7. data/doc/HISTORY.mdown +71 -0
  8. data/doc/ROAD-MAP.mdown +10 -0
  9. data/lib/mango.rb +7 -0
  10. data/lib/mango/application.rb +334 -0
  11. data/lib/mango/content_page.rb +193 -0
  12. data/lib/mango/dependencies.rb +125 -0
  13. data/lib/mango/flavored_markdown.rb +82 -0
  14. data/lib/mango/rack/debugger.rb +22 -0
  15. data/lib/mango/runner.rb +95 -0
  16. data/lib/mango/templates/Gemfile +4 -0
  17. data/lib/mango/templates/README.md +1 -0
  18. data/lib/mango/templates/config.ru +4 -0
  19. data/lib/mango/templates/content/index.md +5 -0
  20. data/lib/mango/templates/themes/default/public/images/particles.gif +0 -0
  21. data/lib/mango/templates/themes/default/public/javascripts/fireworks.js +546 -0
  22. data/lib/mango/templates/themes/default/public/javascripts/timer.js +5 -0
  23. data/lib/mango/templates/themes/default/public/robots.txt +5 -0
  24. data/lib/mango/templates/themes/default/public/styles/fireworks.css +55 -0
  25. data/lib/mango/templates/themes/default/public/styles/reset.css +54 -0
  26. data/lib/mango/templates/themes/default/styles/screen.sass +17 -0
  27. data/lib/mango/templates/themes/default/views/404.haml +21 -0
  28. data/lib/mango/templates/themes/default/views/layout.haml +20 -0
  29. data/lib/mango/templates/themes/default/views/page.haml +3 -0
  30. data/lib/mango/version.rb +6 -0
  31. data/mango.gemspec +35 -0
  32. data/spec/app_root/content/about/index.haml +1 -0
  33. data/spec/app_root/content/about/us.haml +1 -0
  34. data/spec/app_root/content/engines/haml.haml +7 -0
  35. data/spec/app_root/content/engines/markdown.markdown +7 -0
  36. data/spec/app_root/content/engines/md.md +7 -0
  37. data/spec/app_root/content/engines/mdown.mdown +7 -0
  38. data/spec/app_root/content/index.haml +1 -0
  39. data/spec/app_root/content/override.haml +1 -0
  40. data/spec/app_root/content/page_with_missing_view.haml +4 -0
  41. data/spec/app_root/content/turner+hooch.haml +1 -0
  42. data/spec/app_root/security_hole.haml +1 -0
  43. data/spec/app_root/themes/default/public/default.css +3 -0
  44. data/spec/app_root/themes/default/public/images/index.html +10 -0
  45. data/spec/app_root/themes/default/public/images/ripe-mango.jpg +0 -0
  46. data/spec/app_root/themes/default/public/override +10 -0
  47. data/spec/app_root/themes/default/public/robots.txt +2 -0
  48. data/spec/app_root/themes/default/public/styles/override.css +3 -0
  49. data/spec/app_root/themes/default/public/styles/reset.css +27 -0
  50. data/spec/app_root/themes/default/public/styles/subfolder/another.css +3 -0
  51. data/spec/app_root/themes/default/security_hole.sass +1 -0
  52. data/spec/app_root/themes/default/security_hole.txt +1 -0
  53. data/spec/app_root/themes/default/styles/override.sass +2 -0
  54. data/spec/app_root/themes/default/styles/screen.sass +13 -0
  55. data/spec/app_root/themes/default/styles/subfolder/screen.sass +12 -0
  56. data/spec/app_root/themes/default/views/404.haml +7 -0
  57. data/spec/app_root/themes/default/views/layout.haml +7 -0
  58. data/spec/app_root/themes/default/views/page.haml +4 -0
  59. data/spec/mango/application/routing_content_pages_spec.rb +357 -0
  60. data/spec/mango/application/routing_public_files_spec.rb +181 -0
  61. data/spec/mango/application/routing_style_sheets_spec.rb +286 -0
  62. data/spec/mango/application_spec.rb +34 -0
  63. data/spec/mango/content_page/finding_spec.rb +213 -0
  64. data/spec/mango/content_page/initializing_spec.rb +298 -0
  65. data/spec/mango/content_page_spec.rb +44 -0
  66. data/spec/mango/dependencies_spec.rb +189 -0
  67. data/spec/mango/flavored_markdown_spec.rb +52 -0
  68. data/spec/mango/rack/debugger_spec.rb +114 -0
  69. data/spec/mango/version_spec.rb +18 -0
  70. data/spec/quality_spec.rb +32 -0
  71. data/spec/spec.opts +3 -0
  72. data/spec/spec_helper.rb +18 -0
  73. data/spec/support/matchers/malformed_whitespace_matchers.rb +60 -0
  74. metadata +304 -17
@@ -0,0 +1,286 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+ require "rack/test"
4
+
5
+ describe Mango::Application do
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ Mango::Application
10
+ end
11
+
12
+ #################################################################################################
13
+
14
+ describe "GET /styles/screen.css" do
15
+ before(:each) do
16
+ get "/styles/screen.css"
17
+ end
18
+
19
+ it "should return 200 status code" do
20
+ last_response.should be_ok
21
+ end
22
+
23
+ it "should send the correct Content-Type header" do
24
+ last_response["Content-Type"].should == "text/css"
25
+ end
26
+
27
+ it "should send the correct body content" do
28
+ last_response.body.should == <<-EXPECTED
29
+ @charset "UTF-8";
30
+ .content-navigation {
31
+ border-color: #3bbfce;
32
+ color: #2ca2af; }
33
+
34
+ .border {
35
+ padding: 8px;
36
+ margin: 8px;
37
+ border-color: #3bbfce; }
38
+ EXPECTED
39
+ end
40
+ end
41
+
42
+ #################################################################################################
43
+
44
+ describe "GET /styles/subfolder/screen.css" do
45
+ before(:each) do
46
+ get "/styles/subfolder/screen.css"
47
+ end
48
+
49
+ it "should return 200 status code" do
50
+ last_response.should be_ok
51
+ end
52
+
53
+ it "should send the correct Content-Type header" do
54
+ last_response["Content-Type"].should == "text/css"
55
+ end
56
+
57
+ it "should send the correct body content" do
58
+ last_response.body.should == <<-EXPECTED
59
+ @charset "UTF-8";
60
+ table.hl {
61
+ margin: 2em 0; }
62
+ table.hl td.ln {
63
+ text-align: right; }
64
+
65
+ li {
66
+ font-family: serif;
67
+ font-weight: bold;
68
+ font-size: 1.2em; }
69
+ EXPECTED
70
+ end
71
+ end
72
+
73
+ #################################################################################################
74
+
75
+ describe "GET /styles/reset.css" do
76
+ before(:each) do
77
+ get "/styles/reset.css"
78
+ end
79
+
80
+ it "should return 200 status code" do
81
+ last_response.should be_ok
82
+ end
83
+
84
+ it "should send the correct Content-Type header" do
85
+ last_response["Content-Type"].should == "text/css"
86
+ end
87
+
88
+ it "should send the correct body content" do
89
+ last_response.body.should == <<-EXPECTED
90
+ /*
91
+ html5doctor.com Reset Stylesheet
92
+ v1.4.1
93
+ 2010-03-01
94
+ Author: Richard Clark - http://richclarkdesign.com
95
+ */
96
+
97
+ html, body, div, span, object, iframe,
98
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
99
+ abbr, address, cite, code,
100
+ del, dfn, em, img, ins, kbd, q, samp,
101
+ small, strong, sub, sup, var,
102
+ b, i,
103
+ dl, dt, dd, ol, ul, li,
104
+ fieldset, form, label, legend,
105
+ table, caption, tbody, tfoot, thead, tr, th, td,
106
+ article, aside, canvas, details, figcaption, figure,
107
+ footer, header, hgroup, menu, nav, section, summary,
108
+ time, mark, audio, video {
109
+ margin:0;
110
+ padding:0;
111
+ border:0;
112
+ outline:0;
113
+ font-size:100%;
114
+ vertical-align:baseline;
115
+ background:transparent;
116
+ }
117
+ EXPECTED
118
+ end
119
+ end
120
+
121
+ #################################################################################################
122
+
123
+ describe "GET /styles/override.css" do
124
+ before(:each) do
125
+ get "/styles/override.css"
126
+ end
127
+
128
+ it "should return 200 status code" do
129
+ last_response.should be_ok
130
+ end
131
+
132
+ it "should send the correct Content-Type header" do
133
+ last_response["Content-Type"].should == "text/css"
134
+ end
135
+
136
+ it "should send the correct body content" do
137
+ last_response.body.should == <<-EXPECTED
138
+ #override {
139
+ font-weight: bold;
140
+ }
141
+ EXPECTED
142
+ end
143
+ end
144
+
145
+ #################################################################################################
146
+
147
+ describe "GET /default.css" do
148
+ before(:each) do
149
+ get "/default.css"
150
+ end
151
+
152
+ it "should return 200 status code" do
153
+ last_response.should be_ok
154
+ end
155
+
156
+ it "should send the correct Content-Type header" do
157
+ last_response["Content-Type"].should == "text/css"
158
+ end
159
+
160
+ it "should send the correct body content" do
161
+ last_response.body.should == <<-EXPECTED
162
+ #default {
163
+ background-color: black;
164
+ }
165
+ EXPECTED
166
+ end
167
+ end
168
+
169
+ #################################################################################################
170
+
171
+ describe "GET /styles/subfolder/another.css" do
172
+ before(:each) do
173
+ get "/styles/subfolder/another.css"
174
+ end
175
+
176
+ it "should return 200 status code" do
177
+ last_response.should be_ok
178
+ end
179
+
180
+ it "should send the correct Content-Type header" do
181
+ last_response["Content-Type"].should == "text/css"
182
+ end
183
+
184
+ it "should send the correct body content" do
185
+ last_response.body.should == <<-EXPECTED
186
+ #another {
187
+ color: red;
188
+ }
189
+ EXPECTED
190
+ end
191
+ end
192
+
193
+ #################################################################################################
194
+
195
+ describe "GET /styles/style_not_found.css" do
196
+ before(:each) do
197
+ get "/styles/style_not_found.css"
198
+ end
199
+
200
+ it "should return 404 status code" do
201
+ last_response.should be_not_found
202
+ end
203
+
204
+ it "should send the correct Content-Type header" do
205
+ last_response["Content-Type"].should == "text/html"
206
+ end
207
+
208
+ it "should send the correct body content" do
209
+ last_response.body.should == <<-EXPECTED
210
+ <!DOCTYPE html>
211
+ <html>
212
+ <head>
213
+ <meta charset='utf-8' />
214
+ <title>404 Page</title>
215
+ </head>
216
+ <body>
217
+ <h1>Page not found</h1>
218
+ </body>
219
+ </html>
220
+ EXPECTED
221
+ end
222
+ end
223
+
224
+ #################################################################################################
225
+
226
+ describe "GET /screen.css" do
227
+ before(:each) do
228
+ get "/screen.css"
229
+ end
230
+
231
+ it "should return 404 status code" do
232
+ last_response.should be_not_found
233
+ end
234
+
235
+ it "should send the correct Content-Type header" do
236
+ last_response["Content-Type"].should == "text/html"
237
+ end
238
+
239
+ it "should send the correct body content" do
240
+ last_response.body.should == <<-EXPECTED
241
+ <!DOCTYPE html>
242
+ <html>
243
+ <head>
244
+ <meta charset='utf-8' />
245
+ <title>404 Page</title>
246
+ </head>
247
+ <body>
248
+ <h1>Page not found</h1>
249
+ </body>
250
+ </html>
251
+ EXPECTED
252
+ end
253
+ end
254
+
255
+ #################################################################################################
256
+
257
+ describe "GET /styles/../security_hole.css" do
258
+ before(:each) do
259
+ get "/styles/../security_hole.css"
260
+ end
261
+
262
+ it "should return 404 status code" do
263
+ last_response.should be_not_found
264
+ end
265
+
266
+ it "should send the correct Content-Type header" do
267
+ last_response["Content-Type"].should == "text/html"
268
+ end
269
+
270
+ it "should send the correct body content" do
271
+ last_response.body.should == <<-EXPECTED
272
+ <!DOCTYPE html>
273
+ <html>
274
+ <head>
275
+ <meta charset='utf-8' />
276
+ <title>404 Page</title>
277
+ </head>
278
+ <body>
279
+ <h1>Page not found</h1>
280
+ </body>
281
+ </html>
282
+ EXPECTED
283
+ end
284
+ end
285
+
286
+ end
@@ -0,0 +1,34 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ describe Mango::Application do
5
+ describe "settings" do
6
+ before(:each) do
7
+ @expected = SPEC_APP_ROOT
8
+ end
9
+
10
+ it "root should be app_root" do
11
+ Mango::Application.root.should == @expected
12
+ end
13
+
14
+ it "theme should be default" do
15
+ Mango::Application.theme.should == "default"
16
+ end
17
+
18
+ it "views should be app_root/themes/default/views/" do
19
+ Mango::Application.views.should == File.join(@expected, "themes", "default", "views")
20
+ end
21
+
22
+ it "public should be app_root/themes/default/public/" do
23
+ Mango::Application.public.should == File.join(@expected, "themes", "default", "public")
24
+ end
25
+
26
+ it "styles should be app_root/themes/default/styles/" do
27
+ Mango::Application.styles.should == File.join(@expected, "themes", "default", "styles")
28
+ end
29
+
30
+ it "content should be app_root/content/" do
31
+ Mango::Application.content.should == File.join(@expected, "content")
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,213 @@
1
+ # encoding: UTF-8
2
+ require "spec_helper"
3
+
4
+ describe Mango::ContentPage do
5
+
6
+ #################################################################################################
7
+
8
+ describe "finding app_root/content/engines/haml.haml" do
9
+ before(:all) do
10
+ path = File.join(SPEC_APP_ROOT, "content", "engines", "haml")
11
+ @page = Mango::ContentPage.find_by_path(path)
12
+ end
13
+
14
+ it "should be an instance of Mango::ContentPage" do
15
+ @page.should be_instance_of(Mango::ContentPage)
16
+ end
17
+
18
+ it "should save the data" do
19
+ @page.data.should == <<-EOS
20
+ ---
21
+ title: Haml!
22
+ category:
23
+ - content
24
+ - engine
25
+ ---
26
+ %p /engines/haml.haml
27
+ EOS
28
+ end
29
+
30
+ it "should detect content engine" do
31
+ @page.content_engine.should == :haml
32
+ end
33
+
34
+ it "should load attributes" do
35
+ @page.attributes.should have(3).items
36
+ @page.attributes.should include("title" => "Haml!",)
37
+ @page.attributes.should include("category" => ["content", "engine"])
38
+ @page.attributes.should include("view" => :page)
39
+ end
40
+
41
+ it "should load body" do
42
+ @page.body.should == "%p /engines/haml.haml\n"
43
+ end
44
+
45
+ it "should convert to HTML" do
46
+ @page.to_html.should == "<p>/engines/haml.haml</p>\n"
47
+ end
48
+
49
+ it "should determine the view template's base file name" do
50
+ @page.view.should == :page
51
+ end
52
+ end
53
+
54
+ #################################################################################################
55
+
56
+ describe "finding app_root/content/engines/md.md" do
57
+ before(:all) do
58
+ path = File.join(SPEC_APP_ROOT, "content", "engines", "md")
59
+ @page = Mango::ContentPage.find_by_path(path)
60
+ end
61
+
62
+ it "should be an instance of Mango::ContentPage" do
63
+ @page.should be_instance_of(Mango::ContentPage)
64
+ end
65
+
66
+ it "should save the data" do
67
+ @page.data.should == <<-EOS
68
+ ---
69
+ title: Markdown!
70
+ category:
71
+ - content
72
+ - engine
73
+ ---
74
+ ### /engines/md.md
75
+ EOS
76
+ end
77
+
78
+ it "should detect content engine" do
79
+ @page.content_engine.should == :markdown
80
+ end
81
+
82
+ it "should load attributes" do
83
+ @page.attributes.should have(3).items
84
+ @page.attributes.should include("title" => "Markdown!",)
85
+ @page.attributes.should include("category" => ["content", "engine"])
86
+ @page.attributes.should include("view" => :page)
87
+ end
88
+
89
+ it "should load body" do
90
+ @page.body.should == "### /engines/md.md\n"
91
+ end
92
+
93
+ it "should convert to HTML" do
94
+ @page.to_html.should == "<h3>/engines/md.md</h3>"
95
+ end
96
+
97
+ it "should determine the view template's base file name" do
98
+ @page.view.should == :page
99
+ end
100
+ end
101
+
102
+ #################################################################################################
103
+
104
+ describe "finding app_root/content/engines/mdown.mdown" do
105
+ before(:all) do
106
+ path = File.join(SPEC_APP_ROOT, "content", "engines", "mdown")
107
+ @page = Mango::ContentPage.find_by_path(path)
108
+ end
109
+
110
+ it "should be an instance of Mango::ContentPage" do
111
+ @page.should be_instance_of(Mango::ContentPage)
112
+ end
113
+
114
+ it "should save the data" do
115
+ @page.data.should == <<-EOS
116
+ ---
117
+ title: Markdown!
118
+ category:
119
+ - content
120
+ - engine
121
+ ---
122
+ ### /engines/mdown.mdown
123
+ EOS
124
+ end
125
+
126
+ it "should detect content engine" do
127
+ @page.content_engine.should == :markdown
128
+ end
129
+
130
+ it "should load attributes" do
131
+ @page.attributes.should have(3).items
132
+ @page.attributes.should include("title" => "Markdown!",)
133
+ @page.attributes.should include("category" => ["content", "engine"])
134
+ @page.attributes.should include("view" => :page)
135
+ end
136
+
137
+ it "should load body" do
138
+ @page.body.should == "### /engines/mdown.mdown\n"
139
+ end
140
+
141
+ it "should convert to HTML" do
142
+ @page.to_html.should == "<h3>/engines/mdown.mdown</h3>"
143
+ end
144
+
145
+ it "should determine the view template's base file name" do
146
+ @page.view.should == :page
147
+ end
148
+ end
149
+
150
+ #################################################################################################
151
+
152
+ describe "finding app_root/content/engines/markdown.markdown" do
153
+ before(:all) do
154
+ path = File.join(SPEC_APP_ROOT, "content", "engines", "markdown")
155
+ @page = Mango::ContentPage.find_by_path(path)
156
+ end
157
+
158
+ it "should be an instance of Mango::ContentPage" do
159
+ @page.should be_instance_of(Mango::ContentPage)
160
+ end
161
+
162
+ it "should save the data" do
163
+ @page.data.should == <<-EOS
164
+ ---
165
+ title: Markdown!
166
+ category:
167
+ - content
168
+ - engine
169
+ ---
170
+ ### /engines/markdown.markdown
171
+ EOS
172
+ end
173
+
174
+ it "should detect content engine" do
175
+ @page.content_engine.should == :markdown
176
+ end
177
+
178
+ it "should load attributes" do
179
+ @page.attributes.should have(3).items
180
+ @page.attributes.should include("title" => "Markdown!",)
181
+ @page.attributes.should include("category" => ["content", "engine"])
182
+ @page.attributes.should include("view" => :page)
183
+ end
184
+
185
+ it "should load body" do
186
+ @page.body.should == "### /engines/markdown.markdown\n"
187
+ end
188
+
189
+ it "should convert to HTML" do
190
+ @page.to_html.should == "<h3>/engines/markdown.markdown</h3>"
191
+ end
192
+
193
+ it "should determine the view template's base file name" do
194
+ @page.view.should == :page
195
+ end
196
+ end
197
+
198
+ #################################################################################################
199
+
200
+ describe "finding app_root/content/unknown.anyengine" do
201
+ before(:all) do
202
+ @path = File.join(SPEC_APP_ROOT, "content", "unknown")
203
+ end
204
+
205
+ it "should raise exception" do
206
+ expected_message = "Unable to find content page for path -- #{@path}"
207
+ lambda {
208
+ Mango::ContentPage.find_by_path(@path)
209
+ }.should raise_exception(Mango::ContentPage::PageNotFound, expected_message)
210
+ end
211
+ end
212
+
213
+ end