middleman 0.2.1 → 0.2.2

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 (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,73 @@
1
+ require "forwardable"
2
+
3
+ module Rack
4
+ module Test
5
+ module Methods
6
+ extend Forwardable
7
+
8
+ def rack_mock_session(name = :default)
9
+ return build_rack_mock_session unless name
10
+
11
+ @_rack_mock_sessions ||= {}
12
+ @_rack_mock_sessions[name] ||= build_rack_mock_session
13
+ end
14
+
15
+ def build_rack_mock_session
16
+ Rack::MockSession.new(app)
17
+ end
18
+
19
+ def rack_test_session(name = :default)
20
+ return build_rack_test_session(name) unless name
21
+
22
+ @_rack_test_sessions ||= {}
23
+ @_rack_test_sessions[name] ||= build_rack_test_session(name)
24
+ end
25
+
26
+ def build_rack_test_session(name)
27
+ Rack::Test::Session.new(rack_mock_session(name))
28
+ end
29
+
30
+ def current_session
31
+ rack_test_session(_current_session_names.last)
32
+ end
33
+
34
+ def with_session(name)
35
+ _current_session_names.push(name)
36
+ yield rack_test_session(name)
37
+ _current_session_names.pop
38
+ end
39
+
40
+ def _current_session_names
41
+ @_current_session_names ||= [:default]
42
+ end
43
+
44
+ METHODS = [
45
+ :request,
46
+
47
+ # HTTP verbs
48
+ :get,
49
+ :post,
50
+ :put,
51
+ :delete,
52
+ :head,
53
+
54
+ # Redirects
55
+ :follow_redirect!,
56
+
57
+ # Header-related features
58
+ :header,
59
+ :set_cookie,
60
+ :clear_cookies,
61
+ :authorize,
62
+ :basic_authorize,
63
+ :digest_authorize,
64
+
65
+ # Expose the last request and response
66
+ :last_response,
67
+ :last_request
68
+ ]
69
+
70
+ def_delegators :current_session, *METHODS
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,27 @@
1
+ module Rack
2
+ module Test
3
+
4
+ class MockDigestRequest
5
+ def initialize(params)
6
+ @params = params
7
+ end
8
+
9
+ def method_missing(sym)
10
+ if @params.has_key? k = sym.to_s
11
+ return @params[k]
12
+ end
13
+
14
+ super
15
+ end
16
+
17
+ def method
18
+ @params['method']
19
+ end
20
+
21
+ def response(password)
22
+ Rack::Auth::Digest::MD5.new(nil).send :digest, self, password
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ require "tempfile"
2
+
3
+ module Rack
4
+ module Test
5
+
6
+ class UploadedFile
7
+ # The filename, *not* including the path, of the "uploaded" file
8
+ attr_reader :original_filename
9
+
10
+ # The content type of the "uploaded" file
11
+ attr_accessor :content_type
12
+
13
+ def initialize(path, content_type = "text/plain", binary = false)
14
+ raise "#{path} file does not exist" unless ::File.exist?(path)
15
+ @content_type = content_type
16
+ @original_filename = ::File.basename(path)
17
+ @tempfile = Tempfile.new(@original_filename)
18
+ @tempfile.set_encoding(Encoding::BINARY) if @tempfile.respond_to?(:set_encoding)
19
+ @tempfile.binmode if binary
20
+ FileUtils.copy_file(path, @tempfile.path)
21
+ end
22
+
23
+ def path
24
+ @tempfile.path
25
+ end
26
+
27
+ alias_method :local_path, :path
28
+
29
+ def method_missing(method_name, *args, &block) #:nodoc:
30
+ @tempfile.__send__(method_name, *args, &block)
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,75 @@
1
+ module Rack
2
+ module Test
3
+
4
+ module Utils
5
+ include Rack::Utils
6
+
7
+ def requestify(value, prefix = nil)
8
+ case value
9
+ when Array
10
+ value.map do |v|
11
+ requestify(v, "#{prefix}[]")
12
+ end.join("&")
13
+ when Hash
14
+ value.map do |k, v|
15
+ requestify(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k))
16
+ end.join("&")
17
+ else
18
+ "#{prefix}=#{escape(value)}"
19
+ end
20
+ end
21
+
22
+ module_function :requestify
23
+
24
+ def multipart_requestify(params, first=true)
25
+ p = Hash.new
26
+
27
+ params.each do |key, value|
28
+ k = first ? key.to_s : "[#{key}]"
29
+
30
+ if Hash === value
31
+ multipart_requestify(value, false).each do |subkey, subvalue|
32
+ p[k + subkey] = subvalue
33
+ end
34
+ else
35
+ p[k] = value
36
+ end
37
+ end
38
+
39
+ return p
40
+ end
41
+
42
+ module_function :multipart_requestify
43
+
44
+ def multipart_body(params)
45
+ multipart_requestify(params).map do |key, value|
46
+ if value.respond_to?(:original_filename)
47
+ ::File.open(value.path, "rb") do |f|
48
+ f.set_encoding(Encoding::BINARY) if f.respond_to?(:set_encoding)
49
+
50
+ <<-EOF
51
+ --#{MULTIPART_BOUNDARY}\r
52
+ Content-Disposition: form-data; name="#{key}"; filename="#{escape(value.original_filename)}"\r
53
+ Content-Type: #{value.content_type}\r
54
+ Content-Length: #{::File.stat(value.path).size}\r
55
+ \r
56
+ #{f.read}\r
57
+ EOF
58
+ end
59
+ else
60
+ <<-EOF
61
+ --#{MULTIPART_BOUNDARY}\r
62
+ Content-Disposition: form-data; name="#{key}"\r
63
+ \r
64
+ #{value}\r
65
+ EOF
66
+ end
67
+ end.join("")+"--#{MULTIPART_BOUNDARY}--\r"
68
+ end
69
+
70
+ module_function :multipart_body
71
+
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ require "fake_app"
2
+
3
+ run Rack::Test::FakeApp
@@ -0,0 +1,109 @@
1
+ require "sinatra/base"
2
+
3
+ module Rack
4
+ module Test
5
+
6
+ class FakeApp < Sinatra::Default
7
+ head "/" do
8
+ "meh"
9
+ end
10
+
11
+ get "/" do
12
+ "Hello, GET: #{params.inspect}"
13
+ end
14
+
15
+ get "/redirect" do
16
+ redirect "/redirected"
17
+ end
18
+
19
+ get "/redirected" do
20
+ "You've been redirected"
21
+ end
22
+
23
+ get "/void" do
24
+ [200, {}, ""]
25
+ end
26
+
27
+ get "/cookies/show" do
28
+ request.cookies.inspect
29
+ end
30
+
31
+ get "/COOKIES/show" do
32
+ request.cookies.inspect
33
+ end
34
+
35
+ get "/not-cookies/show" do
36
+ request.cookies.inspect
37
+ end
38
+
39
+ get "/cookies/set-secure" do
40
+ raise if params["value"].nil?
41
+
42
+ response.set_cookie("secure-cookie", :value => params["value"], :secure => true)
43
+ "Set"
44
+ end
45
+
46
+ get "/cookies/set-simple" do
47
+ raise if params["value"].nil?
48
+
49
+ response.set_cookie "simple", params["value"]
50
+ "Set"
51
+ end
52
+
53
+ get "/cookies/delete" do
54
+ response.delete_cookie "value"
55
+ end
56
+
57
+ get "/cookies/count" do
58
+ old_value = request.cookies["count"].to_i || 0
59
+ new_value = (old_value + 1).to_s
60
+
61
+ response.set_cookie("count", :value => new_value)
62
+ new_value
63
+ end
64
+
65
+ get "/cookies/set" do
66
+ raise if params["value"].nil?
67
+
68
+ response.set_cookie("value", {
69
+ :value => params["value"],
70
+ :path => "/cookies",
71
+ :expires => Time.now + 10
72
+ })
73
+ "Set"
74
+ end
75
+
76
+ get "/cookies/domain" do
77
+ old_value = request.cookies["count"].to_i || 0
78
+ new_value = (old_value + 1).to_s
79
+
80
+ response.set_cookie("count", :value => new_value, :domain => "localhost.com")
81
+ new_value
82
+ end
83
+
84
+ get "/cookies/set-uppercase" do
85
+ raise if params["value"].nil?
86
+
87
+ response.set_cookie("VALUE", {
88
+ :value => params["value"],
89
+ :path => "/cookies",
90
+ :expires => Time.now + 10
91
+ })
92
+ "Set"
93
+ end
94
+
95
+ post "/" do
96
+ "Hello, POST: #{params.inspect}"
97
+ end
98
+
99
+ put "/" do
100
+ "Hello, PUT: #{params.inspect}"
101
+ end
102
+
103
+ delete "/" do
104
+ "Hello, DELETE: #{params.inspect}"
105
+ end
106
+ end
107
+
108
+ end
109
+ end
@@ -0,0 +1 @@
1
+ bar
@@ -0,0 +1,176 @@
1
+ require File.dirname(__FILE__) + "/../../spec_helper"
2
+
3
+ describe Rack::Test::Session do
4
+ def have_body(string)
5
+ simple_matcher "have body #{string.inspect}" do |response|
6
+ response.body.should == string
7
+ end
8
+ end
9
+
10
+ context "cookies" do
11
+ it "keeps a cookie jar" do
12
+ get "/cookies/show"
13
+ last_request.cookies.should == {}
14
+
15
+ get "/cookies/set", "value" => "1"
16
+ get "/cookies/show"
17
+ last_request.cookies.should == { "value" => "1" }
18
+ end
19
+
20
+ it "doesn't send expired cookies" do
21
+ get "/cookies/set", "value" => "1"
22
+ now = Time.now
23
+ Time.stub!(:now => now + 60)
24
+ get "/cookies/show"
25
+ last_request.cookies.should == {}
26
+ end
27
+
28
+ it "doesn't send cookies with the wrong domain" do
29
+ get "http://www.example.com/cookies/set", "value" => "1"
30
+ get "http://www.other.example/cookies/show"
31
+ last_request.cookies.should == {}
32
+ end
33
+
34
+ it "doesn't send cookies with the wrong path" do
35
+ get "/cookies/set", "value" => "1"
36
+ get "/not-cookies/show"
37
+ last_request.cookies.should == {}
38
+ end
39
+
40
+ it "persists cookies across requests that don't return any cookie headers" do
41
+ get "/cookies/set", "value" => "1"
42
+ get "/void"
43
+ get "/cookies/show"
44
+ last_request.cookies.should == { "value" => "1" }
45
+ end
46
+
47
+ it "deletes cookies" do
48
+ get "/cookies/set", "value" => "1"
49
+ get "/cookies/delete"
50
+ get "/cookies/show"
51
+ last_request.cookies.should == { }
52
+ end
53
+
54
+ xit "respects cookie domains when no domain is explicitly set" do
55
+ request("http://example.org/cookies/count").should have_body("1")
56
+ request("http://www.example.org/cookies/count").should have_body("1")
57
+ request("http://example.org/cookies/count").should have_body("2")
58
+ request("http://www.example.org/cookies/count").should have_body("2")
59
+ end
60
+
61
+ it "treats domains case insensitively" do
62
+ get "http://example.com/cookies/set", "value" => "1"
63
+ get "http://EXAMPLE.COM/cookies/show"
64
+ last_request.cookies.should == { "value" => "1" }
65
+ end
66
+
67
+ it "treats paths case sensitively" do
68
+ get "/cookies/set", "value" => "1"
69
+ get "/COOKIES/show"
70
+ last_request.cookies.should == {}
71
+ end
72
+
73
+ it "prefers more specific cookies" do
74
+ get "http://example.com/cookies/set", "value" => "domain"
75
+ get "http://sub.example.com/cookies/set", "value" => "sub"
76
+
77
+ get "http://sub.example.com/cookies/show"
78
+ last_request.cookies.should == { "value" => "sub" }
79
+
80
+ get "http://example.com/cookies/show"
81
+ last_request.cookies.should == { "value" => "domain" }
82
+ end
83
+
84
+ it "treats cookie names case insensitively" do
85
+ get "/cookies/set", "value" => "lowercase"
86
+ get "/cookies/set-uppercase", "value" => "UPPERCASE"
87
+ get "/cookies/show"
88
+ last_request.cookies.should == { "VALUE" => "UPPERCASE" }
89
+ end
90
+
91
+ it "defaults the domain to the request domain" do
92
+ get "http://example.com/cookies/set-simple", "value" => "cookie"
93
+ get "http://example.com/cookies/show"
94
+ last_request.cookies.should == { "simple" => "cookie" }
95
+
96
+ get "http://other.example/cookies/show"
97
+ last_request.cookies.should == {}
98
+ end
99
+
100
+ it "defaults the domain to the request path up to the last slash" do
101
+ get "/cookies/set-simple", "value" => "1"
102
+ get "/not-cookies/show"
103
+ last_request.cookies.should == {}
104
+ end
105
+
106
+ it "supports secure cookies" do
107
+ get "https://example.com/cookies/set-secure", "value" => "set"
108
+ get "http://example.com/cookies/show"
109
+ last_request.cookies.should == {}
110
+
111
+ get "https://example.com/cookies/show"
112
+ last_request.cookies.should == { "secure-cookie" => "set" }
113
+ end
114
+
115
+ it "keeps separate cookie jars for different domains" do
116
+ get "http://example.com/cookies/set", "value" => "example"
117
+ get "http://example.com/cookies/show"
118
+ last_request.cookies.should == { "value" => "example" }
119
+
120
+ get "http://other.example/cookies/set", "value" => "other"
121
+ get "http://other.example/cookies/show"
122
+ last_request.cookies.should == { "value" => "other" }
123
+
124
+ get "http://example.com/cookies/show"
125
+ last_request.cookies.should == { "value" => "example" }
126
+ end
127
+
128
+ it "allows cookies to be cleared" do
129
+ get "/cookies/set", "value" => "1"
130
+ clear_cookies
131
+ get "/cookies/show"
132
+ last_request.cookies.should == {}
133
+ end
134
+
135
+ it "allow cookies to be set" do
136
+ set_cookie "value=10"
137
+ get "/cookies/show"
138
+ last_request.cookies.should == { "value" => "10" }
139
+ end
140
+
141
+ it "allows an array of cookies to be set" do
142
+ set_cookie ["value=10", "foo=bar"]
143
+ get "/cookies/show"
144
+ last_request.cookies.should == { "value" => "10", "foo" => "bar" }
145
+ end
146
+
147
+ it "supports multiple sessions" do
148
+ with_session(:first) do
149
+ get "/cookies/set", "value" => "1"
150
+ get "/cookies/show"
151
+ last_request.cookies.should == { "value" => "1" }
152
+ end
153
+
154
+ with_session(:second) do
155
+ get "/cookies/show"
156
+ last_request.cookies.should == { }
157
+ end
158
+ end
159
+
160
+ it "uses :default as the default session name" do
161
+ get "/cookies/set", "value" => "1"
162
+ get "/cookies/show"
163
+ last_request.cookies.should == { "value" => "1" }
164
+
165
+ with_session(:default) do
166
+ get "/cookies/show"
167
+ last_request.cookies.should == { "value" => "1" }
168
+ end
169
+ end
170
+
171
+ it "accepts explicitly provided cookies" do
172
+ request "/cookies/show", :cookie => "value=1"
173
+ last_request.cookies.should == { "value" => "1" }
174
+ end
175
+ end
176
+ end