firebug 1.0.0 → 1.1.0

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: d545d18663f423f86f0fc36abe0e816dd2a4c3ae
4
- data.tar.gz: dc8299e1e7b113809a310081455cba07adebf56a
3
+ metadata.gz: c7ae866f5a57fc4cd5782c1d42232a83b473541e
4
+ data.tar.gz: ea21d35182344dedc599830d373177714098963e
5
5
  SHA512:
6
- metadata.gz: c16a02261c7639885fce6f821cba409a8cf8fcb162004693482998a96a91784ea38a5bf56625b9a0037da8f2a5ad21fce0688c43411346f94dcda4e4299ebe37
7
- data.tar.gz: cf737fe94d2f8a12a232575990672d3de72ea5505fce1f6fa6311363f187e51409175cc809fde2ab808dba76ecbf760cac1b866fedaf422b1801cc2671552526
6
+ metadata.gz: 543016ca23566df1e2e76790e0c85688a30102851df90f137f19bbbed502141e1308576613768292d56c468bfd5bfbf6bb1abdd2d3d5a4a4b1f65642071ab6ca
7
+ data.tar.gz: b5776e9dbc85cb9f3b7e35984c4a2047fcc9b2484b467c100c2f48898671b4e57f256f054cee3bf3f8a3a927901bc78da98145d12ef7a254c6ffcb2e09235c1b
data/.circleci/config.yml CHANGED
@@ -25,12 +25,9 @@ restore_gems: &restore_gems
25
25
  - firebug-{{ checksum "Gemfile.lock" }}
26
26
 
27
27
  jobs:
28
- # Since a workspace can't persist the root of the working directory we are using the caching mechanism to save
29
- # the repository.
30
28
  checkout-code:
31
29
  <<: *defaults
32
30
  steps:
33
- - *restore_repo
34
31
  - checkout
35
32
  - save_cache:
36
33
  key: repo-{{ .Branch }}-{{ .Revision }}
@@ -45,10 +42,9 @@ jobs:
45
42
  - run:
46
43
  name: Install Bundler dependencies
47
44
  command: |
48
- bin/bundle install --deployment \
49
- --path=vendor/bundle \
50
- --jobs=4 \
51
- --retry=3
45
+ bin/bundle install --path=vendor/bundle \
46
+ --jobs=4 \
47
+ --retry=3
52
48
  - save_cache:
53
49
  key: firebug-{{ checksum "Gemfile.lock" }}
54
50
  paths:
@@ -66,22 +62,15 @@ jobs:
66
62
  - *attach_workspace
67
63
  - run:
68
64
  name: Set bundler path
69
- command: bundle --path vendor/bundle
70
- - run:
71
- name: Setup Code Climate test-reporter
72
- command: |
73
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
74
- chmod +x ./cc-test-reporter
65
+ command: bin/bundle --path vendor/bundle
75
66
  - run:
76
67
  name: Run tests
77
68
  command: |
78
- ./cc-test-reporter before-build
79
69
  bin/bundle exec rspec --profile 10 \
80
70
  --format RspecJunitFormatter \
81
71
  --out test_results/rspec.xml \
82
72
  --format progress \
83
73
  $(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)
84
- ./cc-test-reporter after-build -t simplecov coverage/.resultset.json
85
74
  - store_test_results:
86
75
  path: test_results
87
76
  - store_artifacts:
@@ -97,11 +86,11 @@ jobs:
97
86
  - *restore_repo
98
87
  - *attach_workspace
99
88
  - run:
100
- name: Install rubocop
101
- command: gem install rubocop rubocop-rspec
89
+ name: Set bundler path
90
+ command: bin/bundle --path vendor/bundle
102
91
  - run:
103
92
  name: Run rubocop
104
- command: rubocop -c .rubocop.yml
93
+ command: bin/bundle exec rubocop
105
94
 
106
95
  workflows:
107
96
  version: 2
@@ -113,8 +102,7 @@ workflows:
113
102
  - checkout-code
114
103
  - run-rubocop:
115
104
  requires:
116
- - checkout-code
105
+ - bundle-dependencies
117
106
  - run-specs:
118
107
  requires:
119
108
  - bundle-dependencies
120
- - run-rubocop
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Firebug [![CircleCI](https://circleci.com/gh/rvshare/firebug.svg?style=svg)](https://circleci.com/gh/rvshare/firebug)
2
+ [![Gem Version](https://badge.fury.io/rb/firebug.svg)](https://badge.fury.io/rb/firebug)
2
3
 
3
4
  A gem for working with CodeIgniter sessions in ruby.
4
5
 
@@ -83,7 +84,7 @@ version, push git commits and tags, and push the `.gem`file to
83
84
  ## Contributing
84
85
 
85
86
  Bug reports and pull requests are welcome on GitHub at
86
- [https://github.com/afrase/firebug](https://github.com/afrase/firebug.)
87
+ [https://github.com/rvshare/firebug](https://github.com/rvshare/firebug).
87
88
 
88
89
  ## License
89
90
 
data/firebug.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec| # rubocop:disable BlockLength
28
28
  spec.add_dependency 'activerecord', '~> 5.0'
29
29
  spec.add_dependency 'ruby-mcrypt', '~> 0.2'
30
30
 
31
- spec.add_development_dependency 'bundler', '~> 1.16'
31
+ spec.add_development_dependency 'bundler', '~> 1.15'
32
32
  spec.add_development_dependency 'database_cleaner', '~> 1.6', '>= 1.6.2'
33
33
  spec.add_development_dependency 'pry', '~> 0.11.3'
34
34
  spec.add_development_dependency 'rake', '~> 12.3'
@@ -7,6 +7,8 @@ module ActionDispatch
7
7
  module Session
8
8
  # A session store for Rails to handle Pyro sessions.
9
9
  class CodeIgniterStore < AbstractStore
10
+ SESSION_RECORD_KEY = 'rack.session.record'
11
+
10
12
  # @param [Object] app
11
13
  # @param [Hash] options
12
14
  # @option options [String] :key ('default_pyrocms') The session cookie name.
@@ -26,10 +28,13 @@ module ActionDispatch
26
28
  # @param [String] sid
27
29
  # @return [Array<String, Hash>]
28
30
  def find_session(req, sid)
29
- model = find_session_model(req, sid)
30
- # +Rack::Session::Abstract::Persisted#load_session+ expects this to return an Array with the first value being
31
- # the session ID and the second the actual session data.
32
- [model.session_id, model.user_data]
31
+ silence_logger(req) do
32
+ model = find_session_model(req, sid)
33
+ req.env[SESSION_RECORD_KEY] = model
34
+ # +Rack::Session::Abstract::Persisted#load_session+ expects this to return an Array with the first value being
35
+ # the session ID and the second the actual session data.
36
+ [model.session_id, model.user_data]
37
+ end
33
38
  end
34
39
 
35
40
  # Should the session be persisted?
@@ -63,17 +68,20 @@ module ActionDispatch
63
68
  # @param [Hash] _options
64
69
  # @return [String] encrypted and base64 encoded string of the session data.
65
70
  def write_session(req, sid, session, _options)
66
- model = find_session_model(req, sid)
67
- model_params = {
68
- session_id: model.session_id,
69
- user_agent: req.user_agent || '', # user_agent can't be null
70
- ip_address: req.remote_ip || '', # ip_address can't be null
71
- user_data: session
72
- }
73
- # Returning false will cause Rack to output a warning.
74
- return false unless model.update(model_params)
75
- # Return the encrypted cookie format of the data. Rack sets this value as the cookie in the response
76
- model.cookie_data
71
+ silence_logger(req) do
72
+ model = find_session_model(req, sid)
73
+ model_params = {
74
+ session_id: model.session_id,
75
+ user_agent: req.user_agent || '', # user_agent can't be null
76
+ ip_address: req.remote_ip || '', # ip_address can't be null
77
+ user_data: session
78
+ }
79
+ # Returning false will cause Rack to output a warning.
80
+ return false unless model.update(model_params)
81
+ req.env[SESSION_RECORD_KEY] = model
82
+ # Return the encrypted cookie format of the data. Rack sets this value as the cookie in the response
83
+ model.cookie_data
84
+ end
77
85
  end
78
86
 
79
87
  # Deletes then creates a new session in the database.
@@ -87,11 +95,14 @@ module ActionDispatch
87
95
  # @param [Hash] options
88
96
  # @return [String] the new session id
89
97
  def delete_session(req, sid, options)
90
- # Get the current database record for this session then delete it.
91
- find_session_model(req, sid).delete
92
- return if options[:drop]
93
- # Generate a new one and return it's ID
94
- find_session_model(req).tap { |s| s.save if options[:renew] }.session_id
98
+ silence_logger(req) do
99
+ # Get the current database record for this session then delete it.
100
+ find_session_model(req, sid).delete
101
+ return if options[:drop]
102
+ req.env[SESSION_RECORD_KEY] = nil
103
+ # Generate a new one and return it's ID
104
+ find_session_model(req).tap { |s| s.save if options[:renew] }.session_id
105
+ end
95
106
  end
96
107
 
97
108
  # Tries to find the session ID in the requests cookies.
@@ -116,7 +127,7 @@ module ActionDispatch
116
127
  # @return [Firebug::Session]
117
128
  def find_session_model(req, sid=nil)
118
129
  if sid
119
- model = Firebug::Session.find_by(find_by_params(req, sid))
130
+ model = req.env[SESSION_RECORD_KEY] || Firebug::Session.find_by(find_by_params(req, sid))
120
131
  return model if model
121
132
  # use a different session ID in case the reason for not finding the record is because the user_agent
122
133
  # or ip_address didn't match.
@@ -142,6 +153,16 @@ module ActionDispatch
142
153
  end
143
154
  params
144
155
  end
156
+
157
+ # @param [ActionDispatch::Request] req
158
+ def silence_logger(req)
159
+ logger = req.env['action_dispatch.logger'] || ActiveRecord::Base.logger
160
+ if logger && Firebug.config.silence_logger
161
+ logger.silence { yield }
162
+ else
163
+ yield
164
+ end
165
+ end
145
166
  end
146
167
  end
147
168
  end
@@ -13,6 +13,8 @@ module Firebug
13
13
  # Use the user-agent in addition to the session ID.
14
14
  # @attr [Boolean] match_ip_address
15
15
  # Use the remote ip address in addition to the session ID.
16
+ # @attr [Boolean] silence_logger
17
+ # Silence ActiveRecord logs.
16
18
  # @attr [Proc] session_filter
17
19
  # Return true if this request should have it's session written.
18
20
  # @see ActionDispatch::Session::CodeIgniterStore#commit_session?
@@ -24,11 +26,13 @@ module Firebug
24
26
  attr_accessor :match_user_agent
25
27
  attr_accessor :match_ip_address
26
28
  attr_accessor :session_filter
29
+ attr_accessor :silence_logger
27
30
 
28
31
  def initialize
29
32
  self.truncate_user_agent = false
30
33
  self.match_user_agent = false
31
34
  self.match_ip_address = false
35
+ self.silence_logger = true
32
36
  # default to always writing the session
33
37
  self.session_filter = ->(_) { true }
34
38
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Firebug
4
4
  # The current version of Firebug
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Frase
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-28 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.16'
61
+ version: '1.15'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.16'
68
+ version: '1.15'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: database_cleaner
71
71
  requirement: !ruby/object:Gem::Requirement