ar_cache 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +68 -0
  3. data/.gitignore +8 -0
  4. data/.rubocop.yml +56 -0
  5. data/CODE_OF_CONDUCT.md +84 -0
  6. data/Gemfile +7 -0
  7. data/Gemfile.common +17 -0
  8. data/Gemfile.lock +192 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +166 -0
  11. data/Rakefile +28 -0
  12. data/ar_cache.gemspec +34 -0
  13. data/bin/activerecord-test +20 -0
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/gemfiles/rails-6-1 +3 -0
  17. data/gemfiles/rails-edge +3 -0
  18. data/lib/ar_cache.rb +22 -0
  19. data/lib/ar_cache/active_record.rb +36 -0
  20. data/lib/ar_cache/active_record/associations/has_one_through_association.rb +39 -0
  21. data/lib/ar_cache/active_record/associations/singular_association.rb +18 -0
  22. data/lib/ar_cache/active_record/connection_adapters/abstract/database_statements.rb +76 -0
  23. data/lib/ar_cache/active_record/connection_adapters/abstract/transaction.rb +90 -0
  24. data/lib/ar_cache/active_record/core.rb +21 -0
  25. data/lib/ar_cache/active_record/insert_all.rb +17 -0
  26. data/lib/ar_cache/active_record/model_schema.rb +27 -0
  27. data/lib/ar_cache/active_record/persistence.rb +23 -0
  28. data/lib/ar_cache/active_record/relation.rb +48 -0
  29. data/lib/ar_cache/configuration.rb +59 -0
  30. data/lib/ar_cache/log_subscriber.rb +8 -0
  31. data/lib/ar_cache/marshal.rb +81 -0
  32. data/lib/ar_cache/mock_table.rb +55 -0
  33. data/lib/ar_cache/query.rb +95 -0
  34. data/lib/ar_cache/record.rb +54 -0
  35. data/lib/ar_cache/store.rb +38 -0
  36. data/lib/ar_cache/table.rb +126 -0
  37. data/lib/ar_cache/version.rb +5 -0
  38. data/lib/ar_cache/where_clause.rb +151 -0
  39. data/lib/generators/ar_cache/install_generator.rb +22 -0
  40. data/lib/generators/ar_cache/templates/configuration.rb +34 -0
  41. data/lib/generators/ar_cache/templates/migrate/create_ar_cache_records.rb.tt +16 -0
  42. metadata +107 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8eab4ff7873091b901a45bfa48e948679d7feda3e0e547201d3f5ab931bbf77e
4
+ data.tar.gz: 642654c010e8ced742980a0657480305be9904835a23715d884df3a90d42eef8
5
+ SHA512:
6
+ metadata.gz: a41629683860591506020f8ee516d6d3948ac0daf5381dff1c1b3410fc659be978a4f27d31c0ba49be3fbdf9fd608e7c424a215f5efd75842f5fbe47b31a2d75
7
+ data.tar.gz: 71dc11fbccc0816af45df3a1e3e3b3460c595f67fed0376afb9202237367970593441937131e80514d7dfd6bd601d4d2bdc3e3329267c9f6370efb36708291ec
@@ -0,0 +1,68 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ # NOTE: I don’t know why can’t connect to the follows services.
13
+ # services:
14
+ # postgres:
15
+ # image: postgres
16
+ # env:
17
+ # POSTGRES_PASSWORD: postgres
18
+ # ports:
19
+ # - 5432:5432
20
+ # options: >-
21
+ # --health-cmd pg_isready
22
+ # --health-interval 10s
23
+ # --health-timeout 5s
24
+ # --health-retries 5
25
+ # mysql:
26
+ # image: mysql
27
+ # env:
28
+ # MYSQL_ROOT_PASSWORD: mysql
29
+ # ports:
30
+ # - 3306:3306
31
+ # options: >-
32
+ # --health-cmd 'mysqladmin ping'
33
+ # --health-interval 10s
34
+ # --health-timeout 5s
35
+ # --health-retries 5
36
+ strategy:
37
+ fail-fast: false
38
+ matrix:
39
+ ruby-version: [3.0]
40
+ gemfile: [rails-6-1]
41
+ experimental: [false]
42
+ # include:
43
+ # - gemfile: rails-edge
44
+ # ruby-version: 3.0
45
+ # experimental: true
46
+ env:
47
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
48
+ continue-on-error: ${{ matrix.experimental }}
49
+ steps:
50
+ - name: GitHub Actions
51
+ uses: actions/checkout@v2
52
+ - name: Setup Ruby
53
+ uses: ruby/setup-ruby@v1.64.1
54
+ with:
55
+ ruby-version: ${{ matrix.ruby-version }}
56
+ bundler-cache: true
57
+ - name: Setup PostgreSQL
58
+ run: |
59
+ sudo apt-get -y install postgresql libpq-dev
60
+ sudo service postgresql start
61
+ sudo -u postgres createuser --superuser "$USER"
62
+ - name: Run ArCache Test
63
+ run: |
64
+ gem install bundler
65
+ bundle install
66
+ bundle exec rake
67
+ - name: Run ActiveRecord Test
68
+ run: bin/activerecord-test
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,56 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-minitest
4
+ - rubocop-rails
5
+ - rubocop-rake
6
+
7
+ AllCops:
8
+ NewCops: enable
9
+
10
+ Rails/SkipsModelValidations:
11
+ Exclude:
12
+ - '**/test/**/*'
13
+
14
+ Metrics/BlockLength:
15
+ Enabled: true
16
+ Exclude:
17
+ - '**/test/**/*'
18
+
19
+ Metrics/AbcSize:
20
+ Enabled: false
21
+
22
+ Metrics/ClassLength:
23
+ Enabled: true
24
+ Max: 300
25
+
26
+ Metrics/ModuleLength:
27
+ Enabled: true
28
+ Max: 300
29
+
30
+ Metrics/MethodLength:
31
+ Enabled: true
32
+ Max: 25
33
+
34
+ Lint/NestedMethodDefinition:
35
+ Enabled: false
36
+
37
+ Style/AccessModifierDeclarations:
38
+ Enabled: false
39
+
40
+ Style/DoubleNegation:
41
+ Enabled: false
42
+
43
+ Style/ConditionalAssignment:
44
+ Enabled: false
45
+
46
+ Style/Documentation:
47
+ Enabled: false
48
+
49
+ Layout/LineLength:
50
+ Max: 120
51
+
52
+ Bundler/OrderedGems:
53
+ Enabled: false
54
+
55
+ Gemspec/OrderedDependencies:
56
+ Enabled: false
@@ -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 2729877005qq@gmail.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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ eval_gemfile 'Gemfile.common'
4
+
5
+ gem 'rails'
6
+
7
+ gem 'pry'
data/Gemfile.common ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ar_cache.gemspec
4
+ gemspec
5
+
6
+ gem 'rake'
7
+
8
+ gem 'sqlite3'
9
+ gem 'database_cleaner'
10
+
11
+ gem 'rubocop'
12
+ gem 'rubocop-rake'
13
+ gem 'rubocop-rails'
14
+ gem 'rubocop-minitest'
15
+ gem 'rubocop-performance'
16
+
17
+ gem 'minitest'
data/Gemfile.lock ADDED
@@ -0,0 +1,192 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ar_cache (1.0.0)
5
+ activerecord (>= 6.1, < 7)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.1)
11
+ actionpack (= 6.1.1)
12
+ activesupport (= 6.1.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.1)
16
+ actionpack (= 6.1.1)
17
+ activejob (= 6.1.1)
18
+ activerecord (= 6.1.1)
19
+ activestorage (= 6.1.1)
20
+ activesupport (= 6.1.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.1)
23
+ actionpack (= 6.1.1)
24
+ actionview (= 6.1.1)
25
+ activejob (= 6.1.1)
26
+ activesupport (= 6.1.1)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.1)
30
+ actionview (= 6.1.1)
31
+ activesupport (= 6.1.1)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.1)
37
+ actionpack (= 6.1.1)
38
+ activerecord (= 6.1.1)
39
+ activestorage (= 6.1.1)
40
+ activesupport (= 6.1.1)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.1)
43
+ activesupport (= 6.1.1)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.1)
49
+ activesupport (= 6.1.1)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.1)
52
+ activesupport (= 6.1.1)
53
+ activerecord (6.1.1)
54
+ activemodel (= 6.1.1)
55
+ activesupport (= 6.1.1)
56
+ activestorage (6.1.1)
57
+ actionpack (= 6.1.1)
58
+ activejob (= 6.1.1)
59
+ activerecord (= 6.1.1)
60
+ activesupport (= 6.1.1)
61
+ marcel (~> 0.3.1)
62
+ mimemagic (~> 0.3.2)
63
+ activesupport (6.1.1)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ ast (2.4.2)
70
+ builder (3.2.4)
71
+ coderay (1.1.3)
72
+ concurrent-ruby (1.1.8)
73
+ crass (1.0.6)
74
+ database_cleaner (1.8.5)
75
+ erubi (1.10.0)
76
+ globalid (0.4.2)
77
+ activesupport (>= 4.2.0)
78
+ i18n (1.8.7)
79
+ concurrent-ruby (~> 1.0)
80
+ loofah (2.9.0)
81
+ crass (~> 1.0.2)
82
+ nokogiri (>= 1.5.9)
83
+ mail (2.7.1)
84
+ mini_mime (>= 0.1.1)
85
+ marcel (0.3.3)
86
+ mimemagic (~> 0.3.2)
87
+ method_source (1.0.0)
88
+ mimemagic (0.3.5)
89
+ mini_mime (1.0.2)
90
+ minitest (5.14.3)
91
+ nio4r (2.5.4)
92
+ nokogiri (1.11.1-x86_64-linux)
93
+ racc (~> 1.4)
94
+ parallel (1.20.1)
95
+ parser (3.0.0.0)
96
+ ast (~> 2.4.1)
97
+ pry (0.13.1)
98
+ coderay (~> 1.1)
99
+ method_source (~> 1.0)
100
+ racc (1.5.2)
101
+ rack (2.2.3)
102
+ rack-test (1.1.0)
103
+ rack (>= 1.0, < 3)
104
+ rails (6.1.1)
105
+ actioncable (= 6.1.1)
106
+ actionmailbox (= 6.1.1)
107
+ actionmailer (= 6.1.1)
108
+ actionpack (= 6.1.1)
109
+ actiontext (= 6.1.1)
110
+ actionview (= 6.1.1)
111
+ activejob (= 6.1.1)
112
+ activemodel (= 6.1.1)
113
+ activerecord (= 6.1.1)
114
+ activestorage (= 6.1.1)
115
+ activesupport (= 6.1.1)
116
+ bundler (>= 1.15.0)
117
+ railties (= 6.1.1)
118
+ sprockets-rails (>= 2.0.0)
119
+ rails-dom-testing (2.0.3)
120
+ activesupport (>= 4.2.0)
121
+ nokogiri (>= 1.6)
122
+ rails-html-sanitizer (1.3.0)
123
+ loofah (~> 2.3)
124
+ railties (6.1.1)
125
+ actionpack (= 6.1.1)
126
+ activesupport (= 6.1.1)
127
+ method_source
128
+ rake (>= 0.8.7)
129
+ thor (~> 1.0)
130
+ rainbow (3.0.0)
131
+ rake (13.0.3)
132
+ regexp_parser (2.0.3)
133
+ rexml (3.2.4)
134
+ rubocop (1.9.0)
135
+ parallel (~> 1.10)
136
+ parser (>= 3.0.0.0)
137
+ rainbow (>= 2.2.2, < 4.0)
138
+ regexp_parser (>= 1.8, < 3.0)
139
+ rexml
140
+ rubocop-ast (>= 1.2.0, < 2.0)
141
+ ruby-progressbar (~> 1.7)
142
+ unicode-display_width (>= 1.4.0, < 3.0)
143
+ rubocop-ast (1.4.1)
144
+ parser (>= 2.7.1.5)
145
+ rubocop-minitest (0.10.3)
146
+ rubocop (>= 0.87, < 2.0)
147
+ rubocop-performance (1.9.2)
148
+ rubocop (>= 0.90.0, < 2.0)
149
+ rubocop-ast (>= 0.4.0)
150
+ rubocop-rails (2.9.1)
151
+ activesupport (>= 4.2.0)
152
+ rack (>= 1.1)
153
+ rubocop (>= 0.90.0, < 2.0)
154
+ rubocop-rake (0.5.1)
155
+ rubocop
156
+ ruby-progressbar (1.11.0)
157
+ sprockets (4.0.2)
158
+ concurrent-ruby (~> 1.0)
159
+ rack (> 1, < 3)
160
+ sprockets-rails (3.2.2)
161
+ actionpack (>= 4.0)
162
+ activesupport (>= 4.0)
163
+ sprockets (>= 3.0.0)
164
+ sqlite3 (1.4.2)
165
+ thor (1.1.0)
166
+ tzinfo (2.0.4)
167
+ concurrent-ruby (~> 1.0)
168
+ unicode-display_width (2.0.0)
169
+ websocket-driver (0.7.3)
170
+ websocket-extensions (>= 0.1.0)
171
+ websocket-extensions (0.1.5)
172
+ zeitwerk (2.4.2)
173
+
174
+ PLATFORMS
175
+ x86_64-linux
176
+
177
+ DEPENDENCIES
178
+ ar_cache!
179
+ database_cleaner
180
+ minitest
181
+ pry
182
+ rails
183
+ rake
184
+ rubocop
185
+ rubocop-minitest
186
+ rubocop-performance
187
+ rubocop-rails
188
+ rubocop-rake
189
+ sqlite3
190
+
191
+ BUNDLED WITH
192
+ 2.2.3