mango 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # CHANGES
2
2
 
3
+ ## v0.6.2 / 2011-06-06
4
+
5
+ [Full changes](https://github.com/ryansobol/mango/compare/v0.6.1...v0.6.2)
6
+
7
+ ## Bugs
8
+
9
+ * Allow view templates nested within directories [GH#65](https://github.com/ryansobol/mango/issues/65)
10
+ * Pass to next matching route for all get route handlers [GH#64](https://github.com/ryansobol/mango/issues/64)
11
+
12
+ ## Dependencies
13
+
14
+ * Update rack to ~> 1.2.3 [GH#63](https://github.com/ryansobol/mango/issues/63)
15
+ * Add therubyracer-heroku = 0.8.1.pre3 [GH#59](https://github.com/ryansobol/mango/issues/59)
16
+
17
+ ## Chores
18
+
19
+ * Remove rspec task from Rakefile [GH51](https://github.com/ryansobol/mango/issues/51)
20
+
21
+ ## Documentation
22
+
23
+ * Touch up the README.md [GH#62](https://github.com/ryansobol/mango/issues/62)
24
+
25
+ ## Legal
26
+
27
+ * Update copyright to 2011 in README.md [GH#60](https://github.com/ryansobol/mango/issues/60)
28
+
3
29
  ## v0.6.1 / 2011-05-29
4
30
 
5
31
  [Full changes](https://github.com/ryansobol/mango/compare/v0.6.0...v0.6.1)
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mango (0.6.0)
4
+ mango (0.6.2)
5
5
  bluecloth (~> 2.1.0)
6
6
  bundler (~> 1.0.7)
7
7
  coffee-script (~> 2.2.0)
8
8
  haml (~> 3.1.1)
9
9
  liquid (~> 2.2.2)
10
- rack (~> 1.2.2)
10
+ rack (~> 1.2.3)
11
11
  sass (~> 3.1.1)
12
12
  sinatra (~> 1.2.6)
13
+ therubyracer-heroku (= 0.8.1.pre3)
13
14
  thor (~> 0.14.6)
14
15
 
15
16
  GEM
@@ -41,6 +42,7 @@ GEM
41
42
  sinatra (1.2.6)
42
43
  rack (~> 1.1)
43
44
  tilt (>= 1.2.2, < 2.0)
45
+ therubyracer-heroku (0.8.1.pre3)
44
46
  thor (0.14.6)
45
47
  tilt (1.3.2)
46
48
  yard (0.7.1)
@@ -55,10 +57,11 @@ DEPENDENCIES
55
57
  haml (~> 3.1.1)
56
58
  liquid (~> 2.2.2)
57
59
  mango!
58
- rack (~> 1.2.2)
60
+ rack (~> 1.2.3)
59
61
  rack-test (~> 0.6.0)
60
62
  rspec (~> 2.6.0)
61
63
  sass (~> 3.1.1)
62
64
  sinatra (~> 1.2.6)
65
+ therubyracer-heroku (= 0.8.1.pre3)
63
66
  thor (~> 0.14.6)
64
67
  yard (~> 0.7.1)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- Mango release 0.6.1 (May 29, 2011)
1
+ Mango release 0.6.2 (June 6, 2011)
2
2
  ==================================
3
3
 
4
- Copyright (c) 2010 Ryan Sobol. Licensed under the MIT license. Please see the {file:LICENSE} for more information.
4
+ Copyright (c) 2011 Ryan Sobol. Licensed under the MIT license. Please see the {file:LICENSE} for more information.
5
5
 
6
6
  * **Demo Application** : [http://mango-fireworks.heroku.com/](http://mango-fireworks.heroku.com/)
7
7
  * **Source Code**: [https://github.com/ryansobol/mango](https://github.com/ryansobol/mango)
@@ -82,22 +82,21 @@ REQUIREMENTS
82
82
  * [Ruby](http://www.ruby-lang.org/) ~> 1.9.2 ([RVM](http://rvm.beginrescueend.com/) recommended)
83
83
  * [RubyGems](https://rubygems.org/) >= 1.3.7 (bundled with Ruby)
84
84
  * [Bundler](http://gembundler.com/) ~> 1.0.7
85
- * [Rack](http://rack.rubyforge.org/) ~> 1.2.2
85
+ * [Thor](https://github.com/wycats/thor) ~> 0.14.6
86
+ * [Rack](http://rack.rubyforge.org/) ~> 1.2.3
86
87
  * [Sinatra](http://www.sinatrarb.com/) ~> 1.2.6
87
88
  * [Haml](http://haml-lang.com/) ~> 3.1.1
88
89
  * [Sass](http://sass-lang.com/) ~> 3.1.1
89
90
  * [BlueCloth](http://deveiate.org/projects/BlueCloth) ~> 2.1.0
90
91
  * [Liquid](http://www.liquidmarkup.org/) ~> 2.2.2
91
92
  * [CoffeeScript](http://jashkenas.github.com/coffee-script/) ~> 2.2.0
92
- * [Thor](https://github.com/wycats/thor) ~> 0.14.6
93
+ * [TheRubyRacer for Heroku](https://github.com/pwim/therubyracer-heroku) = 0.8.1.pre3
93
94
 
94
95
  ### Optional development dependencies
95
96
 
96
- * [Rake](http://rake.rubyforge.org/) ~> 0.8.7 (bundled with Ruby)
97
97
  * [Rack::Test](https://github.com/brynary/rack-test) ~> 0.6.0
98
98
  * [RSpec](http://rspec.info/) ~> 2.6.0
99
99
  * [YARD](http://yardoc.org/) ~> 0.7.1
100
- * [YARD::Sinatra](https://github.com/rkh/yard-sinatra) ~> 0.5.1
101
100
  * [BlueCloth](http://deveiate.org/projects/BlueCloth) ~> 2.1.0
102
101
 
103
102
  INSTALLING
@@ -108,7 +107,7 @@ INSTALLING
108
107
  I highly recommend [RVM](http://rvm.beginrescueend.com/) by Wayne E. Seguin. It trivializes managing multiple versions of Ruby on one machine.
109
108
 
110
109
  $ ruby -v
111
- ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
110
+ ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
112
111
 
113
112
  **TIP:** The revision and arch-type may differ on your machine.
114
113
 
@@ -128,7 +127,7 @@ Simply edit the gem version in your application's `Gemfile` and re-install with
128
127
  $ cat Gemfile
129
128
  # encoding: UTF-8
130
129
  source "http://rubygems.org"
131
- gem "mango", "~> 0.6.1"
130
+ gem "mango", "~> 0.6.2"
132
131
  $ bundle install
133
132
 
134
133
  **TIP:** If you're working in the insolation of an [RVM gemset](http://rvm.beginrescueend.com/gemsets/basics/), type `gem clean` to uninstall outdated gems.
@@ -208,7 +207,8 @@ Now that the newly generated Mango application is running, here's how the applic
208
207
  * For routes ending in `.js`, Mango searches for a stylesheet template in `themes/javascripts/`.
209
208
  * For routes ending in `.css`, Mango searches for a stylesheet template in `themes/stylesheets/`.
210
209
  * For all other routes, Mango searches for a content page in `content/` and wraps it within a view template in `themes/default/views`.
211
- * If no static or template file is found, Mango routes unknown HTTP requests to a customizable 404 page found in either `themes/default/public` or `themes/default/views`.
210
+ * If no static or template file is found, Mango tries to route the request to a custom route handler if one exists.
211
+ * Finally, Mango routes unknown HTTP requests to a customizable 404 page found in either `themes/default/public` or `themes/default/views`.
212
212
 
213
213
  WRITING
214
214
  -------
data/Rakefile CHANGED
@@ -1,19 +1,5 @@
1
1
  # encoding: UTF-8
2
2
  require File.expand_path("lib/mango", File.dirname(__FILE__))
3
- Mango::Dependencies.warn_at_exit
4
-
5
- ###################################################################################################
6
-
7
- begin
8
- require "rspec/core/rake_task"
9
- require "rack/test" # for Rack support
10
- RSpec::Core::RakeTask.new(:spec)
11
- task :default => :spec
12
- rescue LoadError => e
13
- Mango::Dependencies.create_warning_for(e)
14
- end
15
-
16
- ###################################################################################################
17
3
 
18
4
  namespace :gem do
19
5
  desc "Builds a gem from the current project's Gem::Specification"
@@ -18,7 +18,7 @@ module Mango
18
18
  #
19
19
  # In addition to serving static assets, the application has these dynamic route handlers:
20
20
  #
21
- # * Content page templates with `GET *`
21
+ # * Content page templates with `GET /*`
22
22
  # * JavaScript templates with `GET /javascripts/*.js`
23
23
  # * Stylesheet templates with `GET /stylesheets/*.css`
24
24
  #
@@ -50,9 +50,9 @@ module Mango
50
50
  #
51
51
  # GET /../security_hole.txt => pass to NOT_FOUND error handler
52
52
  #
53
- # # Content page templates with `GET *`
53
+ # # Content page templates with `GET /*`
54
54
  #
55
- # ### Example `GET *` requests routed to content page templates
55
+ # ### Example `GET /*` requests routed to content page templates
56
56
  #
57
57
  # |-- content
58
58
  # | |-- about
@@ -71,8 +71,10 @@ module Mango
71
71
  # GET /about/us => 200 content/about/us.haml
72
72
  # GET /turner%2Bhooch => 200 content/turner+hooch.haml
73
73
  #
74
- # GET /page_not_found => pass to NOT_FOUND error handler
75
- # GET /../security_hole => pass to NOT_FOUND error handler
74
+ # GET /page_not_found => pass to another matching route or to the NOT_FOUND error
75
+ # handler if none exists
76
+ # GET /../security_hole => pass to another matching route or to the NOT_FOUND error
77
+ # handler if none exists
76
78
  #
77
79
  # # JavaScript templates with `GET /javascripts/*.js`
78
80
  #
@@ -102,9 +104,12 @@ module Mango
102
104
  # GET /root.js => 200 themes/default/public/root.js
103
105
  # GET /javascripts/math/opposite.js => 200 themes/default/public/javascripts/math/opposite.js
104
106
  #
105
- # GET /javascripts/not_found.js => pass to NOT_FOUND error handler
106
- # GET /siblings.js => pass to NOT_FOUND error handler
107
- # GET /javascripts/../security_hole.js => pass to NOT_FOUND error handler
107
+ # GET /javascripts/not_found.js => pass to another matching route or to the NOT_FOUND
108
+ # error handler if none exists
109
+ # GET /siblings.js => pass to another matching route or to the NOT_FOUND
110
+ # error handler if none exists
111
+ # GET /javascripts/../security_hole.js => pass to another matching route or to the NOT_FOUND
112
+ # error handler if none exists
108
113
  #
109
114
  # # Stylesheet templates with `GET /stylesheets/*.css`
110
115
  #
@@ -134,15 +139,18 @@ module Mango
134
139
  # GET /default.css => 200 themes/default/public/default.css
135
140
  # GET /stylesheets/folder/print.css => 200 themes/default/public/stylesheets/folder/print.css
136
141
  #
137
- # GET /stylesheets/not_found.css => pass to NOT_FOUND error handler
138
- # GET /screen.css => pass to NOT_FOUND error handler
139
- # GET /stylesheets/../security_hole.css => pass to NOT_FOUND error handler
142
+ # GET /stylesheets/not_found.css => pass to another matching route or to the NOT_FOUND
143
+ # error handler if none exists
144
+ # GET /screen.css => pass to another matching route or to the NOT_FOUND
145
+ # error handler if none exists
146
+ # GET /stylesheets/../security_hole.css => pass to another matching route or to the NOT_FOUND
147
+ # error handler if none exists
140
148
  #
141
149
  # # 404 Page Not Found with `NOT_FOUND`
142
150
  #
143
- # When a requested URI path cannot be matched with a public file or template file, the error
144
- # handler attempts to send a 404 public file or a rendered a 404 template with a 404 HTTP
145
- # response.
151
+ # When a requested URI path cannot be matched with a public file or template file, and cannot be
152
+ # matched to another route, the error handler attempts to send a 404 public file or a rendered a
153
+ # 404 template file with a 404 HTTP response.
146
154
  #
147
155
  # ### Example `GET /page_not_found` request routed to a 404 public file
148
156
  #
@@ -336,8 +344,8 @@ module Mango
336
344
  # **It's intended that requests to public JavaScript files and requests to JavaScript templates
337
345
  # share the `/javascripts/` prefix.**
338
346
  #
339
- # Finally, if no matches are found, the route handler passes execution to the `NOT_FOUND` error
340
- # handler.
347
+ # Finally, if no matches are found, execution is passed to the next matching route handler if
348
+ # one exists. Otherwise, execution is passed to the `NOT_FOUND` error handler.
341
349
  #
342
350
  # @macro [attach] sinatra.get
343
351
  # @overload get "$1"
@@ -346,7 +354,7 @@ module Mango
346
354
  #
347
355
  get "/javascripts/*.js" do |uri_path|
348
356
  render_javascript_template! uri_path
349
- not_found
357
+ pass
350
358
  end
351
359
 
352
360
  # Given a URI path, attempts to render a JavaScript template, if it exists, and halt
@@ -409,14 +417,14 @@ module Mango
409
417
  # **It's intended that requests to public stylesheet files and requests to stylesheet templates
410
418
  # share the `/stylesheets/` prefix.**
411
419
  #
412
- # Finally, if no matches are found, the route handler passes execution to the `NOT_FOUND` error
413
- # handler.
420
+ # Finally, if no matches are found, execution is passed to the next matching route handler if
421
+ # one exists. Otherwise, execution is passed to the `NOT_FOUND` error handler.
414
422
  #
415
423
  # @method get_css
416
424
  #
417
425
  get "/stylesheets/*.css" do |uri_path|
418
426
  render_stylesheet_template! uri_path
419
- not_found
427
+ pass
420
428
  end
421
429
 
422
430
  # Given a URI path, attempts to render a stylesheet template, if it exists, and halt
@@ -488,15 +496,15 @@ module Mango
488
496
  # themes/default/views/page.haml +
489
497
  # themes/default/views/layout.haml
490
498
  #
491
- # Finally, if no matches are found, the route handler passes execution to the `NOT_FOUND` error
492
- # handler.
499
+ # Finally, if no matches are found, execution is passed to the next matching route handler if
500
+ # one exists. Otherwise, execution is passed to the `NOT_FOUND` error handler.
493
501
  #
494
502
  # @method get_all
495
503
  #
496
504
  get "/*" do |uri_path|
497
505
  render_index_file! uri_path
498
506
  render_content_page! uri_path
499
- not_found
507
+ pass
500
508
  end
501
509
 
502
510
  # Given a URI path, attempts to send an index.html file, if it exists, and halt
@@ -6,11 +6,14 @@ class String
6
6
  # Convert a file name to a Sinatra-compliant template name
7
7
  #
8
8
  # @example
9
- # "blog.haml".templatize #=> :blog
9
+ # "blog.haml".templatize #=> :blog
10
+ # "blog/home.erb".templatize #=> :"blog/home"
11
+ # "page.html.liquid".templatize #=> :"page.html"
12
+ # "article/post.html.haml".templatize #=> :"article/post.html"
10
13
  #
11
14
  # @return [Symbol] A Sinatra-compliant template name
12
15
  #
13
16
  def templatize
14
- File.basename(self, '.*').to_sym
17
+ self.rpartition(".").shift.to_sym
15
18
  end
16
19
  end
@@ -1,41 +1,15 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  module Mango
4
- # `Mango::Dependencies` is a module that performs two types of depedency checking:
5
- #
6
- # * Strict parse-time version checking of Ruby
7
- # * Lenient run-time handling of missing development RubyGems
8
- #
9
- # `Mango::Dependencies` automatically enforces a strict parse-time check for the
4
+ # `Mango::Dependencies` is a module that automatically enforces a strict parse-time check for the
10
5
  # `SUPPORTED_RUBY_VERSIONS` on both application and development processes for the Mango
11
- # library. (i.e. `bin/mango`, `rake`, `spec`, `rackup`, etc) Because of this,
6
+ # library. (i.e. `bin/mango`, `rake`, `rspec`, `rackup`, etc) Because of this,
12
7
  # `Mango::Dependencies` is syntactically compatible with Ruby 1.8.7 or higher.
13
8
  #
14
- # `Mango::Dependencies` is also a lenient, run-time handler used in the `Rakefile` to build
15
- # developer-friendly warnings from rescued `LoadError` exceptions raised by missing
16
- # development RubyGem dependencies.
17
- #
18
- # @example Simple usage with the rspec-core gem
19
- # Mango::Dependencies.warn_at_exit
20
- # begin
21
- # require "rspec/core/rake_task"
22
- # RSpec::Core::RakeTask.new(:spec)
23
- # rescue LoadError => e
24
- # Mango::Dependencies.create_warning_for(e)
25
- # end
26
- #
27
- # @see Mango::Dependencies.create_warning_for
28
- # @see Mango::Dependencies.warn_at_exit
29
9
  module Dependencies
30
10
  # A short list of supported Ruby versions
31
11
  SUPPORTED_RUBY_VERSIONS = ["1.9.2"]
32
12
 
33
- # Maps file names to gem name
34
- FILE_NAME_TO_GEM_NAME = {
35
- :"rack/test" => :"rack-test",
36
- :"rspec/core/rake_task" => :"rspec-core",
37
- }
38
-
39
13
  # Checks that the version of the current Ruby process matches the one of the
40
14
  # `SUPPORTED_RUBY_VERSIONS`. This method is automatically invoked at the first time this class
41
15
  # is required, ensuring the correct Ruby version at parse-time.
@@ -51,47 +25,8 @@ http://rvm.beginrescueend.com/
51
25
  ERROR
52
26
  end
53
27
  end
54
- check_ruby_version
55
-
56
- # Empties the warnings cache. This method is called when the class is required.
57
- def self.destroy_warnings
58
- @@warnings_cache = []
59
- end
60
- destroy_warnings
61
-
62
- # Creates and caches a warning from a `LoadError` exception.
63
- #
64
- # @param [LoadError] error A rescued exception
65
- def self.create_warning_for(error)
66
- pattern = %r{no such file to load -- ([\w\-\\/]*)}
67
- error.message.match(pattern) do |match_data|
68
- file_name = match_data[1].to_sym
69
- gem_name = if FILE_NAME_TO_GEM_NAME.has_key?(file_name)
70
- FILE_NAME_TO_GEM_NAME[file_name]
71
- else
72
- file_name
73
- end
74
-
75
- @@warnings_cache << gem_name
76
- end
77
- end
78
-
79
- # Displays a warning message to the user on the standard output channel if there are warnings
80
- # to render.
81
- def self.render_warnings
82
- unless @@warnings_cache.empty?
83
- puts <<-EOS
84
-
85
- Could not require the following RubyGems: #{@@warnings_cache.join(", ")}
86
- Please run "bundle install" to access all development features.
87
-
88
- EOS
89
- end
90
- end
91
28
 
92
- # Attaches a call to `render_warnings` to `Kernel#at_exit`
93
- def self.warn_at_exit
94
- at_exit { render_warnings }
95
- end
29
+ # Automatic enforcement
30
+ check_ruby_version
96
31
  end
97
32
  end
@@ -1,3 +1,3 @@
1
1
  # encoding: UTF-8
2
2
  source "http://rubygems.org"
3
- gem "mango", "~> 0.6.1"
3
+ gem "mango", "~> 0.6.2"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mango
4
4
  # Current stable released version
5
- VERSION = "0.6.1"
5
+ VERSION = "0.6.2"
6
6
  end
@@ -15,18 +15,19 @@ Gem::Specification.new do |s|
15
15
  s.required_rubygems_version = ">= 1.3.7"
16
16
  s.rubyforge_project = "mango"
17
17
 
18
- s.add_runtime_dependency "bundler", "~> 1.0.7"
19
- s.add_runtime_dependency "rack", "~> 1.2.2"
20
- s.add_runtime_dependency "sinatra", "~> 1.2.6"
21
- s.add_runtime_dependency "haml", "~> 3.1.1"
22
- s.add_runtime_dependency "sass", "~> 3.1.1"
23
- s.add_runtime_dependency "liquid", "~> 2.2.2"
24
- s.add_runtime_dependency "bluecloth", "~> 2.1.0"
25
- s.add_runtime_dependency "coffee-script", "~> 2.2.0"
26
- s.add_runtime_dependency "thor", "~> 0.14.6"
18
+ s.add_runtime_dependency "bundler", "~> 1.0.7"
19
+ s.add_runtime_dependency "thor", "~> 0.14.6"
20
+ s.add_runtime_dependency "rack", "~> 1.2.3"
21
+ s.add_runtime_dependency "sinatra", "~> 1.2.6"
22
+ s.add_runtime_dependency "haml", "~> 3.1.1"
23
+ s.add_runtime_dependency "sass", "~> 3.1.1"
24
+ s.add_runtime_dependency "liquid", "~> 2.2.2"
25
+ s.add_runtime_dependency "bluecloth", "~> 2.1.0"
26
+ s.add_runtime_dependency "coffee-script", "~> 2.2.0"
27
+ s.add_runtime_dependency "therubyracer-heroku", "= 0.8.1.pre3"
27
28
 
28
- s.add_development_dependency "rspec", "~> 2.6.0"
29
29
  s.add_development_dependency "rack-test", "~> 0.6.0"
30
+ s.add_development_dependency "rspec", "~> 2.6.0"
30
31
  s.add_development_dependency "yard", "~> 0.7.1"
31
32
  s.add_development_dependency "bluecloth", "~> 2.1.0"
32
33
 
@@ -0,0 +1,5 @@
1
+ ---
2
+ view: articles/page.erb
3
+ ---
4
+
5
+ ### /articles/index.md
@@ -0,0 +1,7 @@
1
+ <h1>Welcome to Mango!</h1>
2
+
3
+ <p id="template">articles/page.erb</p>
4
+
5
+ <div id="content">
6
+ <%= page.content %>
7
+ </div>
@@ -256,6 +256,43 @@ describe Mango::Application do
256
256
 
257
257
  #################################################################################################
258
258
 
259
+ describe "GET /articles/index" do
260
+ before(:all) do
261
+ get "/articles/index"
262
+ end
263
+
264
+ it "returns 200 status code" do
265
+ last_response.should be_ok
266
+ end
267
+
268
+ it "sends the correct Content-Type header" do
269
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
270
+ end
271
+
272
+ it "sends the correct body content" do
273
+ last_response.body.should == <<-EXPECTED
274
+ <!DOCTYPE html>
275
+ <html>
276
+ <head>
277
+ <meta charset='utf-8' />
278
+ <title>layout.erb</title>
279
+ </head>
280
+ <body>
281
+ <h1>Welcome to Mango!</h1>
282
+
283
+ <p id="template">articles/page.erb</p>
284
+
285
+ <div id="content">
286
+ <h3>/articles/index.md</h3>
287
+ </div>
288
+ </body>
289
+ </html>
290
+ EXPECTED
291
+ end
292
+ end
293
+
294
+ #################################################################################################
295
+
259
296
  describe "GET /turner%2Bhooch" do
260
297
  before(:all) do
261
298
  get "/turner%2Bhooch"
@@ -631,4 +668,32 @@ describe Mango::Application do
631
668
  EXPECTED
632
669
  end
633
670
  end
671
+
672
+ #################################################################################################
673
+
674
+ context "given an additional GET route handler to Mango::Application" do
675
+ class Mango::Application
676
+ get "/route/addition" do
677
+ "/route/addition isolated and handled"
678
+ end
679
+ end
680
+
681
+ describe "GET /route/addition" do
682
+ before(:all) do
683
+ get "/route/addition"
684
+ end
685
+
686
+ it "returns 200 status code" do
687
+ last_response.should be_ok
688
+ end
689
+
690
+ it "sends the correct Content-Type header" do
691
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
692
+ end
693
+
694
+ it "sends the correct body content" do
695
+ last_response.body.should == "/route/addition isolated and handled"
696
+ end
697
+ end
698
+ end
634
699
  end
@@ -275,4 +275,32 @@ if (opposite) {
275
275
  EXPECTED
276
276
  end
277
277
  end
278
+
279
+ #################################################################################################
280
+
281
+ context "given an additional GET route handler to Mango::Application" do
282
+ class Mango::Application
283
+ get "/javascripts/addition.js" do
284
+ "/javascripts/addition.js isolated and handled"
285
+ end
286
+ end
287
+
288
+ describe "GET /javascripts/addition.js" do
289
+ before(:all) do
290
+ get "/javascripts/addition.js"
291
+ end
292
+
293
+ it "returns 200 status code" do
294
+ last_response.should be_ok
295
+ end
296
+
297
+ it "sends the correct Content-Type header" do
298
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
299
+ end
300
+
301
+ it "sends the correct body content" do
302
+ last_response.body.should == "/javascripts/addition.js isolated and handled"
303
+ end
304
+ end
305
+ end
278
306
  end
@@ -318,4 +318,32 @@ time, mark, audio, video {
318
318
  EXPECTED
319
319
  end
320
320
  end
321
+
322
+ #################################################################################################
323
+
324
+ context "given an additional GET route handler to Mango::Application" do
325
+ class Mango::Application
326
+ get "/stylesheets/addition.css" do
327
+ "/stylesheets/addition.css isolated and handled"
328
+ end
329
+ end
330
+
331
+ describe "GET /stylesheets/addition.css" do
332
+ before(:all) do
333
+ get "/stylesheets/addition.css"
334
+ end
335
+
336
+ it "returns 200 status code" do
337
+ last_response.should be_ok
338
+ end
339
+
340
+ it "sends the correct Content-Type header" do
341
+ last_response["Content-Type"].should == "text/html;charset=utf-8"
342
+ end
343
+
344
+ it "sends the correct body content" do
345
+ last_response.body.should == "/stylesheets/addition.css isolated and handled"
346
+ end
347
+ end
348
+ end
321
349
  end
@@ -2,11 +2,35 @@
2
2
  require "spec_helper"
3
3
 
4
4
  describe String, "#templatize" do
5
- context "given a file name" do
5
+ context "given a file name with 1 extension" do
6
6
  let(:file_name) { "blog.haml" }
7
7
 
8
8
  it "converts it to a Sinatra-compliant template name" do
9
9
  file_name.templatize.should eq(:blog)
10
10
  end
11
11
  end
12
+
13
+ context "given a nested file name with 1 extension" do
14
+ let(:file_name) { "blog/home.erb" }
15
+
16
+ it "converts it to a Sinatra-compliant template name" do
17
+ file_name.templatize.should eq(:"blog/home")
18
+ end
19
+ end
20
+
21
+ context "given a file name with 2 extensions" do
22
+ let(:file_name) { "page.html.liquid" }
23
+
24
+ it "converts it to a Sinatra-compliant template name" do
25
+ file_name.templatize.should eq(:"page.html")
26
+ end
27
+ end
28
+
29
+ context "given a nested file name with 2 extensions" do
30
+ let(:file_name) { "article/post.html.haml" }
31
+
32
+ it "converts it to a Sinatra-compliant template name" do
33
+ file_name.templatize.should eq(:"article/post.html")
34
+ end
35
+ end
12
36
  end
@@ -9,18 +9,6 @@ describe Mango::Dependencies do
9
9
  it "supports ruby 1.9.2" do
10
10
  Mango::Dependencies::SUPPORTED_RUBY_VERSIONS.should == ["1.9.2"]
11
11
  end
12
-
13
- it "file name to gem name look-up table should be correct" do
14
- expected = {
15
- :"rack/test" => :"rack-test",
16
- :"rspec/core/rake_task" => :"rspec-core",
17
- }
18
- Mango::Dependencies::FILE_NAME_TO_GEM_NAME.should == expected
19
- end
20
-
21
- it "warnings cache should be empty" do
22
- Mango::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
23
- end
24
12
  end
25
13
 
26
14
  #################################################################################################
@@ -77,75 +65,4 @@ http://rvm.beginrescueend.com/
77
65
  }.should_not raise_exception(SystemExit, expected_message(version))
78
66
  end
79
67
  end
80
-
81
- #################################################################################################
82
-
83
- context "given three load errors" do
84
- before(:each) do
85
- ["rspec/core/rake_task", "yard", "bluecloth"].each do |file|
86
- load_error = LoadError.new("no such file to load -- #{file}")
87
- Mango::Dependencies.create_warning_for(load_error)
88
- end
89
- end
90
-
91
- after(:each) do
92
- Mango::Dependencies.destroy_warnings
93
- end
94
-
95
- describe ".destroy_warnings" do
96
- it "empties the warnings cache" do
97
- Mango::Dependencies.class_variable_get(:@@warnings_cache).should_not be_empty
98
- Mango::Dependencies.destroy_warnings
99
- Mango::Dependencies.class_variable_get(:@@warnings_cache).should be_empty
100
- end
101
- end
102
-
103
- ###############################################################################################
104
-
105
- describe ".create_warning_for" do
106
- it "creates and caches three warnings" do
107
- expected = [:"rspec-core", :yard, :bluecloth]
108
- Mango::Dependencies.class_variable_get(:@@warnings_cache).should == expected
109
- end
110
- end
111
-
112
- ###############################################################################################
113
-
114
- describe ".render_warnings" do
115
- before(:each) do
116
- $stdout = StringIO.new
117
- end
118
-
119
- after(:each) do
120
- $stdout = STDOUT
121
- end
122
-
123
- it "displays a warning message to the user on the standard output channel" do
124
- Mango::Dependencies.render_warnings
125
- $stdout.string.should == <<-MESSAGE
126
-
127
- Could not require the following RubyGems: rspec-core, yard, bluecloth
128
- Please run "bundle install" to access all development features.
129
-
130
- MESSAGE
131
- end
132
-
133
- it "doesn't display a warning message to the user if there are no warnings in the cache" do
134
- Mango::Dependencies.destroy_warnings
135
- Mango::Dependencies.render_warnings
136
- $stdout.string.should be_empty
137
- end
138
- end
139
- end
140
-
141
- #################################################################################################
142
-
143
- describe ".warn_at_exit" do
144
- it "ensures Kernel#at_exit is invoked with a block" do
145
- Mango::Dependencies.should_receive(:at_exit)
146
- # TODO how to specify that #at_exit receives a block?
147
- # maybe i can intercept the block, execute it and test the output?
148
- Mango::Dependencies.warn_at_exit
149
- end
150
- end
151
68
  end
@@ -81,7 +81,7 @@ run Mango::Application
81
81
  File.read(expected).should == <<-EOS
82
82
  # encoding: UTF-8
83
83
  source "http://rubygems.org"
84
- gem "mango", "~> 0.6.1"
84
+ gem "mango", "~> 0.6.2"
85
85
  EOS
86
86
  end
87
87
 
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
  describe Mango do
5
5
  describe "version synchronizing" do
6
6
  before(:all) do
7
- @expected = "0.6.1"
7
+ @expected = "0.6.2"
8
8
  end
9
9
 
10
10
  it "is correct for Mango::VERSION" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 6
8
- - 1
9
- version: 0.6.1
8
+ - 2
9
+ version: 0.6.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ryan Sobol
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-29 00:00:00 -07:00
17
+ date: 2011-06-06 00:00:00 -04:00
18
18
  default_executable: mango
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -33,9 +33,24 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: rack
36
+ name: thor
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 0
45
+ - 14
46
+ - 6
47
+ version: 0.14.6
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rack
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
39
54
  none: false
40
55
  requirements:
41
56
  - - ~>
@@ -43,14 +58,14 @@ dependencies:
43
58
  segments:
44
59
  - 1
45
60
  - 2
46
- - 2
47
- version: 1.2.2
61
+ - 3
62
+ version: 1.2.3
48
63
  type: :runtime
49
- version_requirements: *id002
64
+ version_requirements: *id003
50
65
  - !ruby/object:Gem::Dependency
51
66
  name: sinatra
52
67
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
54
69
  none: false
55
70
  requirements:
56
71
  - - ~>
@@ -61,11 +76,11 @@ dependencies:
61
76
  - 6
62
77
  version: 1.2.6
63
78
  type: :runtime
64
- version_requirements: *id003
79
+ version_requirements: *id004
65
80
  - !ruby/object:Gem::Dependency
66
81
  name: haml
67
82
  prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
69
84
  none: false
70
85
  requirements:
71
86
  - - ~>
@@ -76,11 +91,11 @@ dependencies:
76
91
  - 1
77
92
  version: 3.1.1
78
93
  type: :runtime
79
- version_requirements: *id004
94
+ version_requirements: *id005
80
95
  - !ruby/object:Gem::Dependency
81
96
  name: sass
82
97
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
98
+ requirement: &id006 !ruby/object:Gem::Requirement
84
99
  none: false
85
100
  requirements:
86
101
  - - ~>
@@ -91,11 +106,11 @@ dependencies:
91
106
  - 1
92
107
  version: 3.1.1
93
108
  type: :runtime
94
- version_requirements: *id005
109
+ version_requirements: *id006
95
110
  - !ruby/object:Gem::Dependency
96
111
  name: liquid
97
112
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
113
+ requirement: &id007 !ruby/object:Gem::Requirement
99
114
  none: false
100
115
  requirements:
101
116
  - - ~>
@@ -106,11 +121,11 @@ dependencies:
106
121
  - 2
107
122
  version: 2.2.2
108
123
  type: :runtime
109
- version_requirements: *id006
124
+ version_requirements: *id007
110
125
  - !ruby/object:Gem::Dependency
111
126
  name: bluecloth
112
127
  prerelease: false
113
- requirement: &id007 !ruby/object:Gem::Requirement
128
+ requirement: &id008 !ruby/object:Gem::Requirement
114
129
  none: false
115
130
  requirements:
116
131
  - - ~>
@@ -121,11 +136,11 @@ dependencies:
121
136
  - 0
122
137
  version: 2.1.0
123
138
  type: :runtime
124
- version_requirements: *id007
139
+ version_requirements: *id008
125
140
  - !ruby/object:Gem::Dependency
126
141
  name: coffee-script
127
142
  prerelease: false
128
- requirement: &id008 !ruby/object:Gem::Requirement
143
+ requirement: &id009 !ruby/object:Gem::Requirement
129
144
  none: false
130
145
  requirements:
131
146
  - - ~>
@@ -136,56 +151,57 @@ dependencies:
136
151
  - 0
137
152
  version: 2.2.0
138
153
  type: :runtime
139
- version_requirements: *id008
154
+ version_requirements: *id009
140
155
  - !ruby/object:Gem::Dependency
141
- name: thor
156
+ name: therubyracer-heroku
142
157
  prerelease: false
143
- requirement: &id009 !ruby/object:Gem::Requirement
158
+ requirement: &id010 !ruby/object:Gem::Requirement
144
159
  none: false
145
160
  requirements:
146
- - - ~>
161
+ - - "="
147
162
  - !ruby/object:Gem::Version
148
163
  segments:
149
164
  - 0
150
- - 14
151
- - 6
152
- version: 0.14.6
165
+ - 8
166
+ - 1
167
+ - pre3
168
+ version: 0.8.1.pre3
153
169
  type: :runtime
154
- version_requirements: *id009
170
+ version_requirements: *id010
155
171
  - !ruby/object:Gem::Dependency
156
- name: rspec
172
+ name: rack-test
157
173
  prerelease: false
158
- requirement: &id010 !ruby/object:Gem::Requirement
174
+ requirement: &id011 !ruby/object:Gem::Requirement
159
175
  none: false
160
176
  requirements:
161
177
  - - ~>
162
178
  - !ruby/object:Gem::Version
163
179
  segments:
164
- - 2
180
+ - 0
165
181
  - 6
166
182
  - 0
167
- version: 2.6.0
183
+ version: 0.6.0
168
184
  type: :development
169
- version_requirements: *id010
185
+ version_requirements: *id011
170
186
  - !ruby/object:Gem::Dependency
171
- name: rack-test
187
+ name: rspec
172
188
  prerelease: false
173
- requirement: &id011 !ruby/object:Gem::Requirement
189
+ requirement: &id012 !ruby/object:Gem::Requirement
174
190
  none: false
175
191
  requirements:
176
192
  - - ~>
177
193
  - !ruby/object:Gem::Version
178
194
  segments:
179
- - 0
195
+ - 2
180
196
  - 6
181
197
  - 0
182
- version: 0.6.0
198
+ version: 2.6.0
183
199
  type: :development
184
- version_requirements: *id011
200
+ version_requirements: *id012
185
201
  - !ruby/object:Gem::Dependency
186
202
  name: yard
187
203
  prerelease: false
188
- requirement: &id012 !ruby/object:Gem::Requirement
204
+ requirement: &id013 !ruby/object:Gem::Requirement
189
205
  none: false
190
206
  requirements:
191
207
  - - ~>
@@ -196,11 +212,11 @@ dependencies:
196
212
  - 1
197
213
  version: 0.7.1
198
214
  type: :development
199
- version_requirements: *id012
215
+ version_requirements: *id013
200
216
  - !ruby/object:Gem::Dependency
201
217
  name: bluecloth
202
218
  prerelease: false
203
- requirement: &id013 !ruby/object:Gem::Requirement
219
+ requirement: &id014 !ruby/object:Gem::Requirement
204
220
  none: false
205
221
  requirements:
206
222
  - - ~>
@@ -211,7 +227,7 @@ dependencies:
211
227
  - 0
212
228
  version: 2.1.0
213
229
  type: :development
214
- version_requirements: *id013
230
+ version_requirements: *id014
215
231
  description: Mango is a dynamic, database-free, and open source website framework that is designed to make life easier for small teams of designers, developers, and content writers.
216
232
  email: contact@ryansobol.com
217
233
  executables:
@@ -261,6 +277,7 @@ files:
261
277
  - spec/bin/mango_spec.rb
262
278
  - spec/fixture/content/about/index.haml
263
279
  - spec/fixture/content/about/us.haml
280
+ - spec/fixture/content/articles/index.md
264
281
  - spec/fixture/content/engines/erb.erb
265
282
  - spec/fixture/content/engines/haml.haml
266
283
  - spec/fixture/content/engines/liquid.liquid
@@ -301,6 +318,7 @@ files:
301
318
  - spec/fixture/themes/default/views/404.erb
302
319
  - spec/fixture/themes/default/views/404.haml
303
320
  - spec/fixture/themes/default/views/404.liquid
321
+ - spec/fixture/themes/default/views/articles/page.erb
304
322
  - spec/fixture/themes/default/views/layout.erb
305
323
  - spec/fixture/themes/default/views/layout.haml
306
324
  - spec/fixture/themes/default/views/layout.liquid
@@ -365,6 +383,7 @@ test_files:
365
383
  - spec/bin/mango_spec.rb
366
384
  - spec/fixture/content/about/index.haml
367
385
  - spec/fixture/content/about/us.haml
386
+ - spec/fixture/content/articles/index.md
368
387
  - spec/fixture/content/engines/erb.erb
369
388
  - spec/fixture/content/engines/haml.haml
370
389
  - spec/fixture/content/engines/liquid.liquid
@@ -405,6 +424,7 @@ test_files:
405
424
  - spec/fixture/themes/default/views/404.erb
406
425
  - spec/fixture/themes/default/views/404.haml
407
426
  - spec/fixture/themes/default/views/404.liquid
427
+ - spec/fixture/themes/default/views/articles/page.erb
408
428
  - spec/fixture/themes/default/views/layout.erb
409
429
  - spec/fixture/themes/default/views/layout.haml
410
430
  - spec/fixture/themes/default/views/layout.liquid