changed 0.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9811b29b82154768e261bd90c16604ab7cb1c741eb45ad91cc4a4fe963e23be
4
- data.tar.gz: 8c8b3993c740fc868e200842fda818710dc74f05a8f38668582ae4026c833f8f
3
+ metadata.gz: a624358bc74adfc4ce845ae502cc8a573c2ef90c8f070eaeb196d978c641996b
4
+ data.tar.gz: 72a7e53ffc9530e7d1d28f5616716e491f8bb9d35e9c48a399c5929c9ac87a60
5
5
  SHA512:
6
- metadata.gz: 8b5007282b58dbc1c4d36b96f73d4369b126e392b6950fbcc327ebbbf2841005232ee0f70b453cb52f4dc85c2a627119f299e12fd70d54b2a91ed9afe13e7eec
7
- data.tar.gz: 22405f5a0d3e2b96f5e3b77823cc4725fe622cf0b888811a317cfde55c887e45f9e144a505be092de7317cd24c2547044e3d648033955ebfd4c8b31bc85a64d1
6
+ metadata.gz: c7daffb97f36da1931a52d6c6536d2c8221d959c73941e6a72585f6f24a1121615fb64d03d6f2457532a4d0f1b001fffc1a04a0e20f54db65fd52e03352cd0ee
7
+ data.tar.gz: e272cf28d5f7b674c69411ad5984589caf47e2216576d005412ef8397f631a5dbf487a5894f3e2ca2a10d39f5f81a68d0ec3d10df155ce17f516df443d649415
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Clutter
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Changed
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/changed`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/changed.svg)](https://badge.fury.io/rb/changed)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ A gem for tracking what **changed** when.
6
6
 
7
7
  ## Installation
8
8
 
@@ -14,22 +14,105 @@ gem 'changed'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ ```bash
18
+ $ bundle
19
+ ```
18
20
 
19
21
  Or install it yourself as:
20
22
 
21
- $ gem install changed
23
+ ```bash
24
+ $ gem install changed
25
+ ```
26
+
27
+ After installing the gem run the following to setup:
28
+
29
+ ```bash
30
+ rails changed:install:migrations
31
+ rails db:migrate
32
+ ```
22
33
 
23
34
  ## Usage
24
35
 
25
- TODO: Write usage instructions here
36
+ This gem is designed to integrate with active record objects:
37
+
38
+ ```ruby
39
+ class Employee
40
+ include Changed::Auditable
41
+ belongs_to :company
42
+
43
+ audited :name, :email, :eid, :company, transformations: { eid: 'Employee ID' }
44
+ end
45
+ ```
46
+
47
+ To ensure the proper 'changer' is tracked, add the following code to your application controller:
48
+
49
+ ```ruby
50
+ before_action :configure_audit_changer
51
+
52
+ protected
53
+
54
+ def configure_audit_changer
55
+ Changed.changer = User.current
56
+ end
57
+ ```
26
58
 
27
- ## Development
59
+ To execute code with a different timestamp or changer, use the following:
60
+
61
+ ```ruby
62
+ employee = Employee.find_by(name: "...")
63
+ Changed.perform(changer: User.current, timestamp: Time.now) do
64
+ employee.name = "..."
65
+ employee.save!
66
+ end
67
+ ```
68
+
69
+ ### Fields
70
+
71
+ Fields (i.e. name, email, phone, etc) are tracked inside the `changeset` key of a generated audit. They can be queried using:
72
+
73
+ ```sql
74
+ SELECT
75
+ "audits"."timestamp",
76
+ "audits"."changeset"->'name'->>0 AS "was",
77
+ "audits"."changeset"->'name'->>1 AS "now",
78
+ "changers"."name" AS "changer"
79
+ FROM "audits"
80
+ JOIN "users" AS "changers" ON "audits"."changer_id" = "changers"."id" AND "audits"."changer_type" = 'User'
81
+ WHERE "audits"."changeset"->>'name' IS NOT NULL
82
+ ```
83
+
84
+ ### Associations
85
+
86
+ Associations (i.e. user, favourites, etc) are tracked by the `associations` table. They can be queried using:
87
+
88
+ ```sql
89
+ SELECT
90
+ "audits"."timestamp",
91
+ "changers"."name" AS "changer",
92
+ CASE "associations"."kind"
93
+ WHEN '0' THEN 'ADD'
94
+ WHEN '1' THEN 'REMOVE'
95
+ END AS "kind",
96
+ "users"."name" AS "user"
97
+ FROM "audits"
98
+ JOIN "associations" ON "associations"."audit_id" = "audits"."id"
99
+ JOIN "users" ON "associations"."associated_id" = "users"."id" AND "associations"."associated_type" = 'User'
100
+ JOIN "users" AS "changers" ON "audits"."changer_id" = "changers"."id" AND "audits"."changer_type" = 'User'
101
+ WHERE "associations"."name" = 'user'
102
+ ```
103
+
104
+ ## Configuration
105
+
106
+ Specifying `default_changer_proc` gives a changer if one cannot be inferred otherwise:
107
+
108
+ ```ruby
109
+ Changed.config.default_changer_proc = ->{ User.system }
110
+ ```
28
111
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
112
+ ## Status
30
113
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
114
+ [![CircleCI](https://circleci.com/gh/clutter/changed.svg?style=svg&circle-token=77cf2fadb88cfc6b16bf85643826152305dac75f)](https://circleci.com/gh/clutter/changed)
32
115
 
33
- ## Contributing
116
+ ## License
34
117
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/changed.
118
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,6 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/setup'
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ APP_RAKEFILE = File.expand_path('../spec/dummy/Rakefile', __FILE__)
6
+
7
+ load 'rails/tasks/engine.rake'
8
+ load 'rails/tasks/statistics.rake'
3
9
 
4
10
  RSpec::Core::RakeTask.new(:spec)
5
11
 
6
- task :default => :spec
12
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ module Changed
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ module Changed
2
+ class Association < ApplicationRecord
3
+ belongs_to :audit, class_name: 'Changed::Audit'
4
+ belongs_to :associated, polymorphic: true
5
+
6
+ enum :kind, %i[add remove]
7
+
8
+ validates :name, presence: true
9
+
10
+ scope :ordered, -> { order(id: :desc) }
11
+ end
12
+ end
@@ -0,0 +1,109 @@
1
+ module Changed
2
+ class Audit < ApplicationRecord
3
+ module Event
4
+ CREATE = 'create'.freeze
5
+ UPDATE = 'update'.freeze
6
+ end
7
+
8
+ EVENTS = [
9
+ Event::CREATE,
10
+ Event::UPDATE,
11
+ ].freeze
12
+
13
+ belongs_to :changer, polymorphic: true, required: false
14
+ belongs_to :audited, polymorphic: true
15
+ has_many :associations, dependent: :destroy, class_name: 'Changed::Association'
16
+
17
+ scope :optimized, -> { preload(:changer, :audited, associations: :associated) }
18
+ scope :ordered, -> { order(id: :desc) }
19
+ scope :creates, -> { where(event: Event::CREATE) }
20
+ scope :updates, -> { where(event: Event::UPDATE) }
21
+
22
+ validates :event, inclusion: { in: EVENTS }
23
+ validates :audited, presence: true
24
+
25
+ scope :for, ->(audited) { where(audited: audited).ordered }
26
+
27
+ after_initialize -> { self.timestamp ||= Changed.timestamp || Time.now }
28
+
29
+ def fields
30
+ changeset.map do |name, value|
31
+ was, now = value
32
+ Field.new(was, now, transform(name))
33
+ end
34
+ end
35
+
36
+ def relationships
37
+ memo = {}
38
+ associations.each do |association|
39
+ memo[association.name] ||= Set.new
40
+ memo[association.name] << association
41
+ end
42
+ memo.map do |name, associations|
43
+ Relationship.new(associations, transform(name))
44
+ end
45
+ end
46
+
47
+ def track(event, fields)
48
+ self.changer = Changed.changer
49
+
50
+ fields.each do |attribute|
51
+ attribute = String(attribute)
52
+ if audited.saved_change_to_attribute?(attribute)
53
+ changeset[attribute] = audited.saved_change_to_attribute(attribute)
54
+ end
55
+ end
56
+
57
+ self.event = event
58
+ end
59
+
60
+ def anything?
61
+ changeset.any? || associations.any?
62
+ end
63
+
64
+ def changed?(key)
65
+ fields.map(&:name).include?(key)
66
+ end
67
+
68
+ # The 'change' provided needs to be a block, lambda, or proc that executes
69
+ # the changes. The other provided block is yielded pre and post the change.
70
+ def track_attribute_change(attribute, change)
71
+ attribute_was = yield
72
+ change.call
73
+ attribute_now = yield
74
+
75
+ return if attribute_was == attribute_now
76
+
77
+ changeset[String(attribute)] = [
78
+ attribute_was,
79
+ attribute_now,
80
+ ]
81
+ end
82
+
83
+ def track_association_change(name, change)
84
+ association_was = yield
85
+ change.call
86
+ association_now = yield
87
+ return if association_was == association_now
88
+
89
+ (association_was - association_now).each do |associated|
90
+ associations.build(name: name, associated: associated, kind: :remove)
91
+ end
92
+ (association_now - association_was).each do |associated|
93
+ associations.build(name: name, associated: associated, kind: :add)
94
+ end
95
+ end
96
+
97
+ private
98
+
99
+ def transform(name)
100
+ (transformations[name] if transformations) || name
101
+ end
102
+
103
+ def transformations
104
+ @transformations = audited.class.auditable[:transformations] unless defined?(@transformations)
105
+ @transformations
106
+ end
107
+
108
+ end
109
+ end
@@ -0,0 +1,13 @@
1
+ class CreateChangedAudits < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :changed_audits do |t|
4
+ t.references :changer, polymorphic: true, null: true, index: true
5
+ t.references :audited, polymorphic: true, null: false, index: true
6
+ t.jsonb :changeset, default: {}, null: false
7
+ t.string :event, null: false
8
+ t.datetime :timestamp, null: false
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class CreateChangedAssociations < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :changed_associations do |t|
4
+ t.references :audit, null: false, index: true
5
+ t.references :associated, null: false, polymorphic: true, index: true
6
+ t.string :name, null: false
7
+ t.integer :kind, null: false
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_foreign_key :changed_associations, :changed_audits, column: :audit_id
13
+ end
14
+ end
@@ -0,0 +1,51 @@
1
+ require 'active_support/concern'
2
+
3
+ module Changed
4
+ module Auditable
5
+ extend ActiveSupport::Concern
6
+
7
+ # ==== Overview
8
+ #
9
+ # A helper that caches an audit between operations. Once an audit is persisted this method handles the generation
10
+ # of a new audit, thus ensuring that each transaction is audited separately.
11
+ def audit
12
+ @audit = Audit.new(audited: self) if @audit.nil? || @audit.persisted?
13
+ @audit
14
+ end
15
+
16
+ included do
17
+ has_many :audits, -> { ordered }, as: :audited, class_name: 'Changed::Audit', dependent: :destroy
18
+
19
+ # ==== Overview
20
+ #
21
+ # A helper for setting up options.
22
+ #
23
+ def self.auditable
24
+ @auditable ||= {}
25
+ end
26
+
27
+ # ==== Overview
28
+ #
29
+ # A concern for setting up auditable for a model. An audited model can track the changes to attributes
30
+ # (ints, bools, strings, dates, times) or associations (`has_many`, `belongs_to`, `has_and_belongs_to_many`).
31
+ #
32
+ # The `audit` call needs to be placed after all `has_many`, `belongs_to`, `has_and_belongs_to_many` declarations
33
+ # in order for the association reflection to work. Multiple inclusions of `audit` are not supported.
34
+ #
35
+ # ==== Options
36
+ #
37
+ # * +:keys:+ - An array of symbols for the attributes or associations that are tracked with each audit.
38
+ # * +:transformations:+ - A hash of of attribute name mappings (i.e. 'number' to '#' or 'user' to 'rep').
39
+ #
40
+ # ==== Usage
41
+ #
42
+ # audit(:number, :scheduled, :region, :address, :items, transformations: { number: "#", user: "rep" })
43
+ #
44
+ def self.audited(*keys, transformations: nil)
45
+ auditable[:transformations] = ActiveSupport::HashWithIndifferentAccess.new(transformations) if transformations
46
+ Builder.build(self, *keys)
47
+ end
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,141 @@
1
+ module Changed
2
+ class Builder # rubocop:disable Metrics/ClassLength
3
+ class ArgumentError < ::ArgumentError
4
+ end
5
+
6
+ ARGUMENT_ERROR_EMPTY_KEYS_MESSAGE = 'audited requires specifying a splat of keys'.freeze
7
+
8
+ def self.build(*args)
9
+ new(*args).build
10
+ end
11
+
12
+ def initialize(klass, *keys)
13
+ raise ArgumentError, ARGUMENT_ERROR_EMPTY_KEYS_MESSAGE if keys.empty?
14
+
15
+ @klass = klass
16
+ @keys = keys
17
+ end
18
+
19
+ def build
20
+ define_callbacks_for_associations
21
+ define_after_create_callback
22
+ define_after_update_callback
23
+ end
24
+
25
+ private
26
+
27
+ def define_callbacks_for_associations
28
+ @keys.each do |key|
29
+ association = @klass.reflect_on_association(key)
30
+ case association
31
+ when ActiveRecord::Reflection::HasManyReflection,
32
+ ActiveRecord::Reflection::HasAndBelongsToManyReflection,
33
+ ActiveRecord::Reflection::ThroughReflection
34
+ define_callbacks_for_has_many(association)
35
+ when ActiveRecord::Reflection::BelongsToReflection
36
+ define_callbacks_for_belongs_to(association)
37
+ when ActiveRecord::Reflection::HasOneReflection
38
+ define_callbacks_for_has_one(association)
39
+ end
40
+ end
41
+ end
42
+
43
+ def after_create_or_update_for_belongs_to_callback(key, foreign_key, foreign_type, class_name)
44
+ proc do |resource|
45
+ was_associated_id, now_associated_id = resource.saved_change_to_attribute(foreign_key)
46
+ was_associated_type, now_associated_type = resource.saved_change_to_attribute(foreign_type)
47
+ associated_type = resource[foreign_type] || class_name
48
+
49
+ if was_associated_id
50
+ resource.audit.associations.build(
51
+ name: key,
52
+ kind: :remove, associated_id: was_associated_id, associated_type: was_associated_type || associated_type
53
+ )
54
+ end
55
+
56
+ if now_associated_id
57
+ resource.audit.associations.build(
58
+ name: key, kind: :add,
59
+ associated_id: now_associated_id, associated_type: now_associated_type || associated_type
60
+ )
61
+ end
62
+ end
63
+ end
64
+
65
+ def define_callbacks_for_belongs_to(association)
66
+ callback = after_create_or_update_for_belongs_to_callback(
67
+ association.name,
68
+ association.foreign_key,
69
+ association.foreign_type,
70
+ association.class_name
71
+ )
72
+
73
+ @klass.after_update callback
74
+ @klass.after_create callback
75
+ end
76
+
77
+ def before_add_for_has_many_callback(name)
78
+ proc do |_method, resource, associated|
79
+ resource.audit.associations.build(name: name, associated: associated, kind: :add)
80
+ end
81
+ end
82
+
83
+ def before_remove_for_has_many_callback(name)
84
+ proc do |_method, resource, associated|
85
+ resource.audit.associations.build(name: name, associated: associated, kind: :remove)
86
+ end
87
+ end
88
+
89
+ def define_callbacks_for_has_many(association)
90
+ name = association.name
91
+
92
+ # Ensure callback arrays exist before appending to them
93
+ initialize_association_callbacks(association.name)
94
+
95
+ @klass.send(:"before_add_for_#{association.name}") << before_add_for_has_many_callback(name)
96
+ @klass.send(:"before_remove_for_#{association.name}") << before_remove_for_has_many_callback(name)
97
+ end
98
+
99
+ def define_callbacks_for_has_one(association)
100
+ raise ArgumentError, "unsupported reflection '#{association.name}'"
101
+ end
102
+
103
+ def initialize_association_callbacks(association_name)
104
+ # Initialize callback arrays if they don't exist
105
+ before_add_callback_name = :"before_add_for_#{association_name}"
106
+ before_remove_callback_name = :"before_remove_for_#{association_name}"
107
+
108
+ # rubocop:disable Style/GuardClause
109
+ unless @klass.respond_to?(before_add_callback_name)
110
+ @klass.class_eval do
111
+ class_attribute before_add_callback_name, instance_writer: false, default: []
112
+ end
113
+ end
114
+
115
+ unless @klass.respond_to?(before_remove_callback_name)
116
+ @klass.class_eval do
117
+ class_attribute before_remove_callback_name, instance_writer: false, default: []
118
+ end
119
+ end
120
+ # rubocop:enable Style/GuardClause
121
+ end
122
+
123
+ def define_after_create_callback
124
+ keys = @keys
125
+ @klass.after_create do |resource|
126
+ audit = resource.audit
127
+ audit.track(Audit::Event::CREATE, keys)
128
+ audit.save! if audit.anything?
129
+ end
130
+ end
131
+
132
+ def define_after_update_callback
133
+ keys = @keys
134
+ @klass.after_update do |resource|
135
+ audit = resource.audit
136
+ audit.track(Audit::Event::UPDATE, keys)
137
+ audit.save! if audit.anything?
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,5 @@
1
+ module Changed
2
+ class Config
3
+ attr_accessor :default_changer_proc
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ module Changed
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Changed
4
+
5
+ config.generators do |generator|
6
+ generator.test_framework :rspec
7
+ generator.fixture_replacement :factory_bot, dir: 'spec/factories'
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Changed
2
- VERSION = "0.0.1"
2
+ VERSION = '2.0.0'.freeze
3
3
  end
data/lib/changed.rb CHANGED
@@ -1,5 +1,88 @@
1
- require "changed/version"
1
+ require 'request_store'
2
+
3
+ require 'changed/auditable'
4
+ require 'changed/builder'
5
+ require 'changed/config'
6
+ require 'changed/engine'
2
7
 
3
8
  module Changed
4
- # Your code goes here...
9
+ Field = Struct.new(:was, :now, :name)
10
+ Relationship = Struct.new(:associations, :name)
11
+
12
+ # Access the library configuration.
13
+ #
14
+ # ==== Examples
15
+ #
16
+ # Changed.config.default_changer_proc = ->{ User.system }
17
+ def self.config
18
+ @config ||= Config.new
19
+ end
20
+
21
+ # Access the timestamp (this value is set as the timestamp within an audit and defaults to now).
22
+ def self.timestamp
23
+ options[:timestamp] || Time.now
24
+ end
25
+
26
+ # Customize the timestamp (uses a request store to only change lifeycle event).
27
+ #
28
+ # ==== Attributes
29
+ #
30
+ # * +timestamp+ - A timestamp to use.
31
+ #
32
+ # ==== Examples
33
+ #
34
+ # Changed.timestamp = 2.hours.ago
35
+ def self.timestamp=(timestamp)
36
+ options[:timestamp] = timestamp
37
+ end
38
+
39
+ # Access the changer (this value is set as the changer within an audit and defaults to config).
40
+ def self.changer
41
+ options[:changer] || config.default_changer_proc&.call
42
+ end
43
+
44
+ # Customize the changer (uses a request store to only change lifeycle event).
45
+ #
46
+ # ==== Attributes
47
+ #
48
+ # * +changer+ - A changer to use.
49
+ #
50
+ # ==== Examples
51
+ #
52
+ # Changed.changer = User.current
53
+ def self.changer=(changer)
54
+ options[:changer] = changer
55
+ end
56
+
57
+ # Perform a block with custom override options.
58
+ #
59
+ # ==== Attributes
60
+ #
61
+ # * +options+ - Values for the changer and / or timestamp.
62
+ # * +block+ - Some code to run with the new options.
63
+ #
64
+ # ==== Examples
65
+ #
66
+ # Changed.perform(changer: User.system, timestamp: 2.hours.ago) do
67
+ # widget.name = "Sprocket"
68
+ # widget.save!
69
+ # end
70
+ def self.perform(options = {}, &block)
71
+ backup = self.options
72
+ self.options = options
73
+ block.call
74
+ ensure
75
+ self.options = backup
76
+ end
77
+
78
+ OPTIONS_REQUEST_STORE_KEY = :changed_options
79
+ private_constant :OPTIONS_REQUEST_STORE_KEY
80
+
81
+ def self.options=(options)
82
+ RequestStore.store[OPTIONS_REQUEST_STORE_KEY] = options
83
+ end
84
+
85
+ def self.options
86
+ RequestStore.store[OPTIONS_REQUEST_STORE_KEY] ||= {}
87
+ end
5
88
  end
metadata CHANGED
@@ -1,79 +1,215 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: changed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre
8
- autorequire:
9
- bindir: exe
8
+ autorequire:
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-15 00:00:00.000000000 Z
11
+ date: 2025-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 7.1.5.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '9.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 7.1.5.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '9.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: request_store
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: brakeman
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
13
61
  - !ruby/object:Gem::Dependency
14
62
  name: bundler
15
63
  requirement: !ruby/object:Gem::Requirement
16
64
  requirements:
17
- - - "~>"
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: byebug
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: factory_bot_rails
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
18
94
  - !ruby/object:Gem::Version
19
- version: '1.16'
95
+ version: '0'
20
96
  type: :development
21
97
  prerelease: false
22
98
  version_requirements: !ruby/object:Gem::Requirement
23
99
  requirements:
24
- - - "~>"
100
+ - - ">="
25
101
  - !ruby/object:Gem::Version
26
- version: '1.16'
102
+ version: '0'
27
103
  - !ruby/object:Gem::Dependency
28
- name: rake
104
+ name: pg
29
105
  requirement: !ruby/object:Gem::Requirement
30
106
  requirements:
31
- - - "~>"
107
+ - - ">="
32
108
  - !ruby/object:Gem::Version
33
- version: '10.0'
109
+ version: '0'
34
110
  type: :development
35
111
  prerelease: false
36
112
  version_requirements: !ruby/object:Gem::Requirement
37
113
  requirements:
38
- - - "~>"
114
+ - - ">="
39
115
  - !ruby/object:Gem::Version
40
- version: '10.0'
116
+ version: '0'
41
117
  - !ruby/object:Gem::Dependency
42
- name: rspec
118
+ name: rspec_junit_formatter
43
119
  requirement: !ruby/object:Gem::Requirement
44
120
  requirements:
45
- - - "~>"
121
+ - - ">="
46
122
  - !ruby/object:Gem::Version
47
- version: '3.0'
123
+ version: '0'
48
124
  type: :development
49
125
  prerelease: false
50
126
  version_requirements: !ruby/object:Gem::Requirement
51
127
  requirements:
52
- - - "~>"
128
+ - - ">="
53
129
  - !ruby/object:Gem::Version
54
- version: '3.0'
55
- description:
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rspec-rails
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rubocop
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: shoulda-matchers
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :development
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ version: '0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: simplecov
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - ">="
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ description: "⏱"
56
188
  email:
57
- - kevin@ksylvest.com
189
+ - kevin@clutter.com
58
190
  executables: []
59
191
  extensions: []
60
192
  extra_rdoc_files: []
61
193
  files:
62
- - ".gitignore"
63
- - ".rspec"
64
- - ".travis.yml"
65
- - Gemfile
194
+ - LICENSE
66
195
  - README.md
67
196
  - Rakefile
68
- - bin/console
69
- - bin/setup
70
- - changed.gemspec
197
+ - app/models/changed/application_record.rb
198
+ - app/models/changed/association.rb
199
+ - app/models/changed/audit.rb
200
+ - db/migrate/20180213015838_create_changed_audits.rb
201
+ - db/migrate/20180213015849_create_changed_associations.rb
71
202
  - lib/changed.rb
203
+ - lib/changed/auditable.rb
204
+ - lib/changed/builder.rb
205
+ - lib/changed/config.rb
206
+ - lib/changed/engine.rb
72
207
  - lib/changed/version.rb
73
- homepage:
74
- licenses: []
208
+ homepage: https://github.com/clutter/changed
209
+ licenses:
210
+ - MIT
75
211
  metadata: {}
76
- post_install_message:
212
+ post_install_message:
77
213
  rdoc_options: []
78
214
  require_paths:
79
215
  - lib
@@ -81,16 +217,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
217
  requirements:
82
218
  - - ">="
83
219
  - !ruby/object:Gem::Version
84
- version: '0'
220
+ version: 3.0.0
85
221
  required_rubygems_version: !ruby/object:Gem::Requirement
86
222
  requirements:
87
223
  - - ">="
88
224
  - !ruby/object:Gem::Version
89
225
  version: '0'
90
226
  requirements: []
91
- rubyforge_project:
92
- rubygems_version: 2.7.6
93
- signing_key:
227
+ rubygems_version: 3.4.10
228
+ signing_key:
94
229
  specification_version: 4
95
- summary: A simple gem for change tracking.
230
+ summary: Provides insights into what changed.
96
231
  test_files: []
data/.gitignore DELETED
@@ -1,11 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in changed.gemspec
6
- gemspec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "changed"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/changed.gemspec DELETED
@@ -1,24 +0,0 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "changed/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "changed"
8
- spec.version = Changed::VERSION
9
- spec.authors = ["Kevin Sylvestre"]
10
- spec.email = ["kevin@ksylvest.com"]
11
-
12
- spec.summary = %q{A simple gem for change tracking.}
13
-
14
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
- f.match(%r{^(test|spec|features)/})
16
- end
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.16"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
24
- end