rack-matrix_params 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf4767e00aeb1b82b4766eadd9e55877ac32ccfb
4
- data.tar.gz: 50baaa283087567bc6bbe6fb42be87614283b0a4
3
+ metadata.gz: 20bad64eab7a65961c94cde25cc42c5834f85e85
4
+ data.tar.gz: b9798e1f98451c91b363e19c24648b94ef32e340
5
5
  SHA512:
6
- metadata.gz: f469b5878fbd399e25b4821b4c53cb0bbc34e89a33aa061bfe0d1b57423aa9296e532616a693552c405762bef9212c65ad10cccbb41b2e992e1dbdd72d4f52c1
7
- data.tar.gz: ad821c24001e2a3306b34eafa0c955063b35fe6111825bf31cc693dc228fd9e2de15ef9ef4e5362e563257d815705189e6579e04450d64b24a5bc70e7c7a7df5
6
+ metadata.gz: bb4c1c2e0b589b965ff997f5680ed60d175956d98c99399fb58e533deac4ad9161f19d8734e42eabad1a74f517eb56e575d0db81c0da5e668ad10352c47dad95
7
+ data.tar.gz: f85eaba14a3ec7e051612090f87a07100006bc2be72f97464f1ce844b99a570247d93ff5b777451588c4ea2ace30fcfc83f8f879a9eb2822b39843f1de61aaff
data/TODO CHANGED
@@ -1 +1 @@
1
- * Look at the POST section - something'sweird there!
1
+ * Look at the POST section - something's weird there!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -0,0 +1,11 @@
1
+ Feature: Provides matrix URL parameters as if they were given as GET parameters to Rack applications
2
+ As a developer on the rack platform
3
+ I want my application to be able to comprehend [matrix parameter][1] style URLs
4
+ So that I can ensure these parameters are considered when older WWW servers are caching HTTP requests
5
+
6
+ Scenario: Matrix parameters are present in the query parameters environment variable
7
+ When I make a GET request of "/normal/path/with/params;a=1;b=2/in;c=3/the/middle"
8
+ Then Rack's "PATH_INFO" environment variable is "/normal/path/with/params/in/the/middle"
9
+ And Rack's "QUERY_STRING" environment variable is "params[a]=1&params[b]=2&in[c]=3"
10
+
11
+ # [1]: http://www.w3.org/DesignIssues/MatrixURIs.html "Time Berners-Lee's original description of Matrix URIs"
@@ -0,0 +1,7 @@
1
+ When(/^I make a GET request of "(.+)"$/) do |url|
2
+ get url
3
+ end
4
+
5
+ Then(/^Rack's "([^\"]+)" environment variable is "(.+)"$/) do |key, value|
6
+ last_request.env[key].should == value
7
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
+ require 'rack/matrix_params'
3
+ require 'rack/test'
4
+
5
+ module AppMixin
6
+ include Rack::Test::Methods
7
+ def app
8
+ app = Rack::MatrixParams.new(lambda do |env|
9
+ [200, {'Content-Type' => 'text/plain'}, ['All good!'] ]
10
+ end)
11
+ end
12
+ end
13
+
14
+ World(AppMixin)
@@ -70,14 +70,14 @@ module Rack
70
70
  if env['REQUEST_METHOD'] != 'POST'
71
71
 
72
72
  # Rewrite current path and query string and strip all query params from it
73
- env['PATH_INFO'].gsub!(/;([^\/]*)/, '').gsub(/\?(.*)$/, '')
73
+ env['PATH_INFO'] = env['PATH_INFO'].gsub(/;([^\/]*)/, '').gsub(/\?(.*)$/, '')
74
74
 
75
- env['QUERY_STRING'].gsub!(/;([^\/]*)/, '').freeze
75
+ env['QUERY_STRING'] = env['QUERY_STRING'].gsub(/;([^\/]*)/, '').freeze
76
76
 
77
77
  new_params = matrix_params.collect do |component, params|
78
78
  params.collect do |k,v|
79
79
  "#{component}[#{k}]=#{CGI::escape(v.to_s)}"
80
- end
80
+ end.reverse
81
81
  end.flatten
82
82
 
83
83
  # Add matrix params as a regular GET params
@@ -24,4 +24,6 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency 'bundler'
25
25
  gem.add_development_dependency 'rack-test'
26
26
  gem.add_development_dependency 'yarjuf'
27
+
28
+ gem.add_development_dependency 'cucumber'
27
29
  end
@@ -4,10 +4,10 @@ describe Rack::MatrixParams do
4
4
  include Rack::Test::Methods
5
5
 
6
6
  let(:inner_app) do
7
- lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All good!'] ]}
8
- end
9
-
10
- let(:app) { described_class.new(inner_app) }
7
+ lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['All good!'] ]}
8
+ end
9
+
10
+ let(:app) { described_class.new(inner_app) }
11
11
 
12
12
  it 'should not change a normal GET query' do
13
13
  get "/?key=value"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-matrix_params
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Hastings-Spital
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-08 00:00:00.000000000 Z
12
+ date: 2013-09-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -95,6 +95,20 @@ dependencies:
95
95
  - - '>='
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: cucumber
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
98
112
  description: Rack middleware that populates the params variable with the contents
99
113
  of matrix parameters in a URL
100
114
  email:
@@ -112,6 +126,9 @@ files:
112
126
  - Rakefile
113
127
  - TODO
114
128
  - VERSION
129
+ - features/provides_matrix_parameters_like_query_parameters_for_rack.feature
130
+ - features/step_definitions/web_requests_steps.rb
131
+ - features/support/env.rb
115
132
  - lib/rack/matrix_params.rb
116
133
  - rack-matrix_params.gemspec
117
134
  - spec/matrix_params_spec.rb
@@ -141,5 +158,9 @@ signing_key:
141
158
  specification_version: 4
142
159
  summary: Allows the use of matrix URLs in a Rack environment
143
160
  test_files:
161
+ - features/provides_matrix_parameters_like_query_parameters_for_rack.feature
162
+ - features/step_definitions/web_requests_steps.rb
163
+ - features/support/env.rb
144
164
  - spec/matrix_params_spec.rb
145
165
  - spec/spec_helper.rb
166
+ has_rdoc: