hashie 3.5.2 → 3.5.3

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
  SHA1:
3
- metadata.gz: ee11cc424479d1ff5f737d9279f60e182adb0553
4
- data.tar.gz: 7bae504b1c65b8cf79909c3180cf5084771efb5e
3
+ metadata.gz: f4946d0568ab6be36877e25d748fdb8f04f50ed5
4
+ data.tar.gz: f9cdd8a276939236ceb84633d88d5325486d5d86
5
5
  SHA512:
6
- metadata.gz: 6af54aa6435ee5df457614baf9a60a0d3660e7066229e90a74109ff38999afda2444a02e965ec9f5422e4ddd85e6a493d3cb52ff735712d8dfd8d02c84f504f8
7
- data.tar.gz: a2ed6b577219d2a7e6ebaca2ca5589b29af9b89a1201580707ab39d4895c0cbee63f4dd4e92a5c3ccda1409f226fc0ccbce41e0b7f8e6a694f6d85df7e598d60
6
+ metadata.gz: 7c4748d9c7c2d79fa5a362fe10497994ea1f7fc27e75dc476b17422cd32fb9d32d9923c42662a7bfb64c19413b1391124cf91cfd463b0c4adcdc7b463d611981
7
+ data.tar.gz: ded15b7bd812ffe4792cf7e56f894e040d9041af56e1816f2c3d82ef62ee7bd5193fcf2cdac4086b11372dc6689fc0ee0a1b150f84cb17462e93bc4a5f860878
@@ -6,6 +6,16 @@ scheme are considered to be bugs.
6
6
 
7
7
  [semver]: http://semver.org/spec/v2.0.0.html
8
8
 
9
+ ## [3.5.3] - 2017-02-11
10
+
11
+ [3.5.3]: https://github.com/intridea/hashie/compare/v3.5.2...v3.5.3
12
+
13
+ ### Fixed
14
+
15
+ * [#402](https://github.com/intridea/hashie/pull/402): Use a Railtie to set Hashie.logger on rails boot - [@matthewrudy](https://github.com/matthewrudy).
16
+ * [#406](https://github.com/intridea/hashie/pull/406): Ensure that subclasses that disable warnings propagate that setting to grandchild classes - [@michaelherold](https://github.com/michaelherold).
17
+ * Your contribution here.
18
+
9
19
  ## [3.5.2] - 2017-02-10
10
20
 
11
21
  [3.5.2]: https://github.com/intridea/hashie/compare/v3.5.1...v3.5.2
data/README.md CHANGED
@@ -20,7 +20,7 @@ $ gem install hashie
20
20
 
21
21
  ## Upgrading
22
22
 
23
- You're reading the documentation for the stable release of Hashie, 3.5.2. Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
23
+ You're reading the documentation for the stable release of Hashie, 3.5.3. Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
24
24
 
25
25
  ## Hash Extensions
26
26
 
@@ -56,4 +56,6 @@ module Hashie
56
56
  include Hashie::Extensions::StringifyKeys::ClassMethods
57
57
  include Hashie::Extensions::SymbolizeKeys::ClassMethods
58
58
  end
59
+
60
+ require 'hashie/railtie' if defined?(::Rails)
59
61
  end
@@ -5,12 +5,7 @@ module Hashie
5
5
  #
6
6
  # @return [Logger]
7
7
  def self.logger
8
- @logger ||=
9
- if defined?(::Rails)
10
- Rails.logger
11
- else
12
- Logger.new(STDOUT)
13
- end
8
+ @logger ||= Logger.new(STDOUT)
14
9
  end
15
10
 
16
11
  # Sets the logger that Hashie uses for reporting errors.
@@ -86,6 +86,15 @@ module Hashie
86
86
  !!@disable_warnings
87
87
  end
88
88
 
89
+ # Inheritance hook that sets class configuration when inherited.
90
+ #
91
+ # @api semipublic
92
+ # @return [void]
93
+ def self.inherited(subclass)
94
+ super
95
+ subclass.disable_warnings if disable_warnings?
96
+ end
97
+
89
98
  def self.load(path, options = {})
90
99
  @_mashes ||= new
91
100
 
@@ -0,0 +1,10 @@
1
+ require 'rails/railtie'
2
+
3
+ module Hashie
4
+ class Railtie < Rails::Railtie
5
+ # Set the Hashie.logger to use Rails.logger when used with rails.
6
+ initializer 'hashie.configure_logger', after: 'initialize_logger' do
7
+ Hashie.logger = Rails.logger
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Hashie
2
- VERSION = '3.5.2'
2
+ VERSION = '3.5.3'
3
3
  end
@@ -155,6 +155,17 @@ describe Hashie::Mash do
155
155
  it 'cannot disable logging on the base Mash' do
156
156
  expect { Hashie::Mash.disable_warnings }.to raise_error(Hashie::Mash::CannotDisableMashWarnings)
157
157
  end
158
+
159
+ it 'carries over the disable for warnings on grandchild classes' do
160
+ child_class = Class.new(Hashie::Mash) do
161
+ disable_warnings
162
+ end
163
+ grandchild_class = Class.new(child_class)
164
+
165
+ grandchild_class.new('trust' => { 'two' => 2 })
166
+
167
+ expect(logger_output).to be_blank
168
+ end
158
169
  end
159
170
 
160
171
  context 'updating' do
@@ -0,0 +1,53 @@
1
+ require 'action_controller/railtie'
2
+ require 'action_view/railtie'
3
+ require 'action_view/testing/resolvers'
4
+ require 'rails/test_unit/railtie'
5
+ require_relative 'some_site'
6
+
7
+ module RailsApp
8
+ class Application < ::Rails::Application
9
+ config.eager_load = false
10
+ config.secret_key_base = 'hashieintegrationtest'
11
+
12
+ config.middleware.use OmniAuth::Builder do
13
+ provider :some_site
14
+ end
15
+
16
+ routes.append do
17
+ get '/' => 'application#index'
18
+ end
19
+ end
20
+ end
21
+
22
+ LAYOUT = <<-HTML
23
+ <!DOCTYPE html>
24
+ <html>
25
+ <head>
26
+ <title>TestApp</title>
27
+ <%= csrf_meta_tags %>
28
+ </head>
29
+ <body>
30
+ <%= yield %>
31
+ </body>
32
+ </html>
33
+ HTML
34
+
35
+ INDEX = '<h1>Hello, world!</h1>'
36
+
37
+ class ApplicationController < ActionController::Base
38
+ include Rails.application.routes.url_helpers
39
+
40
+ layout 'application'
41
+
42
+ self.view_paths = [ActionView::FixtureResolver.new(
43
+ 'layouts/application.html.erb' => LAYOUT,
44
+ 'application/index.html.erb' => INDEX
45
+ )]
46
+
47
+ def index
48
+ end
49
+ end
50
+
51
+ Bundler.require(:default, Rails.env)
52
+
53
+ RailsApp::Application.initialize!
@@ -0,0 +1,26 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'rspec/core'
4
+
5
+ RSpec.describe 'omniauth-oauth2 inside of rails', type: :request do
6
+ let(:stdout) { StringIO.new }
7
+
8
+ around(:each) do |example|
9
+ original_stdout = $stdout
10
+ $stdout = stdout
11
+ require_relative 'app'
12
+ require 'rspec/rails'
13
+ example.run
14
+ $stdout = original_stdout
15
+ end
16
+
17
+ it 'does not log anything to STDOUT when initializing a Rails app and is set to Rails logger' do
18
+ expect(stdout.string).to eq('')
19
+ expect(Hashie.logger).to eq(Rails.logger)
20
+ end
21
+
22
+ it 'works' do
23
+ get '/'
24
+ assert_select 'h1', 'Hello, world!'
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class SomeSite < OmniAuth::Strategies::OAuth2
6
+ # Give your strategy a name.
7
+ option :name, 'some_site'
8
+
9
+ # This is where you pass the options you would pass when
10
+ # initializing your consumer from the OAuth gem.
11
+ option :client_options, site: 'https://api.somesite.com'
12
+
13
+ # These are called after authentication has succeeded. If
14
+ # possible, you should try to set the UID without making
15
+ # additional calls (if the user id is returned with the token
16
+ # or as a URI parameter). This may not be possible with all
17
+ # providers.
18
+ uid { raw_info['id'] }
19
+
20
+ info do
21
+ {
22
+ :name => raw_info['name'],
23
+ :email => raw_info['email']
24
+ }
25
+ end
26
+
27
+ extra do
28
+ {
29
+ 'raw_info' => raw_info
30
+ }
31
+ end
32
+
33
+ def raw_info
34
+ @raw_info ||= access_token.get('/me').parsed
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,11 @@
1
+ require 'sinatra'
2
+ require 'omniauth'
3
+
4
+ class MyApplication < Sinatra::Base
5
+ use Rack::Session::Cookie, secret: 'hashie integration tests'
6
+ use OmniAuth::Strategies::Developer
7
+
8
+ get '/' do
9
+ 'Hello World'
10
+ end
11
+ end
@@ -2,33 +2,34 @@ ENV['RACK_ENV'] = 'test'
2
2
 
3
3
  require 'rspec/core'
4
4
  require 'rack/test'
5
- require 'sinatra'
6
- require 'omniauth'
7
5
 
8
- class MyApplication < Sinatra::Base
9
- use Rack::Session::Cookie, secret: 'hashie integration tests'
10
- use OmniAuth::Strategies::Developer
11
-
12
- get '/' do
13
- 'Hello World'
6
+ RSpec.configure do |config|
7
+ config.expect_with :rspec do |expect|
8
+ expect.syntax = :expect
14
9
  end
15
10
  end
16
11
 
17
- module RSpecMixin
12
+ RSpec.describe 'omniauth' do
18
13
  include Rack::Test::Methods
14
+
19
15
  def app
20
16
  MyApplication
21
17
  end
22
- end
23
18
 
24
- RSpec.configure do |config|
25
- config.include RSpecMixin
26
- config.expect_with :rspec do |expect|
27
- expect.syntax = :expect
19
+ let(:stdout) { StringIO.new }
20
+
21
+ around(:each) do |example|
22
+ original_stdout = $stdout
23
+ $stdout = stdout
24
+ require_relative 'app'
25
+ example.run
26
+ $stdout = original_stdout
27
+ end
28
+
29
+ it 'does not log anything to STDOUT when initializing' do
30
+ expect(stdout.string).to eq('')
28
31
  end
29
- end
30
32
 
31
- describe 'omniauth' do
32
33
  it 'works' do
33
34
  get '/'
34
35
  expect(last_response).to be_ok
@@ -0,0 +1,48 @@
1
+ require 'action_controller/railtie'
2
+ require 'action_view/railtie'
3
+ require 'action_view/testing/resolvers'
4
+ require 'rails/test_unit/railtie'
5
+
6
+ module RailsApp
7
+ class Application < ::Rails::Application
8
+ config.eager_load = false
9
+ config.secret_key_base = 'hashieintegrationtest'
10
+
11
+ routes.append do
12
+ get '/' => 'application#index'
13
+ end
14
+ end
15
+ end
16
+
17
+ LAYOUT = <<-HTML
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <title>TestApp</title>
22
+ <%= csrf_meta_tags %>
23
+ </head>
24
+ <body>
25
+ <%= yield %>
26
+ </body>
27
+ </html>
28
+ HTML
29
+
30
+ INDEX = '<h1>Hello, world!</h1>'
31
+
32
+ class ApplicationController < ActionController::Base
33
+ include Rails.application.routes.url_helpers
34
+
35
+ layout 'application'
36
+
37
+ self.view_paths = [ActionView::FixtureResolver.new(
38
+ 'layouts/application.html.erb' => LAYOUT,
39
+ 'application/index.html.erb' => INDEX
40
+ )]
41
+
42
+ def index
43
+ end
44
+ end
45
+
46
+ Bundler.require(:default, Rails.env)
47
+
48
+ RailsApp::Application.initialize!
@@ -1,66 +1,26 @@
1
- ENV['RACK_ENV'] = 'test'
1
+ ENV['RAILS_ENV'] = 'test'
2
2
 
3
3
  require 'rspec/core'
4
- require 'rails'
5
- require 'rails/all'
6
- require 'action_view/testing/resolvers'
7
4
 
8
- module RailsApp
9
- class Application < ::Rails::Application
10
- config.action_dispatch.show_exceptions = false
11
- config.active_support.deprecation = :stderr
12
- config.eager_load = false
13
- config.root = __dir__
14
- config.secret_key_base = 'hashieintegrationtest'
5
+ RSpec.describe 'rails', type: :request do
6
+ let(:stdout) { StringIO.new }
15
7
 
16
- routes.append do
17
- get '/' => 'application#index'
18
- end
19
-
20
- config.assets.paths << File.join(__dir__, 'assets/javascripts')
21
- config.assets.debug = true
8
+ around(:each) do |example|
9
+ original_stdout = $stdout
10
+ $stdout = stdout
11
+ require_relative 'app'
12
+ require 'rspec/rails'
13
+ example.run
14
+ $stdout = original_stdout
22
15
  end
23
- end
24
-
25
- LAYOUT = <<-HTML
26
- <!DOCTYPE html>
27
- <html>
28
- <head>
29
- <title>TestApp</title>
30
- <%= stylesheet_link_tag "application", :media => "all" %>
31
- <%= javascript_include_tag "application" %>
32
- <%= csrf_meta_tags %>
33
- </head>
34
- <body>
35
- <%= yield %>
36
- </body>
37
- </html>
38
- HTML
39
-
40
- INDEX = <<-HTML
41
- <h1>Hello, world!</h1>
42
- HTML
43
-
44
- class ApplicationController < ActionController::Base
45
- include Rails.application.routes.url_helpers
46
-
47
- layout 'application'
48
16
 
49
- self.view_paths = [ActionView::FixtureResolver.new(
50
- 'layouts/application.html.erb' => LAYOUT,
51
- 'application/index.html.erb' => INDEX
52
- )]
53
-
54
- def index
17
+ it 'does not log anything to STDOUT when initializing and sets the Hashie logger to the Rails logger' do
18
+ expect(stdout.string).to eq('')
19
+ expect(Hashie.logger).to eq(Rails.logger)
55
20
  end
56
- end
57
21
 
58
- RailsApp::Application.initialize!
59
-
60
- require 'hashie'
61
-
62
- RSpec.describe 'the Hashie logger' do
63
- it 'is set to the Rails logger' do
64
- expect(Hashie.logger).to eq(Rails.logger)
22
+ it 'works' do
23
+ get '/'
24
+ assert_select 'h1', 'Hello, world!'
65
25
  end
66
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashie
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.2
4
+ version: 3.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-02-10 00:00:00.000000000 Z
12
+ date: 2017-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -98,6 +98,7 @@ files:
98
98
  - lib/hashie/hash.rb
99
99
  - lib/hashie/logger.rb
100
100
  - lib/hashie/mash.rb
101
+ - lib/hashie/railtie.rb
101
102
  - lib/hashie/rash.rb
102
103
  - lib/hashie/trash.rb
103
104
  - lib/hashie/utils.rb
@@ -131,7 +132,12 @@ files:
131
132
  - spec/hashie/utils_spec.rb
132
133
  - spec/hashie/version_spec.rb
133
134
  - spec/hashie_spec.rb
135
+ - spec/integration/omniauth-oauth2/app.rb
136
+ - spec/integration/omniauth-oauth2/integration_spec.rb
137
+ - spec/integration/omniauth-oauth2/some_site.rb
138
+ - spec/integration/omniauth/app.rb
134
139
  - spec/integration/omniauth/integration_spec.rb
140
+ - spec/integration/rails/app.rb
135
141
  - spec/integration/rails/integration_spec.rb
136
142
  - spec/spec_helper.rb
137
143
  - spec/support/integration_specs.rb
@@ -192,7 +198,12 @@ test_files:
192
198
  - spec/hashie/utils_spec.rb
193
199
  - spec/hashie/version_spec.rb
194
200
  - spec/hashie_spec.rb
201
+ - spec/integration/omniauth/app.rb
195
202
  - spec/integration/omniauth/integration_spec.rb
203
+ - spec/integration/omniauth-oauth2/app.rb
204
+ - spec/integration/omniauth-oauth2/integration_spec.rb
205
+ - spec/integration/omniauth-oauth2/some_site.rb
206
+ - spec/integration/rails/app.rb
196
207
  - spec/integration/rails/integration_spec.rb
197
208
  - spec/spec_helper.rb
198
209
  - spec/support/integration_specs.rb