rutter 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0a36fa3c38406718e9fd535b91fbc0db685c6dd5de5ec08b07f7046711bfc8f2
4
- data.tar.gz: 18f984a1fafcf11c2bbd6fe67cdd01fbfaf9e5b8508aa3aca3d54ac34ebc5c1f
3
+ metadata.gz: 4df69773cb0979c061fae5c421243b6d0b9892e244a0eb14442b894c8657e094
4
+ data.tar.gz: 0dc82eefc22f4f82c79b6e85dab56605ee9eab02c99ccea063c51d9734eb66d4
5
5
  SHA512:
6
- metadata.gz: 44648973cf5a942840484fbca8129c0d144a15948792923dee5ee63df19da4a273bda50bb28e1806b79e62930c23521284cd2b56506386dd00f745dd1752a783
7
- data.tar.gz: 659a337b9f92478556992319ed2aed38f51e912a891004a765790d06a45a9bfac67c54b4987fc43b9f5c51412948803335d45e694eb15308803ea777bc442434
6
+ metadata.gz: 29296019b52750432a1386e465ec29611d3bd47261b80e7a50992ecb973ccd787775e4eec42fbe98a9bf0efd8b75e25644f3a750f315f6c5694106972b79cfdc
7
+ data.tar.gz: 0f808af9d007dfd92be6eac06cb9be4a794efbf5c9b9b9e4a18f69c9fee7705bd4864cdaba5f55933011d2118886ea2cfdafb4237a8f51f96d75d44c95d9a1c7
@@ -10,7 +10,7 @@ router = Rutter.new do
10
10
  get "/", to: ->(_) { [200, {}, ["Hello World"]] }
11
11
 
12
12
  # wrk -t 2 http://localhost:9292/ruby
13
- get "/:lang", to: ->(env) { [200, {}, [env["rutter.params"]["lang"]]] }
13
+ get "/:lang", to: ->(env) { [200, {}, [env["router.params"]["lang"]]] }
14
14
  end.freeze
15
15
 
16
16
  run router
@@ -1,10 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "rutter/version"
4
- require_relative "rutter/builder"
5
-
6
3
  # HTTP router for Rack.
7
4
  module Rutter
5
+ # Supported request verbs.
6
+ #
7
+ # @return [Array]
8
+ VERBS = %w[GET POST PUT PATCH DELETE OPTIONS].freeze
9
+
10
+ require_relative "rutter/version"
11
+ require_relative "rutter/builder"
12
+
8
13
  # Factory method for creating a new builder object.
9
14
  #
10
15
  # @param base [String]
@@ -3,7 +3,6 @@
3
3
  require "uri"
4
4
 
5
5
  require_relative "naming"
6
- require_relative "verbs"
7
6
  require_relative "route"
8
7
  require_relative "mount"
9
8
  require_relative "scope"
@@ -40,7 +39,7 @@ module Rutter
40
39
  def initialize(base: "http://localhost:9292", &block)
41
40
  @uri = URI(base).freeze
42
41
  @flat_map = []
43
- @verb_map = Hash.new { |h, k| h[k] = [] }
42
+ @verb_map = VERBS.map { |v| [v, []] }.to_h
44
43
  @named_map = {}
45
44
 
46
45
  instance_eval(&block) if block_given?
@@ -84,8 +84,8 @@ module Rutter
84
84
  #
85
85
  # @private
86
86
  def call(env)
87
- env["rutter.params"] ||= {}
88
- env["rutter.params"].merge!(params(env["PATH_INFO"]))
87
+ env["router.params"] ||= {}
88
+ env["router.params"].merge!(params(env["PATH_INFO"]))
89
89
  env["rutter.action"] = @endpoint[:action]
90
90
 
91
91
  ctrl = @endpoint[:controller]
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Rutter
4
4
  # Current version number.
5
- VERSION = "0.3.1"
5
+ VERSION = "0.3.2"
6
6
  end
@@ -4,7 +4,7 @@ RSpec.describe "Rack compatible", type: :request do
4
4
  let :router do
5
5
  Rutter.new do
6
6
  get "/say/:message", to: (lambda do |env|
7
- [200, {}, ["I say, #{env['rutter.params']['message']}"]]
7
+ [200, {}, ["I say, #{env['router.params']['message']}"]]
8
8
  end)
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Sandelius
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mustermann
@@ -117,7 +117,6 @@ files:
117
117
  - lib/rutter/route.rb
118
118
  - lib/rutter/routes.rb
119
119
  - lib/rutter/scope.rb
120
- - lib/rutter/verbs.rb
121
120
  - lib/rutter/version.rb
122
121
  - rutter.gemspec
123
122
  - spec/integration/rack_spec.rb
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Rutter
4
- # Supported request verbs.
5
- #
6
- # @return [Array]
7
- VERBS = %w[GET POST PUT PATCH DELETE OPTIONS].freeze
8
- end