active_record-journal 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bb7f127b6cc57ca305e8e13e28a5b5d8ef5da514bdc113ccdbb30c6cc58e108f
4
+ data.tar.gz: 7be419a842b986060aac1fd321022cdfed43492884db515a6118714965b31e4d
5
+ SHA512:
6
+ metadata.gz: b60babffefb711f427078a97b4461600abc897a90dadb2959f0347744ed6ddb89b97aa6e61d4356f1f78505e323a0d1f0f1186c1d61a46a1c4b3240c33c78c49
7
+ data.tar.gz: ec58d2399d9445e229c615c499e028426da11b5946a3c2f63d3436bcadd3f857e32a1539f1389e00fbe7ea9b53406d872fc156ed37f17f87e21de743a436498d
@@ -0,0 +1,122 @@
1
+ # Use the latest 2.1 version of CircleCI pipeline process engine.
2
+ # See: https://circleci.com/docs/2.0/configuration-reference
3
+ version: 2.1
4
+
5
+ executors:
6
+ gem:
7
+ docker:
8
+ - image: cimg/ruby:2.7.0
9
+ auth:
10
+ username: $DOCKERHUB_ACCESS_USER
11
+ password: $DOCKERHUB_ACCESS_TOKEN
12
+ environment:
13
+ RAILS_ENV: test
14
+ RAILS_RELATIVE_URL_ROOT: '/home/circleci/project'
15
+ postgresql:
16
+ docker:
17
+ - image: cimg/ruby:2.7.0
18
+ auth:
19
+ username: $DOCKERHUB_ACCESS_USER
20
+ password: $DOCKERHUB_ACCESS_TOKEN
21
+ environment:
22
+ RAILS_ENV: test
23
+ POSTGRES_HOST_NAME: localhost
24
+ POSTGRES_USER: $POSTGRES_USER
25
+ POSTGRES_DB: $POSTGRES_DB
26
+ POSTGRES_PASSWORD: $POSTGRES_PASSWORD
27
+ RAILS_RELATIVE_URL_ROOT: '/home/circleci/project'
28
+ - image: cimg/postgres:14.0
29
+ auth:
30
+ username: $DOCKERHUB_ACCESS_USER
31
+ password: $DOCKERHUB_ACCESS_TOKEN
32
+ environment:
33
+ POSTGRES_DB: $POSTGRES_DB
34
+ POSTGRES_PASSWORD: $POSTGRES_PASSWORD
35
+
36
+ commands:
37
+ dependencies:
38
+ steps:
39
+ - checkout
40
+ - run: sudo apt-get update
41
+ - run:
42
+ name: Install system dependencies
43
+ command: sudo apt install -y libpq-dev sqlite3 libsqlite3-dev
44
+ - run:
45
+ name: Install gem dependencies
46
+ command: bundle install
47
+ - run: chmod +x bin/setup
48
+ - run: ./bin/setup
49
+ rubocop:
50
+ steps:
51
+ - run:
52
+ name: Rubocop
53
+ command: bundle exec rubocop
54
+ rspec:
55
+ steps:
56
+ - run:
57
+ name: Run Specs
58
+ command: bundle exec rspec
59
+ - persist_to_workspace:
60
+ root: coverage
61
+ paths:
62
+ - .last_run.json
63
+ simplecov:
64
+ steps:
65
+ - attach_workspace:
66
+ at: coverage
67
+ - run: chmod +x bin/coverage
68
+ - run: ./bin/coverage
69
+
70
+ jobs:
71
+ build:
72
+ description: 'Build gem dependencies'
73
+ executor: gem
74
+ steps:
75
+ - dependencies
76
+ linter:
77
+ description: 'Rubocop'
78
+ executor: gem
79
+ steps:
80
+ - dependencies
81
+ - rubocop
82
+ specs:
83
+ description: 'Run specs'
84
+ parameters:
85
+ db:
86
+ type: string
87
+ executor:
88
+ type: string
89
+ executor: << parameters.executor >>
90
+ steps:
91
+ - dependencies
92
+ - rspec
93
+ environment:
94
+ DB_CONFIG: << parameters.db >>
95
+ coverage:
96
+ executor: gem
97
+ steps:
98
+ - dependencies
99
+ - simplecov
100
+
101
+ workflows:
102
+ integration-workflow:
103
+ jobs:
104
+ - build
105
+ - linter:
106
+ requires:
107
+ - build
108
+ - specs:
109
+ name: postgres-specs
110
+ db: postgresql
111
+ executor: postgresql
112
+ requires:
113
+ - build
114
+ - specs:
115
+ name: sqlite-specs
116
+ db: sqlite
117
+ executor: gem
118
+ requires:
119
+ - build
120
+ - coverage:
121
+ requires:
122
+ - sqlite-specs
data/.env ADDED
@@ -0,0 +1,6 @@
1
+ POSTGRES_HOST_NAME=pg
2
+ POSTGRES_USER=journal
3
+ POSTGRES_DB=journal
4
+ POSTGRES_HOST_AUTH_METHOD=trust
5
+ RAILS_ENV=test
6
+ RAILS_RELATIVE_URL_ROOT=/active_record-journal
data/.gitignore ADDED
@@ -0,0 +1,11 @@
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 ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Metrics/BlockLength:
5
+ Exclude:
6
+ - spec/**/*.rb
7
+
8
+ Lint/UnreachableCode:
9
+ Exclude:
10
+ - spec/**/*.rb
11
+
12
+ Style/Documentation:
13
+ Enabled: false
@@ -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 nika.kirosh@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/Dockerfile ADDED
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.7
2
+ RUN apt-get update
3
+ RUN apt-get install sqlite3
4
+ RUN gem install bundler --no-document
5
+
6
+ WORKDIR /active_record-journal
7
+ COPY . /active_record-journal
8
+ RUN bundle install
9
+
10
+ ENTRYPOINT ["bash"]
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in active_record-journal.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,134 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ active_record-journal (0.1.0)
5
+ activerecord (>= 6.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (7.0.2.2)
11
+ actionview (= 7.0.2.2)
12
+ activesupport (= 7.0.2.2)
13
+ rack (~> 2.0, >= 2.2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
17
+ actionview (7.0.2.2)
18
+ activesupport (= 7.0.2.2)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
23
+ activemodel (7.0.2.2)
24
+ activesupport (= 7.0.2.2)
25
+ activerecord (7.0.2.2)
26
+ activemodel (= 7.0.2.2)
27
+ activesupport (= 7.0.2.2)
28
+ activesupport (7.0.2.2)
29
+ concurrent-ruby (~> 1.0, >= 1.0.2)
30
+ i18n (>= 1.6, < 2)
31
+ minitest (>= 5.1)
32
+ tzinfo (~> 2.0)
33
+ ast (2.4.2)
34
+ builder (3.2.4)
35
+ coderay (1.1.3)
36
+ concurrent-ruby (1.1.9)
37
+ crass (1.0.6)
38
+ diff-lcs (1.5.0)
39
+ docile (1.4.0)
40
+ erubi (1.10.0)
41
+ i18n (1.10.0)
42
+ concurrent-ruby (~> 1.0)
43
+ loofah (2.14.0)
44
+ crass (~> 1.0.2)
45
+ nokogiri (>= 1.5.9)
46
+ method_source (1.0.0)
47
+ minitest (5.15.0)
48
+ nokogiri (1.13.3-x86_64-linux)
49
+ racc (~> 1.4)
50
+ parallel (1.21.0)
51
+ parser (3.1.1.0)
52
+ ast (~> 2.4.1)
53
+ pg (1.3.3)
54
+ pry (0.14.1)
55
+ coderay (~> 1.1)
56
+ method_source (~> 1.0)
57
+ racc (1.6.0)
58
+ rack (2.2.3)
59
+ rack-test (1.1.0)
60
+ rack (>= 1.0, < 3)
61
+ rails-dom-testing (2.0.3)
62
+ activesupport (>= 4.2.0)
63
+ nokogiri (>= 1.6)
64
+ rails-html-sanitizer (1.4.2)
65
+ loofah (~> 2.3)
66
+ railties (7.0.2.2)
67
+ actionpack (= 7.0.2.2)
68
+ activesupport (= 7.0.2.2)
69
+ method_source
70
+ rake (>= 12.2)
71
+ thor (~> 1.0)
72
+ zeitwerk (~> 2.5)
73
+ rainbow (3.1.1)
74
+ rake (13.0.6)
75
+ regexp_parser (2.2.1)
76
+ rexml (3.2.5)
77
+ rspec-core (3.11.0)
78
+ rspec-support (~> 3.11.0)
79
+ rspec-expectations (3.11.0)
80
+ diff-lcs (>= 1.2.0, < 2.0)
81
+ rspec-support (~> 3.11.0)
82
+ rspec-mocks (3.11.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.11.0)
85
+ rspec-rails (5.0.3)
86
+ actionpack (>= 5.2)
87
+ activesupport (>= 5.2)
88
+ railties (>= 5.2)
89
+ rspec-core (~> 3.10)
90
+ rspec-expectations (~> 3.10)
91
+ rspec-mocks (~> 3.10)
92
+ rspec-support (~> 3.10)
93
+ rspec-support (3.11.0)
94
+ rubocop (1.25.1)
95
+ parallel (~> 1.10)
96
+ parser (>= 3.1.0.0)
97
+ rainbow (>= 2.2.2, < 4.0)
98
+ regexp_parser (>= 1.8, < 3.0)
99
+ rexml
100
+ rubocop-ast (>= 1.15.1, < 2.0)
101
+ ruby-progressbar (~> 1.7)
102
+ unicode-display_width (>= 1.4.0, < 3.0)
103
+ rubocop-ast (1.16.0)
104
+ parser (>= 3.1.1.0)
105
+ ruby-progressbar (1.11.0)
106
+ simplecov (0.21.2)
107
+ docile (~> 1.1)
108
+ simplecov-html (~> 0.11)
109
+ simplecov_json_formatter (~> 0.1)
110
+ simplecov-html (0.12.3)
111
+ simplecov_json_formatter (0.1.4)
112
+ sqlite3 (1.4.2)
113
+ thor (1.2.1)
114
+ tzinfo (2.0.4)
115
+ concurrent-ruby (~> 1.0)
116
+ unicode-display_width (2.1.0)
117
+ zeitwerk (2.5.4)
118
+
119
+ PLATFORMS
120
+ x86_64-linux
121
+
122
+ DEPENDENCIES
123
+ active_record-journal!
124
+ bundler
125
+ pg
126
+ pry
127
+ rake (~> 13.0)
128
+ rspec-rails (~> 5.0.1)
129
+ rubocop
130
+ simplecov
131
+ sqlite3
132
+
133
+ BUNDLED WITH
134
+ 2.3.8
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 mkiroshdz
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,161 @@
1
+ [![CircleCI](https://circleci.com/gh/mkiroshdz/active_record-journal/tree/main.svg?style=svg)](https://circleci.com/gh/mkiroshdz/active_record-journal/tree/main)
2
+
3
+ # ActiveRecord::Journal
4
+
5
+ ActiveRecord::Journal allows you to keep track of the CRUDs on your ActiveRecord models and tag them with the data of your choice (the user or job that triggered the actions, description, ...).
6
+
7
+ ## Getting started
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'active_record-journal'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install active_record-journal
22
+
23
+
24
+ ## Setup
25
+
26
+ ### Initialization
27
+
28
+ ```ruby
29
+ ActiveRecord::Journal.configuration.entries_class = 'BookChangeLog'
30
+ ActiveRecord::Journal.configuration.tags_class = 'BookChangeTag'
31
+ ActiveRecord::Journal.configuration.autorecording_enabled = true
32
+ ```
33
+
34
+ ### Logs
35
+
36
+ You need to define the models that will persist the records and tags of the CRUDs.
37
+
38
+ ```ruby
39
+ class BookChangeLog < ActiveRecord::Base; end
40
+ class BookChangeTag < ActiveRecord::Base; end
41
+ ```
42
+
43
+ The minimun attributes required for the models are shown in this schema:
44
+
45
+ ```ruby
46
+ create_table :book_change_logs do |t| # Table for the records
47
+ # t.string :changes_map
48
+ t.jsonb :changes_map
49
+ t.string :action
50
+ t.string :journable_type
51
+ t.integer :journable_id
52
+ t.string :journal_tag_type
53
+ t.integer :journal_tag_id
54
+ t.datetime :created_at
55
+ end
56
+
57
+ create_table :book_change_tags do |t| # Table for the tags
58
+ t.string :journable_type
59
+ t.integer :journable_id
60
+ t.datetime :created_at
61
+ end
62
+ ```
63
+
64
+ Note: The gem assumes that the `BookChangeLog#changes_map=` receives a hash and the logic to handle the serialization will be handled by the model regardless of the type of changes_map in the database.
65
+
66
+ ### Extend ActiveRecord::Base
67
+
68
+ This will provide the required methods to enable tracking in the models.
69
+
70
+ ```ruby
71
+ class RecordWithLogs < ActiveRecord::Base
72
+ self.abstract_class = true
73
+ extend ActiveRecord::Journal::Journable
74
+ end
75
+ ```
76
+
77
+ ### Model tracking
78
+
79
+ You can use the methods `ActiveRecord::Journal::Journable::journal_writes` and `ActiveRecord::Journal::Journable::journal_reads` to define a set of rules that tell your model how to keep track of the records. Every time a CRUD is triggered all the rules defined are checked and executed if the necessary conditions are met.
80
+
81
+ ```ruby
82
+ class Author < RecordWithLogs
83
+ journal_writes on: %i[create]
84
+ journal_writes on: %i[update], only: %i[name last_name]
85
+ end
86
+
87
+ class Book < RecordWithLogs
88
+ belongs_to :author
89
+ journal_reads unless: :best_seller?
90
+ journal_reads entries_class: CustomBookChangeLog, tag_class: BookChangeTag, if: :best_seller?
91
+ journal_writes
92
+ end
93
+ ```
94
+
95
+ ## Usage
96
+
97
+ ### Tag operations
98
+
99
+ You can create and associate a tag to a group of CRUDS.
100
+
101
+ ```ruby
102
+ ActiveRecord::Journal.tag(user: current_user, description: 'Create book') do |tag|
103
+ tag.actions do
104
+ author = Author.find_by(id: params[:author_id])
105
+ Book.create!(title: params[:title], author: author)
106
+ end
107
+ end
108
+ ```
109
+
110
+ ### Ignore operations
111
+
112
+ Can ignore actions originally configured to be tracked.
113
+
114
+ ```ruby
115
+ ActiveRecord::Journal.ignore do |context|
116
+ context.actions do
117
+ author = Author.find_by(id: params[:author_id])
118
+ Book.create!(title: params[:title], author: author)
119
+ end
120
+ end
121
+ ```
122
+
123
+ ### One time constraints
124
+
125
+ ```ruby
126
+ ActiveRecord::Journal.tag(user: current_user) do |tag|
127
+ tag.record(Book, if: ->(record) { record.author.present? })
128
+ tag.actions do
129
+ author = Author.find_by(id: params[:author_id])
130
+ Book.create!(title: params[:title], author: author)
131
+ end
132
+ end
133
+
134
+ ActiveRecord::Journal.context do |context|
135
+ context.record(Book, unless: ->(record) { record.author.present? })
136
+ context.actions do
137
+ author = Author.find_by(id: params[:author_id])
138
+ Book.create!(title: params[:title], author: author)
139
+ end
140
+ end
141
+ ```
142
+
143
+ ## Development
144
+
145
+ ### Setup
146
+
147
+ After checking out the repo, you can build the required containers by running `docker-compose build` and execute them with `docker-compose run gem`.
148
+
149
+ To install this gem onto your local, run `bundle exec rake install`.
150
+
151
+ ### Tests
152
+
153
+ Inside the container, run `rake spec` to run the tests.
154
+
155
+ ## Contributing
156
+
157
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mkiroshdz/active_record-journal.
158
+
159
+ ## License
160
+
161
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'active_record/journal/version'
6
+
7
+ # rubocop:disable Metrics/BlockLength
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'active_record-journal'
10
+ spec.version = ActiveRecord::Journal::VERSION
11
+ spec.authors = ['mkiroshdz']
12
+ spec.email = ['mkirosh@hey.com']
13
+
14
+ spec.summary = 'A gem to track changes on active record models'
15
+ spec.description = 'A gem to track changes on active record models'
16
+ spec.homepage = 'https://github.com/mkiroshdz/active_record-journal'
17
+ spec.license = 'MIT'
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
23
+ spec.metadata['homepage_uri'] = spec.homepage
24
+ spec.metadata['source_code_uri'] = 'https://github.com/mkiroshdz/active_record-journal'
25
+ spec.metadata['changelog_uri'] = 'https://github.com/mkiroshdz/active_record-journal/blob/CHANGELOG.md'
26
+ else
27
+ raise 'RubyGems 2.0 or newer is required to protect against ' \
28
+ 'public gem pushes.'
29
+ end
30
+
31
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+
35
+ spec.bindir = 'exe'
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ['lib']
38
+ spec.required_ruby_version = '>= 2.5'
39
+
40
+ spec.add_dependency 'activerecord', '>= 6.0.0'
41
+ spec.add_development_dependency 'bundler'
42
+ spec.add_development_dependency 'pg'
43
+ spec.add_development_dependency 'pry'
44
+ spec.add_development_dependency 'rake', '~> 13.0'
45
+ spec.add_development_dependency 'rspec-rails', '~> 5.0.1'
46
+ spec.add_development_dependency 'rubocop'
47
+ spec.add_development_dependency 'simplecov'
48
+ spec.add_development_dependency 'sqlite3'
49
+ end
50
+ # rubocop:enable Metrics/BlockLength
data/bin/coverage ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'simplecov'
5
+
6
+ SimpleCov.root((ENV['RAILS_RELATIVE_URL_ROOT']).to_s)
7
+ result = SimpleCov::LastRun.read[:result].values.min
8
+ threshold = ENV['SPEC_COVERAGE_THRESHOLD']&.to_i
9
+ result >= threshold ? exit(true) : exit(false)
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,28 @@
1
+ version: '3'
2
+
3
+ services:
4
+ db:
5
+ image: 'postgres'
6
+ environment:
7
+ - POSTGRES_USER=${POSTGRES_USER}
8
+ - POSTGRES_HOST_AUTH_METHOD=${POSTGRES_HOST_AUTH_METHOD}
9
+ - POSTGRES_DB=${POSTGRES_DB}
10
+ networks:
11
+ - gembrg
12
+ gem:
13
+ build: .
14
+ environment:
15
+ - RAILS_ENV=${RAILS_ENV}
16
+ - RAILS_RELATIVE_URL_ROOT=${RAILS_RELATIVE_URL_ROOT}
17
+ - POSTGRES_HOST_NAME=${POSTGRES_HOST_NAME}
18
+ - POSTGRES_DB=${POSTGRES_DB}
19
+ - POSTGRES_USER=${POSTGRES_USER}
20
+ networks:
21
+ - gembrg
22
+ links:
23
+ - db:pg
24
+ volumes:
25
+ - .:/active_record-journal
26
+
27
+ networks:
28
+ gembrg: