thoth 1.0.2 → 2.0.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
- SHA1:
3
- metadata.gz: 8849c5ed65bc945491752e39279303fb08180b56
4
- data.tar.gz: 6c09a31e1a61667f77cd859a827a9b7eca7f1e58
2
+ SHA256:
3
+ metadata.gz: cd988c8a0356cb7e895c099375de581868eece1f234ae362db17d287ee1dc521
4
+ data.tar.gz: ed3385f0d9eee202743492b598bc368bdf06b89da74d457c7916b0a6523d84be
5
5
  SHA512:
6
- metadata.gz: d56ff76b64f5b93b6ae1166700cd9c729a0dc9b1b53a830b60a14b76a5988cc42cab5adcf967d060c6367580d03e4f55c1a4f92aabd24fc481394770e419d78a
7
- data.tar.gz: b63b7c4be0e8de1c0feaf72b9fd45ba56d5ef0024a0334c60a114c7c74c377efde580650360fb33a077d8d59dffe4303bc6283349cb7e4ca6a90287d9a4e36c5
6
+ metadata.gz: c3204fd840e86c2023530c0179e66360b51b9c6468922cf860c47e97b6c9421661086b25864c26eb211239bfd83eb0295fb60c6d314d55b0484fe5627127e4fe
7
+ data.tar.gz: 9d495a5584ab882ab362d92d2120135b580dd3d548a0cb548408168fd21d87dc54fec668ae145ef9ce22cff53afe7726345355d93f0115a63237840d8c6f474c
@@ -37,7 +37,7 @@ module Thoth
37
37
  self.class.thoth_options[:only]
38
38
  end
39
39
 
40
- if only_options.empty? || !(only_options.map(&:to_s) & changes.keys).empty?
40
+ if only_options.empty? || !(only_options.map(&:to_s) & changed_attribute_names_to_save).empty?
41
41
  thoth_log_model(:update)
42
42
  end
43
43
  end
@@ -48,7 +48,11 @@ module Thoth
48
48
  end
49
49
 
50
50
  def thoth_log_model(action)
51
- Thoth.logger.log("#{self.class.name} #{action}", changes: changes, attributes: attributes)
51
+ Thoth.logger.log("#{self.class.name} #{action}", changes: changes_to_log, attributes: attributes)
52
+ end
53
+
54
+ def changes_to_log
55
+ has_changes_to_save? ? changes_to_save : saved_changes
52
56
  end
53
57
  end
54
58
  end
@@ -5,7 +5,7 @@ module Thoth
5
5
  class Railtie < ::Rails::Railtie
6
6
  initializer "thoth.configure_rails_initialization" do
7
7
  Thoth.logger ||= (
8
- file = File.open(::Rails.root.join(*%W[log events_#{ENV['RAILS_ENV']}.log]), 'a')
8
+ file = File.open(::Rails.root.join(*%W[log events_#{::Rails.env}.log]), 'a')
9
9
  file.sync = true
10
10
  Logger.new(Output::Json.new(file))
11
11
  )
data/lib/thoth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Thoth
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
data/spec/dummy/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '3.2.18'
3
+ gem 'rails', '5.1.7'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
@@ -10,17 +10,17 @@ gem 'sqlite3'
10
10
 
11
11
  # Gems used only for assets and not required
12
12
  # in production environments by default.
13
- group :assets do
14
- gem 'sass-rails', '~> 3.2.3'
15
- gem 'coffee-rails', '~> 3.2.1'
13
+ # group :assets do
14
+ # gem 'sass-rails', '~> 3.2.3'
15
+ # gem 'coffee-rails', '~> 3.2.1'
16
16
 
17
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18
- # gem 'therubyracer', :platforms => :ruby
17
+ # # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18
+ # # gem 'therubyracer', :platforms => :ruby
19
19
 
20
- gem 'uglifier', '>= 1.0.3'
21
- end
20
+ # gem 'uglifier', '>= 1.0.3'
21
+ # end
22
22
 
23
- gem 'jquery-rails'
23
+ # gem 'jquery-rails'
24
24
 
25
25
  gem 'thoth', path: File.join(File.dirname(__FILE__), %w[.. ..])
26
26
 
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,3 +1,3 @@
1
1
  class Car < ActiveRecord::Base
2
- attr_accessible :make, :model, :year
2
+ # attr_accessible :make, :model, :year
3
3
  end
@@ -1,5 +1,5 @@
1
1
  class Cat < ActiveRecord::Base
2
- attr_accessible :name, :breed
2
+ # attr_accessible :name, :breed
3
3
 
4
4
  def evil?
5
5
  true
@@ -1,3 +1,3 @@
1
1
  class Person < ActiveRecord::Base
2
- attr_accessible :name, :food, :color
2
+ # attr_accessible :name, :food, :color
3
3
  end
@@ -51,12 +51,14 @@ module Dummy
51
51
  # This will create an empty whitelist of attributes available for mass-assignment for all models
52
52
  # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
53
53
  # parameters by using an attr_accessible or attr_protected declaration.
54
- config.active_record.whitelist_attributes = true
54
+ # config.active_record.whitelist_attributes = true
55
55
 
56
56
  # Enable the asset pipeline
57
57
  config.assets.enabled = true
58
58
 
59
59
  # Version of your assets, change this if you want to expire all your assets
60
60
  config.assets.version = '1.0'
61
+
62
+ config.eager_load = false
61
63
  end
62
64
  end
@@ -23,11 +23,11 @@ Dummy::Application.configure do
23
23
  config.action_dispatch.best_standards_support = :builtin
24
24
 
25
25
  # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
26
+ # config.active_record.mass_assignment_sanitizer = :strict
27
27
 
28
28
  # Log the query plan for queries taking more than this (works
29
29
  # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
30
+ # config.active_record.auto_explain_threshold_in_seconds = 0.5
31
31
 
32
32
  # Do not compress assets
33
33
  config.assets.compress = false
@@ -30,7 +30,7 @@ Dummy::Application.configure do
30
30
  config.action_mailer.delivery_method = :test
31
31
 
32
32
  # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
33
+ # config.active_record.mass_assignment_sanitizer = :strict
34
34
 
35
35
  # Print deprecation notices to the stderr
36
36
  config.active_support.deprecation = :stderr
@@ -0,0 +1,17 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rails secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: a9fd55a1a5f8cceaa3e268109e1eaaff039f583d1c181285972943ecc50f7db1304482f74eecf6e03cb96eac1cb785b0115935050b76474dc02d8035de68fd96
15
+
16
+ test:
17
+ secret_key_base: 420f66fbeefc13c18e9850d3a1b1e27500d0a802619a8731de312ed7faffa419f5b76fa1d2b5b81d335f787f4e100ba2cef315a02a23026e33a2c940ad7fb0a2
@@ -23,7 +23,7 @@ describe ControllerWithThothContextController, type: :controller do
23
23
  context "on any action" do
24
24
  it "stores params in the Thoth.context" do
25
25
  get :show
26
- expect(assigns(:context)).to eq({"controller"=>"controller_with_thoth_context", "action"=>"show", "current_user"=>1})
26
+ expect(controller.view_context.assigns['context']).to eq({"controller"=>"controller_with_thoth_context", "action"=>"show", "current_user"=>1})
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -32,7 +32,7 @@ describe Thoth::Rails::Model do
32
32
  end
33
33
 
34
34
  context "on destroy" do
35
- let!(:person) { Person.create(name: 'Lee') }
35
+ let!(:person) { Person.create(name: 'Lee').reload }
36
36
 
37
37
  it "records the destroy event" do
38
38
  expect(Thoth).to receive(:logger).and_return(double(log: true))
@@ -45,7 +45,7 @@ describe Thoth::Rails::Model do
45
45
  log_events on: :update
46
46
  end
47
47
 
48
- let!(:cat) { Cat.create }
48
+ let!(:cat) { Cat.create.reload }
49
49
 
50
50
  it "does not record anything" do
51
51
  expect(Thoth).not_to receive(:logger)
@@ -55,11 +55,11 @@ describe Thoth::Rails::Model do
55
55
  end
56
56
 
57
57
  context "on update" do
58
- let!(:person) { Person.create(name: 'Lee') }
58
+ let!(:person) { Person.create(name: 'Lee').reload }
59
59
 
60
60
  it "records the update event" do
61
61
  expect(Thoth).to receive(:logger).and_return(double(log: true))
62
- person.update_attributes!(name: 'Smith')
62
+ person.update!(name: 'Smith')
63
63
  end
64
64
 
65
65
  context "when logging only changes to certain attribute" do
@@ -68,20 +68,20 @@ describe Thoth::Rails::Model do
68
68
  log_events only: :name
69
69
  end
70
70
 
71
- let!(:person) { PersonWithOnly.create(name: 'Lee') }
71
+ let!(:person) { PersonWithOnly.create(name: 'Lee').reload }
72
72
 
73
73
 
74
74
  context "and a watched attribute changes" do
75
75
  it "records the update event" do
76
76
  expect(Thoth).to receive(:logger).and_return(double(log: true))
77
- person.update_attributes!(name: 'Smith', color: :blue)
77
+ person.update!(name: 'Smith', color: :blue)
78
78
  end
79
79
  end
80
80
 
81
81
  context "and a watched attribute does not change" do
82
82
  it "does not record anything" do
83
83
  expect(Thoth).not_to receive(:logger)
84
- person.update_attributes!(color: :blue)
84
+ person.update!(color: :blue)
85
85
  end
86
86
  end
87
87
  end
@@ -92,11 +92,11 @@ describe Thoth::Rails::Model do
92
92
  log_events on: :destroy
93
93
  end
94
94
 
95
- let!(:car) { Car.create(make: 'Tesla', model: 'S') }
95
+ let!(:car) { Car.create(make: 'Tesla', model: 'S').reload }
96
96
 
97
97
  it "does not record anything" do
98
98
  expect(Thoth).not_to receive(:logger)
99
- car.update_attributes!(model: 'X')
99
+ car.update!(model: 'X')
100
100
  end
101
101
  end
102
102
  end
data/thoth.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Philippe Huibonhoa"]
10
10
  spec.email = ["phuibonhoa@gmail.com"]
11
11
  spec.summary = %q{Easy event logging for rails.}
12
- spec.homepage = "https://github.com/bkr/thoth"
12
+ spec.homepage = "https://github.com/phuibonhoa/thoth"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_dependency 'activesupport', ['>= 3.0']
20
+ spec.add_dependency 'activesupport', ['>= 5.1']
21
21
  spec.add_dependency 'request_store'
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency 'rails', '~> 3.2.18'
26
- spec.add_development_dependency 'rspec-rails', '~> 2.14'
25
+ spec.add_development_dependency 'rails', '>= 5.1'
26
+ spec.add_development_dependency 'rspec-rails', '>= 4.1.2'
27
27
  spec.add_development_dependency 'sqlite3'
28
28
  spec.add_development_dependency 'pry-remote'
29
29
  spec.add_development_dependency 'timecop'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thoth
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philippe Huibonhoa
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2021-05-11 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: '3.0'
19
+ version: '5.1'
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: '3.0'
26
+ version: '5.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: request_store
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.6'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.6'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -70,30 +70,30 @@ dependencies:
70
70
  name: rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 3.2.18
75
+ version: '5.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 3.2.18
82
+ version: '5.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-rails
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '2.14'
89
+ version: 4.1.2
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '2.14'
96
+ version: 4.1.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- description:
139
+ description:
140
140
  email:
141
141
  - phuibonhoa@gmail.com
142
142
  executables: []
@@ -161,6 +161,7 @@ files:
161
161
  - spec/dummy/Gemfile
162
162
  - spec/dummy/README.rdoc
163
163
  - spec/dummy/Rakefile
164
+ - spec/dummy/app/assets/config/manifest.js
164
165
  - spec/dummy/app/assets/images/rails.png
165
166
  - spec/dummy/app/assets/javascripts/application.js
166
167
  - spec/dummy/app/assets/stylesheets/application.css
@@ -188,6 +189,7 @@ files:
188
189
  - spec/dummy/config/initializers/wrap_parameters.rb
189
190
  - spec/dummy/config/locales/en.yml
190
191
  - spec/dummy/config/routes.rb
192
+ - spec/dummy/config/secrets.yml
191
193
  - spec/dummy/db/migrate/20140926015139_create_people.rb
192
194
  - spec/dummy/db/migrate/20140926022006_create_cars.rb
193
195
  - spec/dummy/db/migrate/20140926022112_create_cats.rb
@@ -223,11 +225,11 @@ files:
223
225
  - spec/thoth/rails/controller_context_spec.rb
224
226
  - spec/thoth/rails/model_spec.rb
225
227
  - thoth.gemspec
226
- homepage: https://github.com/bkr/thoth
228
+ homepage: https://github.com/phuibonhoa/thoth
227
229
  licenses:
228
230
  - MIT
229
231
  metadata: {}
230
- post_install_message:
232
+ post_install_message:
231
233
  rdoc_options: []
232
234
  require_paths:
233
235
  - lib
@@ -242,9 +244,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
244
  - !ruby/object:Gem::Version
243
245
  version: '0'
244
246
  requirements: []
245
- rubyforge_project:
246
- rubygems_version: 2.2.2
247
- signing_key:
247
+ rubygems_version: 3.0.3
248
+ signing_key:
248
249
  specification_version: 4
249
250
  summary: Easy event logging for rails.
250
251
  test_files:
@@ -252,6 +253,7 @@ test_files:
252
253
  - spec/dummy/Gemfile
253
254
  - spec/dummy/README.rdoc
254
255
  - spec/dummy/Rakefile
256
+ - spec/dummy/app/assets/config/manifest.js
255
257
  - spec/dummy/app/assets/images/rails.png
256
258
  - spec/dummy/app/assets/javascripts/application.js
257
259
  - spec/dummy/app/assets/stylesheets/application.css
@@ -279,6 +281,7 @@ test_files:
279
281
  - spec/dummy/config/initializers/wrap_parameters.rb
280
282
  - spec/dummy/config/locales/en.yml
281
283
  - spec/dummy/config/routes.rb
284
+ - spec/dummy/config/secrets.yml
282
285
  - spec/dummy/db/migrate/20140926015139_create_people.rb
283
286
  - spec/dummy/db/migrate/20140926022006_create_cars.rb
284
287
  - spec/dummy/db/migrate/20140926022112_create_cats.rb