rack-config_env 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 09c6c6d60cd69126d8bd056e04375bef7b5e0670
4
+ data.tar.gz: ea516579d7495ab9e9d1a66bc9d494a6b5b48fa2
5
+ SHA512:
6
+ metadata.gz: a1e1eb04e1a63a75db0b974af36496f39a244a5dcc4ec84002209b40a35683e409e5fd2a6446e47a7c8584a5f33e0fbec59d060d0ee8de80cacdf290a8b880d5
7
+ data.tar.gz: 4a1cbec295e891ed62ffeef486dd5d474edb6fa2e30c1f253f631770a640d52c94bad5149d73829d0f6fa00769671ff72c6647a920a540eacabb071c209fc18a
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .ruby-version
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1
5
+ gemfile:
6
+ - Gemfile
@@ -0,0 +1,3 @@
1
+ ## 0.0.1
2
+
3
+ First version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem 'coveralls', :require => false
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Naotoshi Seo
2
+
3
+ MIT License
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
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # rack-config_env
2
+
3
+ [![Build Status](https://secure.travis-ci.org/sonots/rack-config_env.png?branch=master)](http://travis-ci.org/sonots/rack-config_env)
4
+ [![Coverage Status](https://coveralls.io/repos/sonots/rack-config_env/badge.png?branch=master)](https://coveralls.io/r/sonots/rack-config_env?branch=master)
5
+
6
+ A rack middleware to configure rack env
7
+
8
+ ## Installation
9
+
10
+ Add the following to your `Gemfile`:
11
+
12
+ ```ruby
13
+ gem 'rack-config_env'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ ```plain
19
+ $ bundle
20
+ ```
21
+
22
+ ## How to Use
23
+
24
+ This gem provides a rack middleware `Rack::ConfigEnv` which enables to configure rack's env.
25
+
26
+ ### Rails
27
+
28
+ ```ruby
29
+ # config/application.rb
30
+ require 'logger'
31
+ require 'rack-config_env'
32
+
33
+ class Application < Rails::Application
34
+ config.autoload_paths += %W(#{config.root}/lib)
35
+ config.middleware.insert_after(0, Rack::ConfigEnv, { 'action_dispatch.logger' => Logger.new(STDOUT) })
36
+ end
37
+ ```
38
+
39
+ Middleware check.
40
+
41
+ ```bash
42
+ bundle exec rake middleware
43
+ ```
44
+
45
+ ### Sinatra
46
+
47
+ ```ruby
48
+ # config.ru
49
+ require 'rack-config_env'
50
+
51
+ use Rack::ConfigEnv, { 'rack.errors' => STDERR }
52
+ run App
53
+ ```
54
+
55
+ ## ChangeLog
56
+
57
+ See [CHANGELOG.md](CHANGELOG.md) for details.
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new [Pull Request](../../pull/new/master)
66
+
67
+ ## Copyright
68
+
69
+ Copyright (c) 2014 Naotoshi Seo. See [LICENSE.txt](LICENSE.txt) for details.
@@ -0,0 +1,14 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec) do |spec|
6
+ spec.pattern = FileList['spec/**/*_spec.rb']
7
+ end
8
+ task :default => :spec
9
+
10
+ desc 'Open an irb session preloaded with the gem library'
11
+ task :console do
12
+ sh 'irb -rubygems -I lib'
13
+ end
14
+ task :c => :console
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'sinatra'
4
+ gem 'rack-config_env', path: '../..'
5
+ gem 'pry'
6
+ gem 'pry-nav'
@@ -0,0 +1,7 @@
1
+ require 'sinatra/base'
2
+
3
+ class App < Sinatra::Base
4
+ get '/' do
5
+ logger.info "OK"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'logger'
2
+ require 'rack-config_env'
3
+ require_relative 'app'
4
+
5
+ logger = ::Logger.new(STDOUT)
6
+ def logger.write(msg)
7
+ self.info msg.chomp!
8
+ end
9
+
10
+ use Rack::ConfigEnv, 'rack.errors' => logger
11
+ use Rack::CommonLogger
12
+ run App
@@ -0,0 +1 @@
1
+ require 'rack/config_env'
@@ -0,0 +1,13 @@
1
+ module Rack
2
+ class ConfigEnv
3
+ def initialize(app, opts = {})
4
+ @app = app
5
+ @opts = opts
6
+ end
7
+
8
+ def call(env)
9
+ env.merge!(@opts)
10
+ @app.call(env)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rack-config_env"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Naotoshi Seo"]
9
+ spec.email = ["sonots@gmail.com"]
10
+ spec.summary = %q{A rack middleware to configure rack env}
11
+ spec.description = %q{A rack middleware to configure rack env.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency "rack"
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "pry-nav"
27
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'spec_helper'
2
+ require 'rack/mock'
3
+ require 'logger'
4
+
5
+ describe Rack::ConfigEnv do
6
+ app = lambda { |env|
7
+ [200, {'Content-Type' => 'text/plain'}, ["Hello, World!"]]
8
+ }
9
+
10
+ context 'conform to Rack::Lint' do
11
+ subject do
12
+ @env = { 'rack.logger' => Logger.new(STDOUT) }
13
+ Rack::Lint.new( Rack::ConfigEnv.new(app, @env) )
14
+ end
15
+
16
+ it 'GET /get' do
17
+ Rack::MockRequest.new(subject).get('/get')
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler.setup(:default, :test)
3
+ Bundler.require(:default, :test)
4
+
5
+ $TESTING=true
6
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib/rack/')
7
+ require 'rack-config_env'
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rack-config_env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Naotoshi Seo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-02 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-nav
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A rack middleware to configure rack env.
98
+ email:
99
+ - sonots@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".travis.yml"
106
+ - CHANGELOG.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - example/sinatra/Gemfile
112
+ - example/sinatra/app.rb
113
+ - example/sinatra/config.ru
114
+ - lib/rack-config_env.rb
115
+ - lib/rack/config_env.rb
116
+ - rack-config_env.gemspec
117
+ - spec/rack-config_env_spec.rb
118
+ - spec/spec_helper.rb
119
+ homepage: ''
120
+ licenses:
121
+ - MIT
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.2.2
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: A rack middleware to configure rack env
143
+ test_files:
144
+ - spec/rack-config_env_spec.rb
145
+ - spec/spec_helper.rb