active_record_segment 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rakeTasks +7 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +0 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +78 -0
- data/Rakefile +10 -0
- data/active_record_segment.gemspec +54 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/active_record_segment.rb +62 -0
- data/lib/active_record_segment/controller_context.rb +27 -0
- data/lib/active_record_segment/segmentable.rb +73 -0
- data/lib/active_record_segment/version.rb +3 -0
- data/lib/generators/active_record_segment/install_generator.rb +14 -0
- data/lib/generators/active_record_segment/templates/active_record_segment_initializer.rb +20 -0
- metadata +207 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4f5e5d78658c86749a582b5a76969cd3495d098900ca93fb07a8053013d1a0ab
|
4
|
+
data.tar.gz: 613ce4acfa9c9f1bcefed868eb895da58c3e3b0733fb8f9b16af35feb0a538ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62c88abb718cabdc824709a7ce9c9d297a0460c4735846aab5aec992eed13993823ea402734a766d232cbe0c05f55c1a2d3ec562c5d5c13680d6818f5fb0d648
|
7
|
+
data.tar.gz: 194e05de0f1937b2f688d5c80401d466a90828adb2ea2391234ef0699ff86f4a8813914b1e2a26fa68f241d500b128fdf22e8c41fb3298addcc548b1d4003106
|
data/.gitignore
ADDED
data/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
File without changes
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at xiaorong.ruby@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Ryan Lv
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Active Record Segment
|
2
|
+
|
3
|
+
ActiveRecordSegment is an ActiveRecord Extension that logs all changes to your segment destinations. ActiveRecordSegment could also record who made those changes.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'active_record_segment'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install active_record_segment
|
20
|
+
|
21
|
+
Then, create configuration file for ActiveRecordSegment with following command
|
22
|
+
|
23
|
+
```
|
24
|
+
rails generate active_record_segment:install
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
## Configuration
|
29
|
+
|
30
|
+
After successfully install this gem in your Rails project, please specify configurations in `config/initializer/active_record_segment.rb'
|
31
|
+
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
segment_write_key = "YOUR_WRITE_KEY_OF_SEGMENT"
|
35
|
+
|
36
|
+
ActiveRecordSegment.configure do |config|
|
37
|
+
# Feature toggle
|
38
|
+
config.enabled = true
|
39
|
+
|
40
|
+
config.env = Rails.env.to_s
|
41
|
+
|
42
|
+
config.logger = Rails.logger
|
43
|
+
|
44
|
+
# Instruction: https://github.com/segmentio/analytics-ruby
|
45
|
+
config.segment_write_key = segment_write_key
|
46
|
+
# Ignore changes happen to the following columns of each table.
|
47
|
+
# Default value is `created_at` and `updated_at`
|
48
|
+
config.ignored_attributes = %w[created_at updated_at]
|
49
|
+
|
50
|
+
# By default, all the classes, that are inherited from ActiveRecord, will be logged. Please specify which classes you
|
51
|
+
# would like to ignore.
|
52
|
+
# config.ignored_klasses = []
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
|
57
|
+
## Usage
|
58
|
+
|
59
|
+
When you application runs, this extension will automatically log all changes of ActiveRecord to segment.com.
|
60
|
+
|
61
|
+
|
62
|
+
## Development
|
63
|
+
|
64
|
+
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.
|
65
|
+
|
66
|
+
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).
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/helloworld1812/active_record_segment. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
75
|
+
|
76
|
+
## Code of Conduct
|
77
|
+
|
78
|
+
Everyone interacting in the Activerecordsegment project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/activerecordsegment/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "active_record_segment/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "active_record_segment"
|
7
|
+
spec.version = ActiveRecordSegment::VERSION
|
8
|
+
spec.authors = ["Workstream.is"]
|
9
|
+
spec.email = ["ryan@workstream.is"]
|
10
|
+
|
11
|
+
spec.summary = %q{Log all changes of active record to your segment destination}
|
12
|
+
spec.description = <<-EOS
|
13
|
+
ActiveRecord Segment is an audit tools, deployed by Workstream, Inc (http://workstream.is). As an enterprise application,
|
14
|
+
It's necessary to audit the changes by customers. This gem allow your application to audit all changes and send it to
|
15
|
+
segment destination, in which place you could analyze them in destination database.
|
16
|
+
EOS
|
17
|
+
spec.homepage = "https://github.com/helloworld1812/active_record_segment"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
|
21
|
+
if spec.respond_to?(:metadata)
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/helloworld1812/active_record_segment"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/helloworld1812/active_record_segment/blob/master/CHANGELOG.md"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.required_ruby_version = '>= 2.3.0'
|
40
|
+
|
41
|
+
# Runtime dependency
|
42
|
+
spec.add_runtime_dependency 'activerecord', '>= 4.2'
|
43
|
+
spec.add_runtime_dependency 'activesupport'
|
44
|
+
spec.add_runtime_dependency 'analytics-ruby', '>= 2.0'
|
45
|
+
|
46
|
+
# Development dependency
|
47
|
+
spec.add_development_dependency "bundler", ">= 1.17"
|
48
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
49
|
+
spec.add_development_dependency "minitest"
|
50
|
+
spec.add_development_dependency 'mocha'
|
51
|
+
spec.add_development_dependency 'rails'
|
52
|
+
spec.add_development_dependency 'pry'
|
53
|
+
spec.add_development_dependency 'sqlite3'
|
54
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "active_record_segment"
|
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
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'active_support'
|
3
|
+
require 'analytics-ruby'
|
4
|
+
require 'active_record_segment/version'
|
5
|
+
require 'active_record_segment/segmentable'
|
6
|
+
require 'active_record_segment/controller_context'
|
7
|
+
|
8
|
+
module ActiveRecordSegment
|
9
|
+
|
10
|
+
|
11
|
+
DEFAULT_IGNORED_ATTRIBUTES = %w(updated_at created_at deleted_at)
|
12
|
+
|
13
|
+
class Configuration
|
14
|
+
attr_accessor :segment_write_key, :env, :enabled, :logger, :ignored_attributes, :ignored_klasses
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
# Set default value if user forget to configure
|
18
|
+
self.ignored_attributes = DEFAULT_IGNORED_ATTRIBUTES
|
19
|
+
self.ignored_klasses = []
|
20
|
+
self.enabled = false
|
21
|
+
self.env = defined?(Rails) && Rails.env.to_s
|
22
|
+
self.logger = Logger.new(STDOUT)
|
23
|
+
end
|
24
|
+
|
25
|
+
def segment_analytic
|
26
|
+
if segment_write_key.nil?
|
27
|
+
raise StandardError.new("Please config segment write key before call this method")
|
28
|
+
end
|
29
|
+
|
30
|
+
@segment_analytic ||= Segment::Analytics.new(
|
31
|
+
write_key: segment_write_key,
|
32
|
+
on_error: proc { |status, msg| print msg }
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
attr_accessor :configuration
|
39
|
+
|
40
|
+
def configure
|
41
|
+
yield(configuration)
|
42
|
+
end
|
43
|
+
|
44
|
+
def reset
|
45
|
+
@configuration = Configuration.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def configuration
|
49
|
+
@configuration ||= Configuration.new
|
50
|
+
end
|
51
|
+
|
52
|
+
def store
|
53
|
+
Thread.current[:active_record_segment_store] ||= {}
|
54
|
+
end
|
55
|
+
|
56
|
+
def purge_store!
|
57
|
+
Thread.current[:active_record_segment_store] = {}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
::ActiveRecord::Base.send(:include, ActiveRecordSegment::Segmentable)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveRecordSegment
|
2
|
+
class ControllerContext
|
3
|
+
def around(controller)
|
4
|
+
if controller.present?
|
5
|
+
ActiveRecordSegment.purge_store!
|
6
|
+
ActiveRecordSegment.store[:current_user] = controller.current_user if controller.respond_to?(:current_user)
|
7
|
+
ActiveRecordSegment.store[:current_company] = controller.current_company if controller.respond_to?(:current_company)
|
8
|
+
ActiveRecordSegment.store[:request_uuid] = controller.request.uuid
|
9
|
+
ActiveRecordSegment.store[:remote_ip] = controller.request.remote_ip
|
10
|
+
ActiveRecordSegment.store[:current_controller] = controller
|
11
|
+
end
|
12
|
+
yield
|
13
|
+
ensure
|
14
|
+
# reset the thread local variable.
|
15
|
+
ActiveRecordSegment.purge_store!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
ActiveSupport.on_load(:action_controller) do
|
21
|
+
if defined?(ActionController::Base)
|
22
|
+
ActionController::Base.around_action ActiveRecordSegment::ControllerContext.new
|
23
|
+
end
|
24
|
+
if defined?(ActionController::API)
|
25
|
+
ActionController::API.around_action ActiveRecordSegment::ControllerContext.new
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module ActiveRecordSegment
|
2
|
+
module Segmentable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
after_create :audit_create_to_segment, if: :segment_auditing_enabled?
|
7
|
+
before_update :audit_update_to_segment, if: :segment_auditing_enabled?
|
8
|
+
before_destroy :audit_destroy_to_segment, if: :segment_auditing_enabled?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def segment_auditing_enabled?
|
14
|
+
return false if ActiveRecordSegment.configuration.ignored_klasses.include?(self.class)
|
15
|
+
return false if !ActiveRecordSegment.configuration.enabled
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
|
19
|
+
def audit_create_to_segment
|
20
|
+
write_audit_to_segment(action: 'create', audited_changes: attributes)
|
21
|
+
end
|
22
|
+
|
23
|
+
def audit_update_to_segment
|
24
|
+
if segment_audited_changes.present?
|
25
|
+
write_audit_to_segment(action: 'update', audited_changes: segment_audited_changes)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def audit_destroy_to_segment
|
30
|
+
write_audit_to_segment(action: 'destroy', audited_changes: attributes) unless new_record?
|
31
|
+
end
|
32
|
+
|
33
|
+
def write_audit_to_segment(options)
|
34
|
+
if ActiveRecordSegment.store[:current_controller].present?
|
35
|
+
user = ActiveRecordSegment.store[:current_user]
|
36
|
+
company = ActiveRecordSegment.store[:current_company]
|
37
|
+
else
|
38
|
+
# Sidekiq middleware: TODO
|
39
|
+
user = nil
|
40
|
+
company = nil
|
41
|
+
end
|
42
|
+
return false if user.nil?
|
43
|
+
return false if company.nil?
|
44
|
+
|
45
|
+
event = {
|
46
|
+
event: 'Audit Logs',
|
47
|
+
user_id: user.id,
|
48
|
+
timestamp: Time.now,
|
49
|
+
properties: {
|
50
|
+
source_user_id: user.id,
|
51
|
+
source_company_id: company.id,
|
52
|
+
action: options[:action],
|
53
|
+
table_name: self.class.table_name,
|
54
|
+
table_id: self.id,
|
55
|
+
audited_changes: options[:audited_changes].to_json,
|
56
|
+
request_uuid: ActiveRecordSegment.store[:request_uuid],
|
57
|
+
env: ActiveRecordSegment.configuration.env
|
58
|
+
}
|
59
|
+
}
|
60
|
+
ActiveRecordSegment.configuration.segment_analytic.track(event)
|
61
|
+
rescue => e
|
62
|
+
ActiveRecordSegment.configuration.logger.error e.inspect
|
63
|
+
ActiveRecordSegment.configuration.logger.error options
|
64
|
+
end
|
65
|
+
|
66
|
+
def segment_audited_changes
|
67
|
+
changes_to_save.except(*ActiveRecordSegment.configuration.ignored_attributes)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ActiveRecordSegment
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path("../templates", __FILE__)
|
5
|
+
desc "Creates ActiveRecordSegment initializer for your application"
|
6
|
+
|
7
|
+
def copy_initializer
|
8
|
+
template "active_record_segment_initializer.rb", "config/initializers/active_record_segment.rb"
|
9
|
+
|
10
|
+
puts "Install complete! Truly Outrageous!"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
segment_write_key = "YOUR_WRITE_KEY_OF_SEGMENT"
|
2
|
+
|
3
|
+
ActiveRecordSegment.configure do |config|
|
4
|
+
# Feature toggle
|
5
|
+
config.enabled = true
|
6
|
+
|
7
|
+
config.env = Rails.env.to_s
|
8
|
+
|
9
|
+
config.logger = Rails.logger
|
10
|
+
|
11
|
+
# Instruction: https://github.com/segmentio/analytics-ruby
|
12
|
+
config.segment_write_key = segment_write_key
|
13
|
+
# Ignore changes happen to the following columns of each table.
|
14
|
+
# Default value is `created_at` and `updated_at`
|
15
|
+
config.ignored_attributes = %w[created_at updated_at]
|
16
|
+
|
17
|
+
# By default, all the classes, that are inherited from ActiveRecord, will be logged. Please specify which classes you
|
18
|
+
# would like to ignore.
|
19
|
+
# config.ignored_klasses = []
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,207 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: active_record_segment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Workstream.is
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: analytics-ruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.17'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.17'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mocha
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rails
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: sqlite3
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: |
|
154
|
+
ActiveRecord Segment is an audit tools, deployed by Workstream, Inc (http://workstream.is). As an enterprise application,
|
155
|
+
It's necessary to audit the changes by customers. This gem allow your application to audit all changes and send it to
|
156
|
+
segment destination, in which place you could analyze them in destination database.
|
157
|
+
email:
|
158
|
+
- ryan@workstream.is
|
159
|
+
executables: []
|
160
|
+
extensions: []
|
161
|
+
extra_rdoc_files: []
|
162
|
+
files:
|
163
|
+
- ".gitignore"
|
164
|
+
- ".rakeTasks"
|
165
|
+
- ".travis.yml"
|
166
|
+
- CHANGELOG.md
|
167
|
+
- CODE_OF_CONDUCT.md
|
168
|
+
- Gemfile
|
169
|
+
- LICENSE.txt
|
170
|
+
- README.md
|
171
|
+
- Rakefile
|
172
|
+
- active_record_segment.gemspec
|
173
|
+
- bin/console
|
174
|
+
- bin/setup
|
175
|
+
- lib/active_record_segment.rb
|
176
|
+
- lib/active_record_segment/controller_context.rb
|
177
|
+
- lib/active_record_segment/segmentable.rb
|
178
|
+
- lib/active_record_segment/version.rb
|
179
|
+
- lib/generators/active_record_segment/install_generator.rb
|
180
|
+
- lib/generators/active_record_segment/templates/active_record_segment_initializer.rb
|
181
|
+
homepage: https://github.com/helloworld1812/active_record_segment
|
182
|
+
licenses:
|
183
|
+
- MIT
|
184
|
+
metadata:
|
185
|
+
homepage_uri: https://github.com/helloworld1812/active_record_segment
|
186
|
+
source_code_uri: https://github.com/helloworld1812/active_record_segment
|
187
|
+
changelog_uri: https://github.com/helloworld1812/active_record_segment/blob/master/CHANGELOG.md
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 2.3.0
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubygems_version: 3.0.6
|
204
|
+
signing_key:
|
205
|
+
specification_version: 4
|
206
|
+
summary: Log all changes of active record to your segment destination
|
207
|
+
test_files: []
|