active_manageable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +52 -0
  3. data/.gitignore +20 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +42 -0
  6. data/.rubocop_rails.yml +201 -0
  7. data/.rubocop_rspec.yml +68 -0
  8. data/.standard.yml +5 -0
  9. data/Appraisals +27 -0
  10. data/CHANGELOG.md +5 -0
  11. data/CODE_OF_CONDUCT.md +84 -0
  12. data/Gemfile +6 -0
  13. data/Gemfile.lock +194 -0
  14. data/LICENSE.txt +21 -0
  15. data/README.md +758 -0
  16. data/Rakefile +8 -0
  17. data/active_manageable.gemspec +75 -0
  18. data/bin/console +15 -0
  19. data/bin/setup +8 -0
  20. data/gemfiles/.bundle/config +2 -0
  21. data/gemfiles/rails_6_0.gemfile +8 -0
  22. data/gemfiles/rails_6_1.gemfile +8 -0
  23. data/gemfiles/rails_7_0.gemfile +8 -0
  24. data/lib/active_manageable/authorization/cancancan.rb +28 -0
  25. data/lib/active_manageable/authorization/pundit.rb +28 -0
  26. data/lib/active_manageable/base.rb +218 -0
  27. data/lib/active_manageable/configuration.rb +58 -0
  28. data/lib/active_manageable/methods/auxiliary/includes.rb +98 -0
  29. data/lib/active_manageable/methods/auxiliary/model_attributes.rb +59 -0
  30. data/lib/active_manageable/methods/auxiliary/order.rb +43 -0
  31. data/lib/active_manageable/methods/auxiliary/scopes.rb +59 -0
  32. data/lib/active_manageable/methods/auxiliary/select.rb +46 -0
  33. data/lib/active_manageable/methods/auxiliary/unique_search.rb +50 -0
  34. data/lib/active_manageable/methods/create.rb +20 -0
  35. data/lib/active_manageable/methods/destroy.rb +23 -0
  36. data/lib/active_manageable/methods/edit.rb +25 -0
  37. data/lib/active_manageable/methods/index.rb +49 -0
  38. data/lib/active_manageable/methods/new.rb +20 -0
  39. data/lib/active_manageable/methods/show.rb +25 -0
  40. data/lib/active_manageable/methods/update.rb +23 -0
  41. data/lib/active_manageable/pagination/kaminari.rb +39 -0
  42. data/lib/active_manageable/search/ransack.rb +38 -0
  43. data/lib/active_manageable/version.rb +5 -0
  44. data/lib/active_manageable.rb +43 -0
  45. metadata +373 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f814604ee5d0971ec242d0f6e076140d746a209df9e32bd9a2e64db50c169df
4
+ data.tar.gz: 001f6cafc1265cc866cbd314d06b71c765131165cb719114c679188328a8d99e
5
+ SHA512:
6
+ metadata.gz: 8799c680b7b565cbcf3cdd950500222c73d794d2e6a9ff51297316e97564488bcbd19de13025b0cffb0c86f029d3768d724544d97edd891de15f688840ddc746
7
+ data.tar.gz: c989025cbcb8944027ab74aa23ffee3f26cbace675a0131f7e22a9b8b740c9ac9e70ce6ae56df20405e9332cbc8312fb55e1b1f23e65ac40ce9275b3bb382bbd
@@ -0,0 +1,52 @@
1
+ # GitHub actions workflow using a matrix to test all stable releases of Ruby
2
+ # with the different releases of ActiveRecord & ActiveSupport using the Appraisals gemfiles
3
+ # References
4
+ # https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-ruby
5
+ # https://github.com/ruby/setup-ruby#matrix-of-gemfiles
6
+ # https://technology.customink.com/blog/2019/09/02/from-travis-ci-to-github-actions/
7
+ # https://bibwild.wordpress.com/2020/11/12/deep-dive-moving-ruby-projects-from-travis-to-github-actions-for-ci/
8
+ # https://github.com/jrochkind/attr_json/blob/a3f38f01dc641bc0486442ec6ff4351e18ab4a03/.github/workflows/ci.yml
9
+ name: CI
10
+
11
+ on: [push,pull_request]
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ fail-fast: false # should GitHub cancel all in-progress jobs if any matrix job fails
19
+ matrix:
20
+ ruby-version: ['2.7']
21
+ gemfile: ['rails_6_0']
22
+ include:
23
+ - ruby-version: '2.7'
24
+ gemfile: 'rails_6_1'
25
+ - ruby-version: '2.7'
26
+ gemfile: 'rails_7_0'
27
+ - ruby-version: '3.0'
28
+ gemfile: 'rails_6_0'
29
+ - ruby-version: '3.0'
30
+ gemfile: 'rails_6_1'
31
+ - ruby-version: '3.0'
32
+ gemfile: 'rails_7_0'
33
+ - ruby-version: '3.1'
34
+ gemfile: 'rails_6_1'
35
+ - ruby-version: '3.1'
36
+ gemfile: 'rails_7_0'
37
+
38
+ env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps
39
+ BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
40
+
41
+ steps:
42
+ - name: Checkout
43
+ uses: actions/checkout@v2
44
+
45
+ - name: Set up Ruby ${{ matrix.ruby-version }} and bundle ${{ matrix.gemfile }}
46
+ uses: ruby/setup-ruby@v1
47
+ with:
48
+ ruby-version: ${{ matrix.ruby-version }}
49
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
50
+
51
+ - name: Run the tests
52
+ run: bundle exec rspec
data/.gitignore ADDED
@@ -0,0 +1,20 @@
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
12
+
13
+ # dummy application
14
+ /spec/dummy/db/*.sqlite3
15
+ /spec/dummy/log/*.log
16
+ /spec/dummy/storage/
17
+ /spec/dummy/tmp/
18
+
19
+ # appraisals gemfile lockfiles
20
+ /gemfiles/*.gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,42 @@
1
+ # .rubocop.yml
2
+
3
+ # Based article from Evil Martians
4
+ # https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard
5
+ # referenced in standard readme relating to use of Standard with Rubocop extensions
6
+ # https://github.com/testdouble/standard
7
+
8
+ # We want Exclude directives from different
9
+ # config files to get merged, not overwritten
10
+ inherit_mode:
11
+ merge:
12
+ - Exclude
13
+
14
+ require:
15
+ # Performance cops are bundled with Standard
16
+ - rubocop-performance
17
+ # Standard's config uses this custom cop,
18
+ # so it must be loaded
19
+ - standard/cop/block_single_line_braces
20
+
21
+ inherit_gem:
22
+ standard: config/base.yml
23
+
24
+ inherit_from:
25
+ - .rubocop_rails.yml
26
+ - .rubocop_rspec.yml
27
+
28
+ AllCops:
29
+ NewCops: enable
30
+ TargetRubyVersion: 2.7
31
+ Exclude:
32
+ - "spec/dummy/config/*"
33
+ - "spec/dummy/config/environments/*"
34
+ - "spec/dummy/db/schema.rb"
35
+ - "spec/spec_helper.rb"
36
+
37
+ # Exclude cop for base class with equality comparison
38
+ # so the gem does not need a dependency on ActionPack
39
+ Style/ClassEqualityComparison:
40
+ Enabled: true
41
+ Exclude:
42
+ - "lib/active_manageable/base.rb"
@@ -0,0 +1,201 @@
1
+ # Copy of Evil Martians config file
2
+ # https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard
3
+ # https://gist.github.com/palkan/24869b835c45e89116b9727b534e579e
4
+ # Based on removed standard configuration:
5
+ # https://github.com/testdouble/standard/commit/94d133f477a5694084ac974d5ee01e8a66ce777e#diff-65478e10d5b2ef41c7293a110c0e6b7c
6
+
7
+ require:
8
+ - rubocop-rails
9
+
10
+ Rails/ActionFilter:
11
+ Enabled: true
12
+ EnforcedStyle: action
13
+ Include:
14
+ - app/controllers/**/*.rb
15
+
16
+ Rails/ActiveRecordAliases:
17
+ Enabled: true
18
+
19
+ Rails/ActiveSupportAliases:
20
+ Enabled: true
21
+
22
+ Rails/ApplicationJob:
23
+ Enabled: true
24
+
25
+ Rails/ApplicationRecord:
26
+ Enabled: true
27
+
28
+ Rails/AssertNot:
29
+ Enabled: true
30
+ Include:
31
+ - '**/test/**/*'
32
+
33
+ Rails/Blank:
34
+ Enabled: true
35
+ # Convert usages of `nil? || empty?` to `blank?`
36
+ NilOrEmpty: true
37
+ # Convert usages of `!present?` to `blank?`
38
+ NotPresent: true
39
+ # Convert usages of `unless present?` to `if blank?`
40
+ UnlessPresent: true
41
+
42
+ Rails/BulkChangeTable:
43
+ Enabled: true
44
+ Database: null
45
+ Include:
46
+ - db/migrate/*.rb
47
+
48
+ Rails/CreateTableWithTimestamps:
49
+ Enabled: true
50
+ Include:
51
+ - db/migrate/*.rb
52
+
53
+ Rails/Date:
54
+ Enabled: true
55
+ EnforcedStyle: flexible
56
+
57
+ Rails/Delegate:
58
+ Enabled: true
59
+ EnforceForPrefixed: true
60
+
61
+ Rails/DelegateAllowBlank:
62
+ Enabled: true
63
+
64
+ Rails/DynamicFindBy:
65
+ Enabled: true
66
+ Whitelist:
67
+ - find_by_sql
68
+
69
+ Rails/EnumUniqueness:
70
+ Enabled: true
71
+ Include:
72
+ - app/models/**/*.rb
73
+
74
+ Rails/EnvironmentComparison:
75
+ Enabled: true
76
+
77
+ Rails/Exit:
78
+ Enabled: true
79
+ Include:
80
+ - app/**/*.rb
81
+ - config/**/*.rb
82
+ - lib/**/*.rb
83
+ Exclude:
84
+ - lib/**/*.rake
85
+
86
+ Rails/FilePath:
87
+ Enabled: true
88
+ EnforcedStyle: arguments
89
+
90
+ Rails/FindBy:
91
+ Enabled: true
92
+ Include:
93
+ - app/models/**/*.rb
94
+
95
+ Rails/FindEach:
96
+ Enabled: true
97
+ Include:
98
+ - app/models/**/*.rb
99
+
100
+ Rails/HasAndBelongsToMany:
101
+ Enabled: true
102
+ Include:
103
+ - app/models/**/*.rb
104
+
105
+ Rails/HttpPositionalArguments:
106
+ Enabled: true
107
+ Include:
108
+ - 'spec/**/*'
109
+ - 'test/**/*'
110
+
111
+ Rails/HttpStatus:
112
+ Enabled: true
113
+ EnforcedStyle: symbolic
114
+
115
+ Rails/InverseOf:
116
+ Enabled: true
117
+ Include:
118
+ - app/models/**/*.rb
119
+
120
+ Rails/LexicallyScopedActionFilter:
121
+ Enabled: true
122
+ Safe: false
123
+ Include:
124
+ - app/controllers/**/*.rb
125
+
126
+ Rails/NotNullColumn:
127
+ Enabled: true
128
+ Include:
129
+ - db/migrate/*.rb
130
+
131
+ Rails/Output:
132
+ Enabled: true
133
+ Include:
134
+ - app/**/*.rb
135
+ - config/**/*.rb
136
+ - db/**/*.rb
137
+ - lib/**/*.rb
138
+
139
+ Rails/OutputSafety:
140
+ Enabled: true
141
+
142
+ Rails/PluralizationGrammar:
143
+ Enabled: true
144
+
145
+ Rails/Presence:
146
+ Enabled: true
147
+
148
+ Rails/Present:
149
+ Enabled: true
150
+ NotNilAndNotEmpty: true
151
+ NotBlank: true
152
+ UnlessBlank: true
153
+
154
+ Rails/ReadWriteAttribute:
155
+ Enabled: true
156
+ Include:
157
+ - app/models/**/*.rb
158
+
159
+ Rails/RedundantReceiverInWithOptions:
160
+ Enabled: true
161
+
162
+ Rails/RefuteMethods:
163
+ Enabled: true
164
+ Include:
165
+ - '**/test/**/*'
166
+
167
+ Rails/RelativeDateConstant:
168
+ Enabled: true
169
+ AutoCorrect: false
170
+
171
+ Rails/RequestReferer:
172
+ Enabled: true
173
+ EnforcedStyle: referer
174
+
175
+ Rails/ReversibleMigration:
176
+ Enabled: true
177
+ Include:
178
+ - db/migrate/*.rb
179
+
180
+ Rails/SafeNavigation:
181
+ Enabled: true
182
+ ConvertTry: false
183
+
184
+ Rails/ScopeArgs:
185
+ Enabled: true
186
+ Include:
187
+ - app/models/**/*.rb
188
+
189
+ Rails/TimeZone:
190
+ Enabled: true
191
+ EnforcedStyle: flexible
192
+
193
+ Rails/UniqBeforePluck:
194
+ Enabled: true
195
+ EnforcedStyle: conservative
196
+ AutoCorrect: false
197
+
198
+ Rails/Validation:
199
+ Enabled: true
200
+ Include:
201
+ - app/models/**/*.rb
@@ -0,0 +1,68 @@
1
+ # Copy of Evil Martians config file
2
+ # https://evilmartians.com/chronicles/rubocoping-with-legacy-bring-your-ruby-code-up-to-standard
3
+ # https://gist.github.com/palkan/623c0816b05ed246bfe0cb406050990a
4
+
5
+ require:
6
+ - rubocop-rspec
7
+
8
+ RSpec/Focus:
9
+ Enabled: true
10
+
11
+ RSpec/EmptyExampleGroup:
12
+ Enabled: true
13
+
14
+ RSpec/EmptyLineAfterExampleGroup:
15
+ Enabled: true
16
+
17
+ RSpec/EmptyLineAfterFinalLet:
18
+ Enabled: true
19
+
20
+ RSpec/EmptyLineAfterHook:
21
+ Enabled: true
22
+
23
+ RSpec/EmptyLineAfterSubject:
24
+ Enabled: true
25
+
26
+ RSpec/HookArgument:
27
+ Enabled: true
28
+
29
+ RSpec/HooksBeforeExamples:
30
+ Enabled: true
31
+
32
+ RSpec/ImplicitExpect:
33
+ Enabled: true
34
+
35
+ RSpec/IteratedExpectation:
36
+ Enabled: true
37
+
38
+ RSpec/LetBeforeExamples:
39
+ Enabled: true
40
+
41
+ RSpec/MissingExampleGroupArgument:
42
+ Enabled: true
43
+
44
+ RSpec/ReceiveCounts:
45
+ Enabled: true
46
+
47
+ RSpec/Capybara:
48
+ Enabled: true
49
+
50
+ RSpec/FactoryBot:
51
+ Enabled: true
52
+
53
+ RSpec/NestedGroups:
54
+ Max: 5
55
+
56
+ RSpec/ExampleLength:
57
+ Max: 20
58
+
59
+ RSpec/MultipleExpectations:
60
+ Max: 10
61
+
62
+ # disabled as using expect_any_instance_of(ActiveRecord::Relation)
63
+ # to check for calls to :includes and :preload etc
64
+ RSpec/AnyInstance:
65
+ Enabled: false
66
+
67
+ RSpec/DescribedClass:
68
+ Enabled: false
data/.standard.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Standard ruby style guide, linter, and formatter https://github.com/testdouble/standard
2
+ # to check the style of files run:-
3
+ # $ bundle exec standardrb
4
+ ignore:
5
+ - 'active_manageable.gemspec'
data/Appraisals ADDED
@@ -0,0 +1,27 @@
1
+ # Appraisal integrates with bundler and rake to test your library
2
+ # against different versions of dependencies in repeatable scenarios called "appraisals"
3
+ # https://github.com/thoughtbot/appraisal
4
+ #
5
+ # The dependencies in your Appraisals file are combined with dependencies in your Gemfile
6
+ #
7
+ # Install the dependencies for each appraisal
8
+ # $ bundle exec appraisal install
9
+ # which generates a Gemfile for each appraisal in the gemfiles directory
10
+ #
11
+ # Run each appraisal in turn or a single appraisal:-
12
+ # $ bundle exec appraisal rspec
13
+ # $ bundle exec appraisal rails-6-1 rspec
14
+ appraise "rails-7-0" do
15
+ gem "activerecord", "~> 7.0"
16
+ gem "activesupport", "~> 7.0"
17
+ end
18
+
19
+ appraise "rails-6-1" do
20
+ gem "activerecord", "~> 6.1"
21
+ gem "activesupport", "~> 6.1"
22
+ end
23
+
24
+ appraise "rails-6-0" do
25
+ gem "activerecord", "~> 6.0.1"
26
+ gem "activesupport", "~> 6.0.1"
27
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Change Log
2
+
3
+ ## 0.1.0 - 2022-03-21
4
+
5
+ * Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 138595+chrisbranson@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in active_manageable.gemspec
6
+ gemspec