middleman 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Rakefile +1 -0
  2. data/VERSION +1 -1
  3. data/middleman.gemspec +65 -6
  4. data/pkg/middleman-0.2.1.gem +0 -0
  5. data/rdoc/classes/Middleman.html +164 -0
  6. data/rdoc/created.rid +1 -0
  7. data/rdoc/files/README_rdoc.html +114 -0
  8. data/rdoc/files/lib/middleman_rb.html +111 -0
  9. data/rdoc/fr_class_index.html +27 -0
  10. data/rdoc/fr_file_index.html +28 -0
  11. data/rdoc/fr_method_index.html +27 -0
  12. data/rdoc/index.html +24 -0
  13. data/rdoc/rdoc-style.css +208 -0
  14. data/vendor/rack-test/History.txt +64 -0
  15. data/vendor/rack-test/MIT-LICENSE.txt +19 -0
  16. data/vendor/rack-test/README.rdoc +57 -0
  17. data/vendor/rack-test/Rakefile +62 -0
  18. data/vendor/rack-test/lib/rack/mock_session.rb +57 -0
  19. data/vendor/rack-test/lib/rack/test.rb +246 -0
  20. data/vendor/rack-test/lib/rack/test/cookie_jar.rb +169 -0
  21. data/vendor/rack-test/lib/rack/test/methods.rb +73 -0
  22. data/vendor/rack-test/lib/rack/test/mock_digest_request.rb +27 -0
  23. data/vendor/rack-test/lib/rack/test/uploaded_file.rb +36 -0
  24. data/vendor/rack-test/lib/rack/test/utils.rb +75 -0
  25. data/vendor/rack-test/spec/fixtures/config.ru +3 -0
  26. data/vendor/rack-test/spec/fixtures/fake_app.rb +109 -0
  27. data/vendor/rack-test/spec/fixtures/foo.txt +1 -0
  28. data/vendor/rack-test/spec/rack/test/cookie_spec.rb +176 -0
  29. data/vendor/rack-test/spec/rack/test/digest_auth_spec.rb +48 -0
  30. data/vendor/rack-test/spec/rack/test/multipart_spec.rb +85 -0
  31. data/vendor/rack-test/spec/rack/test/utils_spec.rb +44 -0
  32. data/vendor/rack-test/spec/rack/test_spec.rb +363 -0
  33. data/vendor/rack-test/spec/rcov.opts +1 -0
  34. data/vendor/rack-test/spec/spec.opts +1 -0
  35. data/vendor/rack-test/spec/spec_helper.rb +48 -0
  36. data/vendor/sinatra-markaby/CHANGES +7 -0
  37. data/vendor/sinatra-markaby/LICENSE +20 -0
  38. data/vendor/sinatra-markaby/README.rdoc +33 -0
  39. data/vendor/sinatra-markaby/Rakefile +45 -0
  40. data/vendor/sinatra-markaby/TODO +3 -0
  41. data/vendor/sinatra-markaby/VERSION.yml +4 -0
  42. data/vendor/sinatra-markaby/lib/sinatra/markaby.rb +31 -0
  43. data/vendor/sinatra-markaby/sinatra-markaby.gemspec +49 -0
  44. data/vendor/sinatra-markaby/test/sinatra_markaby_test.rb +72 -0
  45. data/vendor/sinatra-markaby/test/test_helper.rb +19 -0
  46. data/vendor/sinatra-markaby/test/views/hello.mab +1 -0
  47. data/vendor/sinatra-markaby/test/views/html.mab +4 -0
  48. data/vendor/sinatra-maruku/LICENSE +22 -0
  49. data/vendor/sinatra-maruku/README.markdown +85 -0
  50. data/vendor/sinatra-maruku/Rakefile +34 -0
  51. data/vendor/sinatra-maruku/VERSION.yml +4 -0
  52. data/vendor/sinatra-maruku/examples/app.rb +8 -0
  53. data/vendor/sinatra-maruku/examples/config.ru +4 -0
  54. data/vendor/sinatra-maruku/examples/mapp.rb +15 -0
  55. data/vendor/sinatra-maruku/examples/public/javascripts/application.js +0 -0
  56. data/vendor/sinatra-maruku/examples/public/stylesheets/application.css +23 -0
  57. data/vendor/sinatra-maruku/examples/public/stylesheets/print.css +0 -0
  58. data/vendor/sinatra-maruku/examples/views/index.maruku +32 -0
  59. data/vendor/sinatra-maruku/examples/views/layout.maruku +9 -0
  60. data/vendor/sinatra-maruku/lib/sinatra/maruku.rb +25 -0
  61. data/vendor/sinatra-maruku/sinatra-maruku.gemspec +70 -0
  62. data/vendor/sinatra-maruku/test/sinatra_maruku_test.rb +91 -0
  63. data/vendor/sinatra-maruku/test/test_helper.rb +21 -0
  64. data/vendor/sinatra-maruku/test/views/hello.maruku +1 -0
  65. data/vendor/sinatra-maruku/test/views/layout2.maruku +2 -0
  66. metadata +63 -4
  67. data/.document +0 -5
  68. data/.gitignore +0 -6
  69. data/.gitmodules +0 -9
@@ -0,0 +1 @@
1
+ -x gems,spec
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,48 @@
1
+ require "rubygems"
2
+ require "spec"
3
+
4
+ gem "rack", "~> 1.0.0"
5
+
6
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/rack/test")
7
+ require File.dirname(__FILE__) + "/fixtures/fake_app"
8
+
9
+ Spec::Runner.configure do |config|
10
+ config.include Rack::Test::Methods
11
+
12
+ def app
13
+ Rack::Lint.new(Rack::Test::FakeApp.new)
14
+ end
15
+
16
+ end
17
+
18
+ describe "any #verb methods", :shared => true do
19
+ it "requests the URL using VERB" do
20
+ send(verb, "/")
21
+
22
+ last_request.env["REQUEST_METHOD"].should == verb.upcase
23
+ last_response.should be_ok
24
+ end
25
+
26
+ it "uses the provided env" do
27
+ send(verb, "/", {}, { "User-Agent" => "Rack::Test" })
28
+ last_request.env["User-Agent"].should == "Rack::Test"
29
+ end
30
+
31
+ it "yields the response to a given block" do
32
+ yielded = false
33
+
34
+ send(verb, "/") do |response|
35
+ response.should be_ok
36
+ yielded = true
37
+ end
38
+
39
+ yielded.should be_true
40
+ end
41
+
42
+ context "for a XHR" do
43
+ it "sends XMLHttpRequest for the X-Requested-With header" do
44
+ send(verb, "/", {}, { :xhr => true })
45
+ last_request.env["X-Requested-With"].should == "XMLHttpRequest"
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ = 0.9.2.2
2
+
3
+ * layout support is tested
4
+
5
+ = 0.9.2.1
6
+
7
+ * use Rack::Test instead of Sinatra::Test
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 unwwwired.net
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ = sinatra-markaby
2
+
3
+ sinatra-markaby is an extension for sinatra to enable rendering of html files
4
+ using markaby templates.
5
+
6
+ == Installation
7
+
8
+ sudo gem install sbfaulkner-sinatra-markaby -s http://gems.github.com
9
+
10
+ == Example
11
+
12
+ require 'rubygems'
13
+ require 'sinatra'
14
+ require 'sinatra/markaby'
15
+
16
+ get '/' do
17
+ markaby :template
18
+ end
19
+
20
+ __END__
21
+
22
+ @@ template
23
+ mab.html do
24
+ head { title "Hello world" }
25
+ body do
26
+ p "Hello world!!!!!"
27
+ end
28
+ end
29
+
30
+ == Legal
31
+
32
+ Author:: S. Brent Faulkner <brentf@unwwwired.net>
33
+ License:: Copyright (c) 2009 unwwwired.net, released under the MIT license
@@ -0,0 +1,45 @@
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |s|
6
+ s.name = "sinatra-markaby"
7
+ s.summary = %Q{Sinatra plugin to enable markaby (.mab) template rendering.}
8
+ s.email = "brentf@unwwwired.net"
9
+ s.homepage = "http://github.com/sbfaulkner/sinatra-markaby"
10
+ s.description = "Sinatra plugin to enable markaby (.mab) template rendering."
11
+ s.authors = ["S. Brent Faulkner"]
12
+ s.add_dependency "markaby"
13
+ end
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
+ end
17
+
18
+ require 'rake/rdoctask'
19
+ Rake::RDocTask.new do |rdoc|
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = 'sinatra-markaby'
22
+ rdoc.options << '--line-numbers' << '--inline-source'
23
+ rdoc.rdoc_files.include('README*')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
26
+
27
+ require 'rake/testtask'
28
+ Rake::TestTask.new(:test) do |t|
29
+ t.libs << 'lib' << 'test'
30
+ t.pattern = 'test/**/*_test.rb'
31
+ t.verbose = false
32
+ end
33
+
34
+ begin
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |t|
37
+ t.libs << 'test'
38
+ t.test_files = FileList['test/**/*_test.rb']
39
+ t.verbose = true
40
+ end
41
+ rescue LoadError
42
+ puts "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
43
+ end
44
+
45
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ = TODO
2
+
3
+ * refactor render/views in sinatra
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 9
4
+ :patch: 2.2
@@ -0,0 +1,31 @@
1
+ require 'sinatra/base'
2
+ require 'markaby'
3
+
4
+ module Sinatra
5
+ module Markaby
6
+ # Generate html file using Markaby.
7
+ # Takes the name of a template to render as a Symbol and returns a String with the rendered output.
8
+ #
9
+ # Options for markaby may be specified in Sinatra using set :markaby, { ... }
10
+ # TODO: the options aren't actually used yet
11
+ def markaby(template=nil, options={}, locals = {}, &block)
12
+ options, template = template, nil if template.is_a?(Hash)
13
+ template = lambda { block } if template.nil?
14
+ render :mab, template, options, locals
15
+ end
16
+
17
+ protected
18
+ def render_mab(template, data, options, locals, &block)
19
+ filename = options.delete(:filename) || '<MARKABY>'
20
+ line = options.delete(:line) || 1
21
+ mab = ::Markaby::Builder.new(locals)
22
+ if data.respond_to?(:to_str)
23
+ eval(data.to_str, binding, filename, line)
24
+ elsif data.kind_of?(Proc)
25
+ data.call(mab)
26
+ end
27
+ end
28
+ end
29
+
30
+ helpers Markaby
31
+ end
@@ -0,0 +1,49 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{sinatra-markaby}
5
+ s.version = "0.9.2.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["S. Brent Faulkner"]
9
+ s.date = %q{2009-04-29}
10
+ s.description = %q{Sinatra plugin to enable markaby (.mab) template rendering.}
11
+ s.email = %q{brentf@unwwwired.net}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README.rdoc"
15
+ ]
16
+ s.files = [
17
+ "LICENSE",
18
+ "README.rdoc",
19
+ "Rakefile",
20
+ "VERSION.yml",
21
+ "lib/sinatra/markaby.rb",
22
+ "test/sinatra_markaby_test.rb",
23
+ "test/test_helper.rb",
24
+ "test/views/hello.mab"
25
+ ]
26
+ s.has_rdoc = true
27
+ s.homepage = %q{http://github.com/sbfaulkner/sinatra-markaby}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.1}
31
+ s.summary = %q{Sinatra plugin to enable markaby (.mab) template rendering.}
32
+ s.test_files = [
33
+ "test/sinatra_markaby_test.rb",
34
+ "test/test_helper.rb"
35
+ ]
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 2
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_runtime_dependency(%q<markaby>, [">= 0"])
43
+ else
44
+ s.add_dependency(%q<markaby>, [">= 0"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<markaby>, [">= 0"])
48
+ end
49
+ end
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class SinatraMarkabyTest < Test::Unit::TestCase
4
+ def markaby_app(&block)
5
+ mock_app {
6
+ use_in_file_templates!
7
+ helpers Sinatra::Markaby
8
+ set :views, File.dirname(__FILE__) + '/views'
9
+ get '/', &block
10
+ }
11
+ get '/'
12
+ end
13
+
14
+ def test_renders_inline_strings
15
+ markaby_app { markaby 'mab.p "Hello shrimp!"' }
16
+ assert last_response.ok?
17
+ assert_equal '<p>Hello shrimp!</p>', last_response.body
18
+ end
19
+
20
+ def test_renders_inline_blocks
21
+ markaby_app {
22
+ @name = 'Frank & Mary'
23
+ markaby do |mab|
24
+ mab.p "Hello #{@name}!"
25
+ end
26
+ }
27
+ assert last_response.ok?
28
+ assert_equal '<p>Hello Frank &amp; Mary!</p>', last_response.body
29
+ end
30
+
31
+ def test_renders_markaby_files_in_views_path
32
+ markaby_app {
33
+ @name = 'World'
34
+ markaby :hello
35
+ }
36
+ assert last_response.ok?
37
+ assert_equal '<p>Hello, World!</p>', last_response.body
38
+ end
39
+
40
+ def test_renders_in_file_template
41
+ markaby_app {
42
+ @name = 'Joe'
43
+ markaby :in_file
44
+ }
45
+ assert last_response.ok?
46
+ assert_equal '<p>Hey Joe</p>', last_response.body
47
+ end
48
+
49
+ def test_renders_with_layout
50
+ markaby_app {
51
+ @name = 'with Layout'
52
+ markaby :hello, :layout => :html
53
+ }
54
+ assert last_response.ok?
55
+ assert_equal '<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/><title>Hello</title></head><body><p>Hello, with Layout!</p></body></html>', last_response.body
56
+ end
57
+
58
+ def test_raises_error_if_template_not_found
59
+ mock_app {
60
+ helpers Sinatra::Markaby
61
+ set :environment, :test
62
+ set :raise_errors, true
63
+ get('/') { markaby :no_such_template }
64
+ }
65
+ assert_raises(Errno::ENOENT) { get('/') }
66
+ end
67
+ end
68
+
69
+ __END__
70
+
71
+ @@ in_file
72
+ mab.p "Hey #{@name}"
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'rack/test'
4
+
5
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
6
+ require 'sinatra/markaby'
7
+
8
+ class Test::Unit::TestCase
9
+ include Rack::Test::Methods
10
+
11
+ attr_reader :app
12
+
13
+ # Sets up a Sinatra::Base subclass defined with the block
14
+ # given. Used in setup or individual spec methods to establish
15
+ # the application.
16
+ def mock_app(base=Sinatra::Base, &block)
17
+ @app = Sinatra.new(base, &block)
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ mab.p "Hello, #{@name}!"
@@ -0,0 +1,4 @@
1
+ mab.html do
2
+ head { title "Hello" }
3
+ body { yield }
4
+ end
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2008 Wlodek Bzyl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,85 @@
1
+ # Sinatra Maruku Extension
2
+
3
+ The *sinatra-maruku* extension provides `maruku` helper method
4
+ for rendering Maruku templates.
5
+
6
+ To install it, run:
7
+
8
+ sudo gem install wbzyl-sinatra-maruku -s http://gems.github.com
9
+
10
+ To test it, create a simple Sinatra application:
11
+
12
+ # app.rb
13
+ require 'rubygems'
14
+ require 'sinatra'
15
+
16
+ gem 'wbzyl-sinatra-maruku'
17
+ require 'sinatra/maruku'
18
+
19
+ get "/" do
20
+ maruku "# Hello Maruku"
21
+ end
22
+
23
+ and run it with:
24
+
25
+ ruby app.rb
26
+
27
+ The result could be seen at *http://localhost:4567*.
28
+
29
+ Another example could be find in the *examples* directory.
30
+ Run it with:
31
+
32
+ rackup -p 4567 config.ru
33
+
34
+ and visit *http://localhost:4567* to contemplate the sheer
35
+ beauty of rendered text written in Maruku notation.
36
+
37
+
38
+ ## Two links to Maruku related material
39
+
40
+ * [Maruku features](http://maruku.rubyforge.org/maruku.html)
41
+ * [Literate Maruku](http://www.slideshare.net/schmidt/literate-maruku)
42
+
43
+
44
+ ## Template Languages (*update to The Sinatra Book*)
45
+
46
+ ### Maruku Templates
47
+
48
+ This helper method:
49
+
50
+ get '/' do
51
+ maruku :index
52
+ end
53
+
54
+ renders template *./views/index.maruku*.
55
+
56
+ If a layout named *layout.maruku* exists, it will be used each time
57
+ a template is rendered.
58
+
59
+ You can disable layouts by passing `:layout => false`
60
+ to *maruku* helper. For example
61
+
62
+ get '/' do
63
+ maruku :index, :layout => false
64
+ end
65
+
66
+ You can set a different layout from the default one with:
67
+
68
+ get '/' do
69
+ maruku :index, :layout => :application
70
+ end
71
+
72
+ This renders *./views/index.maruku* template
73
+ within *./views/application.maruku* layout.
74
+
75
+
76
+ ## Sample layout for Maruku templates
77
+
78
+ CSS: /stylesheets/application.css /stylesheets/print.css
79
+ Lang: pl
80
+ Title: Hello Maruku
81
+ LaTeX preamble: preamble.tex
82
+
83
+ # Hello Maruku {.header}
84
+
85
+ <%= yield %>