rh-activerecord-diff 2.0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 912aae5cb7b527988b5d986b61d5d5ef0a1cba84dacea539adc62eb8d2c50fae
4
+ data.tar.gz: ee1e22c247c894fc1865130fea557e9a2a364572c2ba23f48ab15222fe75b843
5
+ SHA512:
6
+ metadata.gz: 86dbdee74074bfb3c4955fde6001cf9aa78080ef70fc2763eb1b1246d6c849bca96d154e69eb5d4ef3ab21395316deffc68359710792b0d2036b9923dba8614b
7
+ data.tar.gz: 7f18eff65fe02e03bf01216b191fa8ceadb1a3784079264deb5c792c7cc09263afdeb4cb386d2c1800e4bd0b6e50443fc55bad1aa936a4a7903a35fa2307a2dd
@@ -0,0 +1,36 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ workflow_run:
5
+ workflows:
6
+ - Ruby
7
+ types:
8
+ - completed
9
+ branches: [ main ]
10
+
11
+ jobs:
12
+ build:
13
+ name: Build + Publish
14
+ runs-on: ubuntu-latest
15
+ permissions:
16
+ contents: read
17
+ packages: write
18
+
19
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
20
+ steps:
21
+ - uses: actions/checkout@v2
22
+ - name: Set up Ruby 2.6
23
+ uses: actions/setup-ruby@v1
24
+ with:
25
+ ruby-version: 2.6.x
26
+
27
+ - name: Publish to RubyGems
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem build *.gemspec
34
+ gem push *.gem
35
+ env:
36
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -0,0 +1,63 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test_2_6:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ gemfile: ['activerecord_5.2', 'activerecord_6.0', 'activerecord_6.1']
15
+ env:
16
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: '2.6'
24
+ bundler-cache: true
25
+ - name: Run tests
26
+ run: bundle exec rake
27
+
28
+ test_2_7:
29
+ runs-on: ubuntu-latest
30
+ strategy:
31
+ matrix:
32
+ gemfile: ['activerecord_5.2', 'activerecord_6.0', 'activerecord_6.1', 'activerecord_7.0']
33
+ env:
34
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
35
+
36
+ steps:
37
+ - uses: actions/checkout@v2
38
+ - name: Set up Ruby
39
+ uses: ruby/setup-ruby@v1
40
+ with:
41
+ ruby-version: '2.7'
42
+ bundler-cache: true
43
+ - name: Run tests
44
+ run: bundle exec rake
45
+
46
+ test_3_x:
47
+ runs-on: ubuntu-latest
48
+ strategy:
49
+ matrix:
50
+ ruby-version: ['3.0', '3.1']
51
+ gemfile: ['activerecord_6.0', 'activerecord_6.1', 'activerecord_7.0']
52
+ env:
53
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
54
+
55
+ steps:
56
+ - uses: actions/checkout@v2
57
+ - name: Set up Ruby
58
+ uses: ruby/setup-ruby@v1
59
+ with:
60
+ ruby-version: ${{ matrix.ruby-version }}
61
+ bundler-cache: true
62
+ - name: Run tests
63
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ .ruby-version
@@ -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 chariderpato@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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rh-activerecord-diff.gemspec
4
+
5
+ gem 'rake', '~> 12.0'
6
+ gem 'activerecord', '>= 5.2.0'
7
+ gem 'sqlite3', '~> 1.4'
8
+
9
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rh-activerecord-diff (2.0.1)
5
+ activerecord (>= 5.2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.1.4.1)
11
+ activesupport (= 6.1.4.1)
12
+ activerecord (6.1.4.1)
13
+ activemodel (= 6.1.4.1)
14
+ activesupport (= 6.1.4.1)
15
+ activesupport (6.1.4.1)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 1.6, < 2)
18
+ minitest (>= 5.1)
19
+ tzinfo (~> 2.0)
20
+ zeitwerk (~> 2.3)
21
+ concurrent-ruby (1.1.9)
22
+ i18n (1.8.11)
23
+ concurrent-ruby (~> 1.0)
24
+ minitest (5.14.4)
25
+ rake (12.3.3)
26
+ sqlite3 (1.4.2)
27
+ tzinfo (2.0.4)
28
+ concurrent-ruby (~> 1.0)
29
+ zeitwerk (2.5.1)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ activerecord (>= 5.2.0)
36
+ rake (~> 12.0)
37
+ rh-activerecord-diff!
38
+ sqlite3 (~> 1.4)
39
+
40
+ BUNDLED WITH
41
+ 2.2.33
data/LICENSE ADDED
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # rh-activerecord-diff
2
+
3
+ Simple ActiveRecord diff functionality.
4
+
5
+ This gem was created to take over and maintain [activerecord-diff](https://rubygems.org/gems/activerecord-diff).
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rh-activerecord-diff'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rh-activerecord-diff
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ require 'active_record/diff'
27
+
28
+ class User < ActiveRecord::Base
29
+ include ActiveRecord::Diff
30
+ end
31
+
32
+ alice = User.create(:name => 'alice', :email_address => 'alice@example.org')
33
+
34
+ bob = User.create(:name => 'bob', :email_address => 'bob@example.org')
35
+
36
+ alice.diff?(bob) # => true
37
+
38
+ alice.diff(bob) # => {:name => ['alice', 'bob'], :email_address => ['alice@example.org', 'bob@example.org']}
39
+
40
+ alice.diff({:name => 'eve'}) # => {:name => ['alice', 'eve']}
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ By default, ActiveRecord::Base.content_columns is used to decide which attributes
46
+ to compare. You can include or exclude attributes from this as follows:
47
+
48
+ ```ruby
49
+ class User < ActiveRecord::Base
50
+ diff :include => [:id], :exclude => [:password_hash]
51
+ end
52
+ ```
53
+
54
+ Alternatively, you can specify exactly which columns to compare:
55
+
56
+ ```ruby
57
+ class User < ActiveRecord::Base
58
+ diff :id, :name, :email_address
59
+ end
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake` 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/hayashima/rh-activerecord-diff. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/hayashima/rh-activerecord-diff/blob/main/CODE_OF_CONDUCT.md).
71
+
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/).
76
+
77
+ ## Code of Conduct
78
+
79
+ Everyone interacting in the rh-activerecord-diff project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hayashima/rh-activerecord-diff/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ task :default => [:test]
5
+
6
+ Rake::TestTask.new do |test|
7
+ test.test_files = Dir['test/**/*_test.rb']
8
+ # test.verbose = true
9
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "activerecord/diff"
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,8 @@
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
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake', '~> 12.0'
4
+ gem 'activerecord', '~> 5.2.0'
5
+ gem 'sqlite3', '~> 1.4'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake', '~> 12.0'
4
+ gem 'activerecord', '~> 6.0.0'
5
+ gem 'sqlite3', '~> 1.4'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake', '~> 12.0'
4
+ gem 'activerecord', '~> 6.1.0'
5
+ gem 'sqlite3', '~> 1.4'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake', '~> 12.0'
4
+ gem 'activerecord', '~> 7.0.0'
5
+ gem 'sqlite3', '~> 1.4'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,5 @@
1
+ module ActiveRecord
2
+ module Diff
3
+ VERSION = "2.0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,60 @@
1
+ require "active_record/diff/version"
2
+
3
+ module ActiveRecord
4
+ module Diff
5
+ module ClassMethod
6
+ def diff(*attrs)
7
+ self.diff_attrs = attrs
8
+ end
9
+ end
10
+
11
+ def self.included(base)
12
+ base.class_attribute :diff_attrs
13
+ base.extend ClassMethod
14
+ end
15
+
16
+ def diff?(record = nil)
17
+ not diff(record).empty?
18
+ end
19
+
20
+ def diff(other_record = nil)
21
+ if other_record.nil?
22
+ old_record, new_record = self.class.find(id), self
23
+ else
24
+ old_record, new_record = self, other_record
25
+ end
26
+
27
+ if new_record.is_a?(Hash)
28
+ diff_each(new_record) do |(attr_name, hash_value)|
29
+ [attr_name, old_record.send(attr_name), hash_value]
30
+ end
31
+ else
32
+ attrs = self.class.diff_attrs
33
+
34
+ if attrs.nil?
35
+ attrs = self.class.content_columns.map { |column| column.name.to_sym }
36
+ elsif attrs.length == 1 && Hash === attrs.first
37
+ columns = self.class.content_columns.map { |column| column.name.to_sym }
38
+
39
+ attrs = columns + (attrs.first[:include] || []) - (attrs.first[:exclude] || [])
40
+ end
41
+
42
+ diff_each(attrs) do |attr_name|
43
+ [attr_name, old_record.send(attr_name), new_record.send(attr_name)]
44
+ end
45
+ end
46
+ end
47
+
48
+ def diff_each(enum)
49
+ enum.inject({}) do |diff_hash, attr_name|
50
+ attr_name, old_value, new_value = *yield(attr_name)
51
+
52
+ unless old_value === new_value
53
+ diff_hash[attr_name.to_sym] = [old_value, new_value]
54
+ end
55
+
56
+ diff_hash
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1 @@
1
+ require 'active_record/diff'
@@ -0,0 +1,32 @@
1
+ require_relative 'lib/active_record/diff/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "rh-activerecord-diff"
5
+ spec.version = ActiveRecord::Diff::VERSION
6
+ spec.authors = ["patorash"]
7
+ spec.email = ["chariderpato@gmail.com"]
8
+
9
+ spec.summary = %q{Simple ActiveRecord diff functionality}
10
+ spec.description = %q{Simple ActiveRecord diff functionality}
11
+ spec.homepage = 'https://github.com/hayashima/rh-activerecord-diff'
12
+ spec.license = "CC0-1.0"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
+
15
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
19
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ # spec.bindir = "exe"
27
+ # spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency('activerecord', '< 7.1.0','>= 5.2.0')
31
+
32
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rh-activerecord-diff
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - patorash
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-12-20 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: 5.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 7.1.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 5.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 7.1.0
33
+ description: Simple ActiveRecord diff functionality
34
+ email:
35
+ - chariderpato@gmail.com
36
+ executables: []
37
+ extensions: []
38
+ extra_rdoc_files: []
39
+ files:
40
+ - ".github/workflows/gem-push.yml"
41
+ - ".github/workflows/ruby.yml"
42
+ - ".gitignore"
43
+ - CODE_OF_CONDUCT.md
44
+ - Gemfile
45
+ - Gemfile.lock
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - bin/console
50
+ - bin/setup
51
+ - gemfiles/activerecord_5.2.gemfile
52
+ - gemfiles/activerecord_6.0.gemfile
53
+ - gemfiles/activerecord_6.1.gemfile
54
+ - gemfiles/activerecord_7.0.gemfile
55
+ - lib/active_record/diff.rb
56
+ - lib/active_record/diff/version.rb
57
+ - lib/rh-activerecord-diff.rb
58
+ - rh-activerecord-diff.gemspec
59
+ homepage: https://github.com/hayashima/rh-activerecord-diff
60
+ licenses:
61
+ - CC0-1.0
62
+ metadata:
63
+ homepage_uri: https://github.com/hayashima/rh-activerecord-diff
64
+ source_code_uri: https://github.com/hayashima/rh-activerecord-diff
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.6.0
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ requirements: []
80
+ rubygems_version: 3.0.3.1
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Simple ActiveRecord diff functionality
84
+ test_files: []