actionpack 5.0.0.beta4 → 5.0.0.racecar1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f74fd0c4a1304d3b6de560815456c08e23b5e05
4
- data.tar.gz: 58e4de5b07483d0062d052c853e8e2aa348134de
3
+ metadata.gz: 41c831579f90b1557ff21dc589b126dac6c75a8b
4
+ data.tar.gz: ecde94b249a0f3719f094420383236e9c5a57076
5
5
  SHA512:
6
- metadata.gz: 1daf9219be0739e3ea92b59e285f4c0cba24684b97df0cc5bc0790f7a3d0947f46c22867b65b0d8392e7c3eebf7b5bb1edaffea298c9754fa3bde070c0baac88
7
- data.tar.gz: 21f2abb512096ebc192e1d0f1c5e869f4b7c9032bed2d069ef2ed2bc400852bb85e3395cd1d92147b7227c2d222124bdad6f119f21142ec18d6a128508322dc6
6
+ metadata.gz: 4698ac011b1a6a11ed21c4f077c8a60c382fdbc98017823db8b2313067b1f42cdb909696a86f8175f7f88493ed50fa7b23f54e6f6e8586c1baf659a303b63fdc
7
+ data.tar.gz: 00c7b9d6e682b3a807742a488f846ab6af500289ff03f64db65c9f98a8f58bab68b300fe07411a15cd08506ba694ec25310f6bfe28443b2906aad00666282b13
@@ -1,3 +1,11 @@
1
+ ## Rails 5.0.0.rc1 (May 06, 2016) ##
2
+
3
+ * Add `ActionController#helpers` to get access to the view context at the controller
4
+ level.
5
+
6
+ *Rafael Mendonça França*
7
+
8
+
1
9
  ## Rails 5.0.0.beta4 (April 27, 2016) ##
2
10
 
3
11
  * Routing: Refactor `:action` default handling to ensure that path
@@ -60,9 +60,7 @@ module AbstractController
60
60
  end
61
61
 
62
62
  DEFAULT_PROTECTED_INSTANCE_VARIABLES = Set.new %i(
63
- @_action_name @_response_body @_formats @_prefixes @_config
64
- @_view_context_class @_view_renderer @_lookup_context
65
- @_routes @_db_runtime
63
+ @_action_name @_response_body @_formats @_prefixes
66
64
  )
67
65
 
68
66
  # This method should return a hash with assigns.
@@ -229,7 +229,7 @@ module ActionController
229
229
  HttpAuthentication::Digest::ControllerMethods,
230
230
  HttpAuthentication::Token::ControllerMethods,
231
231
 
232
- # Before callbacks should also be executed the earliest as possible, so
232
+ # Before callbacks should also be executed as early as possible, so
233
233
  # also include them at the bottom.
234
234
  AbstractController::Callbacks,
235
235
 
@@ -251,9 +251,10 @@ module ActionController
251
251
  setup_renderer!
252
252
 
253
253
  # Define some internal variables that should not be propagated to the view.
254
- PROTECTED_IVARS = AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES + [
255
- :@_params, :@_response, :@_request,
256
- :@_view_runtime, :@_stream, :@_url_options, :@_action_has_layout ]
254
+ PROTECTED_IVARS = AbstractController::Rendering::DEFAULT_PROTECTED_INSTANCE_VARIABLES + %i(
255
+ @_params @_response @_request @_config @_url_options @_action_has_layout @_view_context_class
256
+ @_view_renderer @_lookup_context @_routes @_view_runtime @_db_runtime @_helper_proxy
257
+ )
257
258
 
258
259
  def _protected_ivars # :nodoc:
259
260
  PROTECTED_IVARS
@@ -5,7 +5,7 @@ module ActionController
5
5
  #
6
6
  # In addition to using the standard template helpers provided, creating custom helpers to
7
7
  # extract complicated logic or reusable functionality is strongly encouraged. By default, each controller
8
- # will include all helpers. These helpers are only accessible on the controller through <tt>.helpers</tt>
8
+ # will include all helpers. These helpers are only accessible on the controller through <tt>#helpers</tt>
9
9
  #
10
10
  # In previous versions of \Rails the controller will include a helper which
11
11
  # matches the name of the controller, e.g., <tt>MyController</tt> will automatically
@@ -113,5 +113,10 @@ module ActionController
113
113
  all_helpers_from_path(helpers_path)
114
114
  end
115
115
  end
116
+
117
+ # Provides a proxy to access helpers methods from outside the view.
118
+ def helpers
119
+ @_helper_proxy ||= view_context
120
+ end
116
121
  end
117
122
  end
@@ -163,14 +163,6 @@ module ActionController
163
163
  end
164
164
  end
165
165
 
166
- def each
167
- @response.sending!
168
- while str = @buf.pop
169
- yield str
170
- end
171
- @response.sent!
172
- end
173
-
174
166
  # Write a 'close' event to the buffer; the producer/writing thread
175
167
  # uses this to notify us that it's finished supplying content.
176
168
  #
@@ -210,6 +202,14 @@ module ActionController
210
202
  def call_on_error
211
203
  @error_callback.call
212
204
  end
205
+
206
+ private
207
+
208
+ def each_chunk(&block)
209
+ while str = @buf.pop
210
+ yield str
211
+ end
212
+ end
213
213
  end
214
214
 
215
215
  class Response < ActionDispatch::Response #:nodoc: all
@@ -103,7 +103,7 @@ module ActionController
103
103
  #
104
104
  # Both <tt>ActionController::Base</tt> and <tt>ActionController::API</tt>
105
105
  # include <tt>ActionController::Renderers::All</tt>, making all renderers
106
- # avaialable in the controller. See <tt>Renderers::RENDERERS</tt> and <tt>Renderers.add</tt>.
106
+ # available in the controller. See <tt>Renderers::RENDERERS</tt> and <tt>Renderers.add</tt>.
107
107
  #
108
108
  # Since <tt>ActionController::Metal</tt> controllers cannot render, the controller
109
109
  # must include <tt>AbstractController::Rendering</tt>, <tt>ActionController::Rendering</tt>,
@@ -1,6 +1,6 @@
1
1
  module ActionController #:nodoc:
2
- # This module is responsible to provide `rescue_from` helpers
3
- # to controllers and configure when detailed exceptions must be
2
+ # This module is responsible for providing `rescue_from` helpers
3
+ # to controllers and configuring when detailed exceptions must be
4
4
  # shown.
5
5
  module Rescue
6
6
  extend ActiveSupport::Concern
@@ -43,7 +43,7 @@ module ActionController
43
43
 
44
44
  # == Action Controller \Parameters
45
45
  #
46
- # Allows to choose which attributes should be whitelisted for mass updating
46
+ # Allows you to choose which attributes should be whitelisted for mass updating
47
47
  # and thus prevent accidentally exposing that which shouldn't be exposed.
48
48
  # Provides two methods for this purpose: #require and #permit. The former is
49
49
  # used to mark parameters as required. The latter is used to set the parameter
@@ -196,7 +196,7 @@ module ActionController
196
196
  end
197
197
  alias_method :to_unsafe_hash, :to_unsafe_h
198
198
 
199
- # Convert all hashes in values into parameters, then yield each pair like
199
+ # Convert all hashes in values into parameters, then yield each pair in
200
200
  # the same way as <tt>Hash#each_pair</tt>
201
201
  def each_pair(&block)
202
202
  @parameters.each_pair do |key, value|
@@ -278,7 +278,7 @@ module ActionController
278
278
  # params = ActionController::Parameters.new(user: { ... }, profile: { ... })
279
279
  # user_params, profile_params = params.require(:user, :profile)
280
280
  #
281
- # Otherwise, the method reraises the first exception found:
281
+ # Otherwise, the method re-raises the first exception found:
282
282
  #
283
283
  # params = ActionController::Parameters.new(user: {}, profile: {})
284
284
  # user_params, profile_params = params.require(:user, :profile)
@@ -13,11 +13,11 @@ module ActionController
13
13
  #
14
14
  # ApplicationController.renderer.render template: '...'
15
15
  #
16
- # You can use a shortcut on controller to replace previous example with:
16
+ # You can use this shortcut in a controller, instead of the previous example:
17
17
  #
18
18
  # ApplicationController.render template: '...'
19
19
  #
20
- # #render method allows you to use any options as when rendering in controller.
20
+ # #render allows you to use the same options that you can use when rendering in a controller.
21
21
  # For example,
22
22
  #
23
23
  # FooController.render :action, locals: { ... }, assigns: { ... }
@@ -554,6 +554,8 @@ module ActionController
554
554
  end
555
555
  @request.query_string = ''
556
556
 
557
+ @response.sent!
558
+
557
559
  @response
558
560
  end
559
561
 
@@ -164,7 +164,7 @@ module ActionDispatch
164
164
  end
165
165
 
166
166
  def format_from_path_extension
167
- path = @env['action_dispatch.original_path'] || @env['PATH_INFO']
167
+ path = get_header('action_dispatch.original_path') || get_header('PATH_INFO')
168
168
  if match = path && path.match(/\.(\w+)\z/)
169
169
  Mime[match.captures.first]
170
170
  end
@@ -68,7 +68,13 @@ module ActionDispatch # :nodoc:
68
68
  alias_method :headers, :header
69
69
 
70
70
  delegate :[], :[]=, :to => :@header
71
- delegate :each, :to => :@stream
71
+
72
+ def each(&block)
73
+ sending!
74
+ x = @stream.each(&block)
75
+ sent!
76
+ x
77
+ end
72
78
 
73
79
  CONTENT_TYPE = "Content-Type".freeze
74
80
  SET_COOKIE = "Set-Cookie".freeze
@@ -97,10 +103,10 @@ module ActionDispatch # :nodoc:
97
103
 
98
104
  def body
99
105
  @str_body ||= begin
100
- buf = ''
101
- each { |chunk| buf << chunk }
102
- buf
103
- end
106
+ buf = ''
107
+ each { |chunk| buf << chunk }
108
+ buf
109
+ end
104
110
  end
105
111
 
106
112
  def write(string)
@@ -112,10 +118,13 @@ module ActionDispatch # :nodoc:
112
118
  end
113
119
 
114
120
  def each(&block)
115
- @response.sending!
116
- x = @buf.each(&block)
117
- @response.sent!
118
- x
121
+ if @str_body
122
+ return enum_for(:each) unless block_given?
123
+
124
+ yield @str_body
125
+ else
126
+ each_chunk(&block)
127
+ end
119
128
  end
120
129
 
121
130
  def abort
@@ -129,6 +138,12 @@ module ActionDispatch # :nodoc:
129
138
  def closed?
130
139
  @closed
131
140
  end
141
+
142
+ private
143
+
144
+ def each_chunk(&block)
145
+ @buf.each(&block) # extract into own method
146
+ end
132
147
  end
133
148
 
134
149
  def self.create(status = 200, header = {}, body = [], default_headers: self.default_headers)
@@ -133,7 +133,7 @@ module ActionDispatch
133
133
  def to_session_value #:nodoc:
134
134
  flashes_to_keep = @flashes.except(*@discard)
135
135
  return nil if flashes_to_keep.empty?
136
- {'flashes' => flashes_to_keep}
136
+ { 'discard' => [], 'flashes' => flashes_to_keep }
137
137
  end
138
138
 
139
139
  def initialize(flashes = {}, discard = []) #:nodoc:
@@ -9,7 +9,7 @@ module ActionDispatch
9
9
 
10
10
  # Singleton object used to determine if an optional param wasn't specified
11
11
  Unspecified = Object.new
12
-
12
+
13
13
  # Creates a session hash, merging the properties of the previous session if any
14
14
  def self.create(store, req, default_options)
15
15
  session_was = find req
@@ -198,6 +198,10 @@ module ActionDispatch
198
198
  @delegate.merge!(other)
199
199
  end
200
200
 
201
+ def each(&block)
202
+ to_hash.each(&block)
203
+ end
204
+
201
205
  private
202
206
 
203
207
  def load_for_read!
@@ -22,23 +22,23 @@ module ActionDispatch
22
22
  private_class_method :default_env
23
23
 
24
24
  def request_method=(method)
25
- @env['REQUEST_METHOD'] = method.to_s.upcase
25
+ set_header('REQUEST_METHOD', method.to_s.upcase)
26
26
  end
27
27
 
28
28
  def host=(host)
29
- @env['HTTP_HOST'] = host
29
+ set_header('HTTP_HOST', host)
30
30
  end
31
31
 
32
32
  def port=(number)
33
- @env['SERVER_PORT'] = number.to_i
33
+ set_header('SERVER_PORT', number.to_i)
34
34
  end
35
35
 
36
36
  def request_uri=(uri)
37
- @env['REQUEST_URI'] = uri
37
+ set_header('REQUEST_URI', uri)
38
38
  end
39
39
 
40
40
  def path=(path)
41
- @env['PATH_INFO'] = path
41
+ set_header('PATH_INFO', path)
42
42
  end
43
43
 
44
44
  def action=(action_name)
@@ -46,24 +46,24 @@ module ActionDispatch
46
46
  end
47
47
 
48
48
  def if_modified_since=(last_modified)
49
- @env['HTTP_IF_MODIFIED_SINCE'] = last_modified
49
+ set_header('HTTP_IF_MODIFIED_SINCE', last_modified)
50
50
  end
51
51
 
52
52
  def if_none_match=(etag)
53
- @env['HTTP_IF_NONE_MATCH'] = etag
53
+ set_header('HTTP_IF_NONE_MATCH', etag)
54
54
  end
55
55
 
56
56
  def remote_addr=(addr)
57
- @env['REMOTE_ADDR'] = addr
57
+ set_header('REMOTE_ADDR', addr)
58
58
  end
59
59
 
60
60
  def user_agent=(user_agent)
61
- @env['HTTP_USER_AGENT'] = user_agent
61
+ set_header('HTTP_USER_AGENT', user_agent)
62
62
  end
63
63
 
64
64
  def accept=(mime_types)
65
- @env.delete('action_dispatch.request.accepts')
66
- @env['HTTP_ACCEPT'] = Array(mime_types).collect(&:to_s).join(",")
65
+ delete_header('action_dispatch.request.accepts')
66
+ set_header('HTTP_ACCEPT', Array(mime_types).collect(&:to_s).join(","))
67
67
  end
68
68
  end
69
69
  end
@@ -8,7 +8,7 @@ module ActionPack
8
8
  MAJOR = 5
9
9
  MINOR = 0
10
10
  TINY = 0
11
- PRE = "beta4"
11
+ PRE = "racecar1"
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta4
4
+ version: 5.0.0.racecar1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0.beta4
19
+ version: 5.0.0.racecar1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0.beta4
26
+ version: 5.0.0.racecar1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rack
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -98,28 +98,28 @@ dependencies:
98
98
  requirements:
99
99
  - - '='
100
100
  - !ruby/object:Gem::Version
101
- version: 5.0.0.beta4
101
+ version: 5.0.0.racecar1
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - '='
107
107
  - !ruby/object:Gem::Version
108
- version: 5.0.0.beta4
108
+ version: 5.0.0.racecar1
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: activemodel
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
113
  - - '='
114
114
  - !ruby/object:Gem::Version
115
- version: 5.0.0.beta4
115
+ version: 5.0.0.racecar1
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - '='
121
121
  - !ruby/object:Gem::Version
122
- version: 5.0.0.beta4
122
+ version: 5.0.0.racecar1
123
123
  description: Web apps on Rails. Simple, battle-tested conventions for building and
124
124
  testing MVC web applications. Works with any Rack-compatible server.
125
125
  email: david@loudthinking.com
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  requirements:
303
303
  - none
304
304
  rubyforge_project:
305
- rubygems_version: 2.6.4
305
+ rubygems_version: 2.5.1
306
306
  signing_key:
307
307
  specification_version: 4
308
308
  summary: Web-flow and rendering framework putting the VC in MVC (part of Rails).