rack_router 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +86 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/rack/router.rb +12 -0
- data/lib/rack/router/middleware.rb +128 -0
- data/lib/rack/router/path_part.rb +18 -0
- data/lib/rack/router/route.rb +51 -0
- data/lib/rack/router/route_builder.rb +58 -0
- data/lib/rack/router/version.rb +5 -0
- data/lib/rack_router.rb +1 -0
- data/rack_router.gemspec +29 -0
- metadata +78 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 371f49e5b4147144b7ea7237e66f2defafc621d99022b15031914f2f3011a2c4
|
4
|
+
data.tar.gz: 34d45cdc026561b2dd944b0d1bf438edb9a5997f25a0f994d934d7fb953c342e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a2e3780125208f53c537cce13dbe45ae10c147236eaba0df876a12a92678f94dcc2b1c019afc88b656020f7c517593fd1e88f3bf9d34414469eae832d781e32e
|
7
|
+
data.tar.gz: 21187ed1a1b03f411fa25038259104d6817ceb3ecd940c99e75f585c5b3aae982d9e3ae284d990e9c5b573a9c503de052a0119c6d6deaa6e2cdaafd182a5d1c1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at senid231@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Denis Talakevich
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# RackRouter
|
2
|
+
|
3
|
+
Simple and functional rack middleware for routing requests.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'rack_router'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install rack_router
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
`config.ru`
|
24
|
+
```ruby
|
25
|
+
class App
|
26
|
+
def call(env)
|
27
|
+
method_name = env[Rack::Router::RACK_ROUTER_PATH]
|
28
|
+
public_send(method_name, env)
|
29
|
+
end
|
30
|
+
|
31
|
+
def posts_index(env)
|
32
|
+
[200, {}, ['OK']]
|
33
|
+
end
|
34
|
+
|
35
|
+
def posts_show(env)
|
36
|
+
id = env[Rack::Router::RACK_ROUTER_PATH_HASH][:id]
|
37
|
+
[200, {}, ['OK']]
|
38
|
+
end
|
39
|
+
|
40
|
+
def posts_create(env)
|
41
|
+
[201, {}, ['Created']]
|
42
|
+
end
|
43
|
+
|
44
|
+
def posts_update(env)
|
45
|
+
id = env[Rack::Router::RACK_ROUTER_PATH_HASH][:id]
|
46
|
+
[200, {}, ['Updated']]
|
47
|
+
end
|
48
|
+
|
49
|
+
def posts_destroy(env)
|
50
|
+
id = env[Rack::Router::RACK_ROUTER_PATH_HASH][:id]
|
51
|
+
[204, {}, []]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
app = Rack::Builder.new do
|
56
|
+
use Rack::Router::Middleware do
|
57
|
+
get '/posts', 'posts_index'
|
58
|
+
get '/posts/:id', 'posts_show'
|
59
|
+
post '/posts', 'posts_create'
|
60
|
+
put '/posts/:id', 'posts_update'
|
61
|
+
delete '/posts/:id', 'posts_destroy'
|
62
|
+
end
|
63
|
+
|
64
|
+
run App.new
|
65
|
+
end
|
66
|
+
run app
|
67
|
+
```
|
68
|
+
|
69
|
+
## Development
|
70
|
+
|
71
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
72
|
+
|
73
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
74
|
+
|
75
|
+
## Contributing
|
76
|
+
|
77
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/senid231/rack_router. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rack_router/blob/master/CODE_OF_CONDUCT.md).
|
78
|
+
|
79
|
+
|
80
|
+
## License
|
81
|
+
|
82
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
83
|
+
|
84
|
+
## Code of Conduct
|
85
|
+
|
86
|
+
Everyone interacting in the RackRouter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rack_router/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rack_router"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/rack/router.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'rack/router/route'
|
3
|
+
require 'rack/router/route_builder'
|
4
|
+
require 'rack/router/path_part'
|
5
|
+
require 'rack/router/middleware'
|
6
|
+
|
7
|
+
module Rack
|
8
|
+
module Router
|
9
|
+
RACK_ROUTER_PATH = 'rack.router.path'.freeze
|
10
|
+
RACK_ROUTER_PATH_HASH = 'rack.router.path_hash'.freeze
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Rack
|
4
|
+
module Router
|
5
|
+
class Middleware
|
6
|
+
attr_reader :logger
|
7
|
+
|
8
|
+
def initialize(app, logger: nil, &block)
|
9
|
+
@app = app
|
10
|
+
@routes = RouteBuilder.new
|
11
|
+
@current_path = nil
|
12
|
+
@current_options = {}
|
13
|
+
@not_found = nil
|
14
|
+
@logger = logger || Logger.new(STDOUT)
|
15
|
+
@callbacks = []
|
16
|
+
instance_exec(&block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def call(env)
|
20
|
+
route = @routes.match(env)
|
21
|
+
env[RACK_ROUTER_PATH] = route&.value
|
22
|
+
env[RACK_ROUTER_PATH_HASH] = route&.path_hash env[Rack::PATH_INFO]
|
23
|
+
run_after_route(env, route)
|
24
|
+
|
25
|
+
if route.nil? && !@not_found.nil?
|
26
|
+
logger.debug { "#{self.class}#call route was not found\n#{@routes.print_routes}" }
|
27
|
+
return render_not_found(env)
|
28
|
+
end
|
29
|
+
|
30
|
+
@app.call(env)
|
31
|
+
end
|
32
|
+
|
33
|
+
[:get, :post, :put, :patch, :delete, :option, :head].each do |http_method|
|
34
|
+
# @param path [String]
|
35
|
+
# @param value [String, Proc<Hash>]
|
36
|
+
# @param options [Hash<Symbol>,Hash]
|
37
|
+
# :constraint [Hash<Symbol=>Proc<String>>]
|
38
|
+
# :content_type [Array<String>,String]
|
39
|
+
define_method(http_method) do |path, value, options = {}|
|
40
|
+
define_path(http_method, path, value, options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def match(path, value, options = {})
|
45
|
+
define_path(nil, path, value, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
# @param path [String]
|
49
|
+
# @param options [Hash<Symbol>,Hash]
|
50
|
+
# :constraint [Hash<Symbol=>Proc<String>>]
|
51
|
+
# :content_type [String, Array<String>]
|
52
|
+
def nested(path, options = {})
|
53
|
+
old_current_path = @current_path
|
54
|
+
old_current_options = @current_options
|
55
|
+
@current_path = [@current_path, path].compact.join('/')
|
56
|
+
@current_options = @current_options.dup.merge(options)
|
57
|
+
yield
|
58
|
+
ensure
|
59
|
+
@current_path = old_current_path
|
60
|
+
@current_options = old_current_options
|
61
|
+
end
|
62
|
+
|
63
|
+
# @param path [String]
|
64
|
+
def namespace(path, &block)
|
65
|
+
nested(path, {}, &block)
|
66
|
+
end
|
67
|
+
|
68
|
+
# @param constraint [Hash<Symbol,Proc<String>>]
|
69
|
+
def with_constraint(constraint, &block)
|
70
|
+
nested(nil, constraint: constraint, &block)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param content_type [String, Array<String>]
|
74
|
+
def with_content_type(content_type, &block)
|
75
|
+
nested(nil, content_type: content_type, &block)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @param accept [String, Array<String>]
|
79
|
+
def with_accept(accept, &block)
|
80
|
+
nested(nil, accept: accept, &block)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @param http_method [String,Symbol]
|
84
|
+
# @param path [String]
|
85
|
+
# @param value [String, Proc<Hash>]
|
86
|
+
# @param options [Hash]
|
87
|
+
# :constraint [Hash<Symbol=>Proc<String>>]
|
88
|
+
# :content_type [Array<String>,String]
|
89
|
+
def define_path(http_method, path, value, options = {})
|
90
|
+
options = @current_options.dup.merge(options)
|
91
|
+
path = [@current_path, path].reject(&:empty?).join('/')
|
92
|
+
@routes.add(http_method, path, value, options)
|
93
|
+
end
|
94
|
+
|
95
|
+
def not_found(response)
|
96
|
+
response = default_not_found if response == :default
|
97
|
+
response = nil unless response
|
98
|
+
@not_found = response
|
99
|
+
end
|
100
|
+
|
101
|
+
# @yield after route match executed
|
102
|
+
# @yieldparam env [Hash]
|
103
|
+
# @yieldparam route [Rack::Router::Route, NilClass]
|
104
|
+
def after_route(&block)
|
105
|
+
raise ArgumentError, 'block must be given' unless block_given?
|
106
|
+
|
107
|
+
@callbacks.push(block)
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def run_after_route(env, route)
|
113
|
+
@callbacks.each do |cb|
|
114
|
+
instance_exec(env, route, &cb)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def default_not_found
|
119
|
+
[404, { Rack::CONTENT_TYPE => 'text/plain' }, ['Route not found']]
|
120
|
+
end
|
121
|
+
|
122
|
+
def render_not_found(env)
|
123
|
+
return @not_found.call(env) if @not_found.is_a?(Proc)
|
124
|
+
@not_found
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rack
|
2
|
+
module Router
|
3
|
+
class PathPart
|
4
|
+
attr_reader :constraint
|
5
|
+
|
6
|
+
def initialize(constraint)
|
7
|
+
@constraint = constraint
|
8
|
+
end
|
9
|
+
|
10
|
+
def ==(str)
|
11
|
+
return true if constraint.nil?
|
12
|
+
!!constraint.call(str)
|
13
|
+
rescue TypeError, ArgumentError
|
14
|
+
false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Rack
|
2
|
+
module Router
|
3
|
+
# Route = Struct.new(:http_method, :path, :path_parts, :value, :constraint, :content_type) do
|
4
|
+
# def value_for(env)
|
5
|
+
# return value unless value.is_a?(Proc)
|
6
|
+
# value.call(env)
|
7
|
+
# end
|
8
|
+
# end
|
9
|
+
|
10
|
+
|
11
|
+
class Route
|
12
|
+
attr_reader :http_method, :path, :path_parts, :value, :constraint, :content_type, :accept
|
13
|
+
|
14
|
+
def initialize(http_method:, path:, value:, constraint: nil, content_type: nil, accept: nil)
|
15
|
+
@http_method = http_method.to_s.upcase
|
16
|
+
@path = path
|
17
|
+
@value = value
|
18
|
+
@constraint = constraint
|
19
|
+
@content_type = content_type ? Array.wrap(content_type) : nil
|
20
|
+
@accept = accept ? Array.wrap(accept) : nil
|
21
|
+
@path_parts = calculate_path_parts
|
22
|
+
end
|
23
|
+
|
24
|
+
def path_hash(request_path)
|
25
|
+
request_path = request_path.to_s.gsub(/\..*\z/, '')
|
26
|
+
request_path_parts = request_path.split('/').reject(&:empty?)
|
27
|
+
pairs = path.split('/').map.with_index do |part, idx|
|
28
|
+
next if part[0] != ':'
|
29
|
+
[part[1..-1].to_sym, request_path_parts[idx]]
|
30
|
+
end
|
31
|
+
pairs.reject(&:nil?).to_h
|
32
|
+
end
|
33
|
+
|
34
|
+
def print_route
|
35
|
+
str = "\t#{http_method} \t#{path}"
|
36
|
+
str += "\tcontent_type=[#{content_type.join(',')}]" unless content_type.nil?
|
37
|
+
str += "\taccept=[#{content_type.join(',')}]" unless accept.nil?
|
38
|
+
str
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def calculate_path_parts
|
44
|
+
path.split('/').map do |part|
|
45
|
+
next part if part[0] != ':'
|
46
|
+
PathPart.new constraint&.fetch(part[1..-1].to_sym, nil)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Rack
|
2
|
+
module Router
|
3
|
+
class RouteBuilder
|
4
|
+
def initialize
|
5
|
+
@routes = []
|
6
|
+
end
|
7
|
+
|
8
|
+
# @param http_method [Symbol,String]
|
9
|
+
# @param path [String]
|
10
|
+
# @param value [String, Proc<Hash>]
|
11
|
+
# @param options [Hash]
|
12
|
+
# :constraint [Hash<Symbol,Proc<String>>]
|
13
|
+
# :content_type [Array<String>,String]
|
14
|
+
def add(http_method, path, value, options = {})
|
15
|
+
path = path.split('/').reject(&:empty?).join('/')
|
16
|
+
route = Route.new(
|
17
|
+
http_method: http_method.to_s.upcase,
|
18
|
+
path: path,
|
19
|
+
value: value,
|
20
|
+
**options
|
21
|
+
)
|
22
|
+
@routes.push(route)
|
23
|
+
route
|
24
|
+
end
|
25
|
+
|
26
|
+
def match(env)
|
27
|
+
http_method = env[Rack::REQUEST_METHOD]
|
28
|
+
path = env[Rack::PATH_INFO].to_s.gsub(/\..*\z/, '')
|
29
|
+
content_type, *_ = env['CONTENT_TYPE'].to_s.split(';')
|
30
|
+
content_type = nil if !content_type.nil? && content_type.empty?
|
31
|
+
accept, *_ = env['HTTP_ACCEPT'].to_s.split(';')
|
32
|
+
accept = accept.to_s.split(',')
|
33
|
+
|
34
|
+
match_request(http_method, path, content_type: content_type, accept: accept)
|
35
|
+
end
|
36
|
+
|
37
|
+
# @param http_method [String] upcase GET POST PUT PATCH DELETE HEAD
|
38
|
+
# @param path [String]
|
39
|
+
# @param content_type [String, NilClass]
|
40
|
+
# @param accept [Array]
|
41
|
+
def match_request(http_method, path, content_type: nil, accept: [])
|
42
|
+
path_parts = path.split('/').reject(&:empty?)
|
43
|
+
@routes.detect do |route|
|
44
|
+
next false if route.http_method && route.http_method != http_method
|
45
|
+
next false if route.content_type && route.content_type.include?(content_type)
|
46
|
+
next false if route.accept && (route.accept & accept).empty? && !accept.include?('*/*')
|
47
|
+
next false if route.path_parts.size != path_parts.size
|
48
|
+
next false if route.path_parts.map.with_index { |part, idx| part != path_parts[idx] }.any?
|
49
|
+
true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def print_routes
|
54
|
+
"Routes (#{@routes.size}):\n" + @routes.map(&:print_route).join("\n") + "\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/lib/rack_router.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'rack/router'
|
data/rack_router.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/rack/router/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'rack_router'
|
5
|
+
spec.version = Rack::Router::VERSION
|
6
|
+
spec.authors = ['Denis Talakevich']
|
7
|
+
spec.email = ['senid231@gmail.com']
|
8
|
+
|
9
|
+
spec.summary = 'Rack middleware for routing requests.'
|
10
|
+
spec.description = 'Simple and functional rack middleware for routing requests.'
|
11
|
+
spec.homepage = 'https://github.com/senid231/rack_router'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
14
|
+
|
15
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
16
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
17
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = 'exe'
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ['lib']
|
27
|
+
|
28
|
+
spec.add_dependency 'rack'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rack_router
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denis Talakevich
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-01-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: '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
|
+
description: Simple and functional rack middleware for routing requests.
|
28
|
+
email:
|
29
|
+
- senid231@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".travis.yml"
|
36
|
+
- CHANGELOG.md
|
37
|
+
- CODE_OF_CONDUCT.md
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE.txt
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- bin/console
|
43
|
+
- bin/setup
|
44
|
+
- lib/rack/router.rb
|
45
|
+
- lib/rack/router/middleware.rb
|
46
|
+
- lib/rack/router/path_part.rb
|
47
|
+
- lib/rack/router/route.rb
|
48
|
+
- lib/rack/router/route_builder.rb
|
49
|
+
- lib/rack/router/version.rb
|
50
|
+
- lib/rack_router.rb
|
51
|
+
- rack_router.gemspec
|
52
|
+
homepage: https://github.com/senid231/rack_router
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
metadata:
|
56
|
+
homepage_uri: https://github.com/senid231/rack_router
|
57
|
+
source_code_uri: https://github.com/senid231/rack_router
|
58
|
+
changelog_uri: https://github.com/senid231/rack_router/blob/master/CHANGELOG.md
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.3.0
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubygems_version: 3.1.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Rack middleware for routing requests.
|
78
|
+
test_files: []
|