rack-http_router 0.0.32 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rack-http_router/action.rb +31 -10
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8cff48c0ee5cfa89a5de1274be3303220345822527d05a090be207148a8b9b5
4
- data.tar.gz: 60aa48e2d132770c406419b713582b0c7f88a5d833fbc48763a29ed8d58989b0
3
+ metadata.gz: c0c64f3cfa73ac4138ffda97860742253fe931eb53de45281627a58def572c54
4
+ data.tar.gz: 369489457adc954e84ffb7fd8c30eb9cfdea5ec3e44e64eda8a310df04779928
5
5
  SHA512:
6
- metadata.gz: 26edd2abbaff17cab89906192014d14e151aca4edd6f6cd7f81d8e8e2ed674d129e728ccdd87ff8e7557ba88ae1323084dca434b8fd06643f501a476cf9a46fc
7
- data.tar.gz: 6ce7a9c0fd92aaa12e9a7065c28594b20ac9af89634e34cef962b421ae4c702863c917ce1154c55f0854e4e0108ec2bdc52ef40ee6d00d66f923a4406fc60aca
6
+ metadata.gz: 796e12240f741f5b5f771a0b97b433a79f1c2d28a0d72d6db27470d78f22ddcbcb4a20207665912af65ab6351ffd1e7b26c2901366c7553a2b8842e0bb82d1d9
7
+ data.tar.gz: 858a3256bbe6f8e2910a5934b7fe71f2d83276e30a0735e769f83f7d1d72aded1d45d3587ca0c6c1e7c9a07c857b92bd6d32ce8d8422cf3a7a05463606969ed5
@@ -21,7 +21,10 @@ module Rack
21
21
  Rack::HttpRouter::Action.view_response(
22
22
  a_path,
23
23
  a_view_params,
24
- status: status, route: route
24
+ status: status,
25
+ config: config,
26
+ route: route,
27
+ db: db
25
28
  )
26
29
  end
27
30
 
@@ -31,7 +34,11 @@ module Rack
31
34
  Rack::HttpRouter::Action.view(
32
35
  a_path,
33
36
  a_view_params,
34
- status: status, response_instance: response_instance, route: route
37
+ status: status,
38
+ config: config,
39
+ route: route,
40
+ db: db,
41
+ response_instance: response_instance
35
42
  )
36
43
  end
37
44
  end
@@ -86,12 +93,22 @@ module Rack
86
93
  Rack::Response.new(content, status, { 'Content-Type' => 'text/html' })
87
94
  end
88
95
 
89
- def view_response(paths, view_params = {}, status: 200, route: nil)
96
+ def view_response(
97
+ paths,
98
+ view_params = {},
99
+ status: 200,
100
+ config: {},
101
+ route: nil,
102
+ db: nil
103
+ )
90
104
  view(
91
105
  paths,
92
106
  view_params,
93
- status: status, response_instance: true,
94
- route: route
107
+ status: status,
108
+ config: config,
109
+ route: route,
110
+ db: db,
111
+ response_instance: true
95
112
  )
96
113
  end
97
114
 
@@ -99,13 +116,15 @@ module Rack
99
116
  paths,
100
117
  view_params = {},
101
118
  status: 200,
102
- response_instance: false,
103
- route: nil
119
+ config: {},
120
+ route: nil,
121
+ db: nil,
122
+ response_instance: false
104
123
  )
105
124
  erb = if paths.is_a?(Array)
106
- paths.map { |path| erb("views/#{path}", route, view_params) }.join
125
+ paths.map { |path| erb("views/#{path}", config, route, db, view_params) }.join
107
126
  else
108
- erb("views/#{paths}", route, view_params)
127
+ erb("views/#{paths}", config, route, db, view_params)
109
128
  end
110
129
 
111
130
  if response_instance
@@ -143,11 +162,13 @@ module Rack
143
162
  )
144
163
  end
145
164
 
146
- def erb(path, _route, view_params = {})
165
+ # rubocop:disable Lint/UnusedMethodArgument
166
+ def erb(path, config, route, db, view_params = {})
147
167
  @view = OpenStruct.new(view_params)
148
168
 
149
169
  eval(Erubi::Engine.new(::File.read("#{path}.html.erb")).src)
150
170
  end
171
+ # rubocop:enable Lint/UnusedMethodArgument
151
172
 
152
173
  def redirect_response(url)
153
174
  Rack::Response.new(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-http_router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique F. Teixeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-25 00:00:00.000000000 Z
11
+ date: 2023-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubi