rack-indifferent 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4c481dbbe8d6de8bbaede50165f6c9ce34d10a91
4
+ data.tar.gz: 43a868b0b34f4475aa3de517227680bdc3026582
5
+ SHA512:
6
+ metadata.gz: 69eca9378656660ea3a18f8f07cb4e0281f44d91bb78a51b800609dca18cbbeab4921979206821c3e04cb29ea458d0069c4cca6bdeb4a88db60c734b5f84112b
7
+ data.tar.gz: 8733c5ac401ceef069dc9870c3f23ce2bb4a73ef38191df500a7d5bb7807ba8327c6ce4fe581d9a77481536b17fa2f8178218464e45aa9c60f3a7b856d128d29
@@ -0,0 +1,3 @@
1
+ = 1.0.0 (2015-03-08)
2
+
3
+ * Initial public release
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Jeremy Evans
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,31 @@
1
+ = rack-indifferent
2
+
3
+ rack-indifferent monkey patches Rack::Utils::KeySpaceConstrainedParams
4
+ to make the hash it stores params in support indifferent access. So web
5
+ frameworks that use rack-indifferent don't have to make a deep copy
6
+ of the params to allow indifferent access to the params.
7
+
8
+ == Installation
9
+
10
+ gem install rack-indifferent
11
+
12
+ == Source Code
13
+
14
+ Source code is available on GitHub at https://github.com/jeremyevans/rack-indifferent
15
+
16
+ == Basic Usage
17
+
18
+ Since this just monkey patches part of Rack::Utils, you just need to require
19
+ the library:
20
+
21
+ require 'rack/indifferent'
22
+
23
+ This will change the params hashes that rack uses to use indifferent access.
24
+
25
+ == License
26
+
27
+ MIT
28
+
29
+ == Maintainer
30
+
31
+ Jeremy Evans <code@jeremyevans.net>
@@ -0,0 +1,41 @@
1
+ require "rake"
2
+ require "rake/clean"
3
+
4
+ CLEAN.include ["rack-indifferent-*.gem"]
5
+
6
+ desc "Build rack-indifferent gem"
7
+ task :package=>[:clean] do |p|
8
+ sh %{#{FileUtils::RUBY} -S gem build rack-indifferent.gemspec}
9
+ end
10
+
11
+ ### Specs
12
+
13
+ begin
14
+ begin
15
+ # RSpec 1
16
+ require "spec/rake/spectask"
17
+ spec_class = Spec::Rake::SpecTask
18
+ spec_files_meth = :spec_files=
19
+ rescue LoadError
20
+ # RSpec 2
21
+ require "rspec/core/rake_task"
22
+ spec_class = RSpec::Core::RakeTask
23
+ spec_files_meth = :pattern=
24
+ end
25
+
26
+ spec = lambda do |name, files, d|
27
+ lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
28
+ ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
29
+ desc d
30
+ spec_class.new(name) do |t|
31
+ t.send(spec_files_meth, files)
32
+ end
33
+ end
34
+
35
+ task :default => [:spec]
36
+ spec.call("spec", Dir["spec/*_spec.rb"], "Run specs")
37
+ rescue LoadError
38
+ task :default do
39
+ puts "Must install rspec to run the default task (which runs specs)"
40
+ end
41
+ end
@@ -0,0 +1,10 @@
1
+ require 'rack/utils'
2
+
3
+ class Rack::Utils::KeySpaceConstrainedParams
4
+ def initialize(limit = Rack::Utils.key_space_limit)
5
+ @limit = limit
6
+ @size = 0
7
+ @params = Hash.new{|h,k| h[k.to_s] if k.is_a?(Symbol)}
8
+ end
9
+ end
10
+
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), '../lib/rack/indifferent')
2
+ require 'rack/mock'
3
+
4
+ if defined?(RSpec)
5
+ require 'rspec/version'
6
+ if RSpec::Version::STRING >= '2.11.0'
7
+ RSpec.configure do |config|
8
+ config.expect_with :rspec do |c|
9
+ c.syntax = :should
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ describe 'rack-indifferent' do
16
+ it "should make requests use indifferent param hashes" do
17
+ params = Rack::Request.new(Rack::MockRequest.env_for('/?a=b&c[d]=e&f[][g]=h', :input=>'i=j&k[l]=m&n[][o]=p', :method=>'POST')).params
18
+ params[:a].should == 'b'
19
+ params[:c][:d].should == 'e'
20
+ params[:f][0][:g].should == 'h'
21
+ params[:i].should == 'j'
22
+ params[:k][:l].should == 'm'
23
+ params[:n][0][:o].should == 'p'
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-indifferent
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeremy Evans
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ description: |
42
+ rack-indifferent monkey patches Rack::Utils::KeySpaceConstrainedParams
43
+ to make the hash it stores params in support indifferent access. So web
44
+ frameworks that use rack-indifferent don't have to make a deep copy
45
+ of the params to allow indifferent access to the params.
46
+ email: code@jeremyevans.net
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files:
50
+ - README.rdoc
51
+ - CHANGELOG
52
+ - MIT-LICENSE
53
+ files:
54
+ - CHANGELOG
55
+ - MIT-LICENSE
56
+ - README.rdoc
57
+ - Rakefile
58
+ - lib/rack/indifferent.rb
59
+ - spec/indifferent_spec.rb
60
+ homepage: http://github.com/jeremyevans/rack-indifferent
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options:
66
+ - "--quiet"
67
+ - "--line-numbers"
68
+ - "--inline-source"
69
+ - "--title"
70
+ - 'rack-indifferent: Fast indifferent access to request params'
71
+ - "--main"
72
+ - README.rdoc
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.8.7
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.5
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Fast indifferent access to request params
91
+ test_files: []