mongo_db_store 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.rspec +3 -0
- data/.rubocop.yml +258 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/active_support/cache/mongo_db_store.rb +77 -0
- data/lib/mongo_db_store/version.rb +4 -0
- data/lib/mongo_db_store.rb +9 -0
- data/mongo_db_store.gemspec +31 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 530fd715346270e8e175684441f3f00a972fe927
|
4
|
+
data.tar.gz: 638083831a9e42254408c7a26119857a98c9978b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 96ca9e5d31faf80ac1733f15aa68144d108fed6e12078d4e1e9f5862b6feba955d9d9675135312a941824574b1968e778cc0e1a1ba11d554a4dadd3a1d1db993
|
7
|
+
data.tar.gz: f6cb709b720aea84baf98f2586113d849cdc4e5bb3ed1fa7eaeb9a9e4a97b4330974d4eaa60c73b8549b2eb2a84928477e917b6a307b9bef7cfc3f0f81e02e14
|
data/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
## Specific to RubyMotion:
|
17
|
+
.dat*
|
18
|
+
.repl_history
|
19
|
+
build/
|
20
|
+
*.bridgesupport
|
21
|
+
build-iPhoneOS/
|
22
|
+
build-iPhoneSimulator/
|
23
|
+
|
24
|
+
## Specific to RubyMotion (use of CocoaPods):
|
25
|
+
#
|
26
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
27
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
28
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
29
|
+
#
|
30
|
+
# vendor/Pods/
|
31
|
+
|
32
|
+
## Documentation cache and generated files:
|
33
|
+
/.yardoc/
|
34
|
+
/_yardoc/
|
35
|
+
/doc/
|
36
|
+
/rdoc/
|
37
|
+
|
38
|
+
## Environment normalization:
|
39
|
+
/.bundle/
|
40
|
+
/vendor/bundle
|
41
|
+
/lib/bundler/man/
|
42
|
+
|
43
|
+
# for a library or gem, you might want to ignore these files since the code is
|
44
|
+
# intended to run in multiple environments; otherwise, check them in:
|
45
|
+
Gemfile.lock
|
46
|
+
#.ruby-version
|
47
|
+
#.ruby-gemset
|
48
|
+
|
49
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
50
|
+
.rvmrc
|
51
|
+
.idea/
|
52
|
+
.rspec_status
|
53
|
+
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,258 @@
|
|
1
|
+
Rails:
|
2
|
+
Enabled: true
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
DisplayCopNames: true
|
6
|
+
Exclude:
|
7
|
+
- "vendor/**/*"
|
8
|
+
- "db/schema.rb"
|
9
|
+
- "bin/**/*"
|
10
|
+
- "finapps.gemspec"
|
11
|
+
UseCache: false
|
12
|
+
|
13
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
14
|
+
Metrics/LineLength:
|
15
|
+
Max: 120
|
16
|
+
|
17
|
+
# No space makes the method definition shorter and differentiates
|
18
|
+
# from a regular assignment.
|
19
|
+
Style/SpaceAroundEqualsInParameterDefault:
|
20
|
+
EnforcedStyle: no_space
|
21
|
+
|
22
|
+
Style/SpaceInsideBlockBraces:
|
23
|
+
# The space here provides no real gain in readability while consuming
|
24
|
+
# horizontal space that could be used for a better parameter name.
|
25
|
+
# Also {| differentiates better from a hash than { | does.
|
26
|
+
SpaceBeforeBlockParameters: false
|
27
|
+
|
28
|
+
# No trailing space differentiates better from the block:
|
29
|
+
# foo} means hash, foo } means block.
|
30
|
+
Style/SpaceInsideHashLiteralBraces:
|
31
|
+
EnforcedStyle: no_space
|
32
|
+
|
33
|
+
|
34
|
+
Style/CollectionMethods:
|
35
|
+
Description: Preferred collection methods.
|
36
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
37
|
+
Enabled: true
|
38
|
+
PreferredMethods:
|
39
|
+
collect: map
|
40
|
+
collect!: map!
|
41
|
+
find: detect
|
42
|
+
find_all: select
|
43
|
+
reduce: inject
|
44
|
+
Style/DotPosition:
|
45
|
+
Description: Checks the position of the dot in multi-line method calls.
|
46
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
47
|
+
Enabled: true
|
48
|
+
EnforcedStyle: leading
|
49
|
+
SupportedStyles:
|
50
|
+
- leading
|
51
|
+
- trailing
|
52
|
+
Style/FileName:
|
53
|
+
Description: Use snake_case for source file names.
|
54
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
55
|
+
Enabled: false
|
56
|
+
Exclude: []
|
57
|
+
Style/GuardClause:
|
58
|
+
Description: Check for conditionals that can be replaced with guard clauses
|
59
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
60
|
+
Enabled: false
|
61
|
+
MinBodyLength: 1
|
62
|
+
Style/IfUnlessModifier:
|
63
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
64
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
65
|
+
Enabled: false
|
66
|
+
MaxLineLength: 80
|
67
|
+
Style/OptionHash:
|
68
|
+
Description: Don't use option hashes when you can use keyword arguments.
|
69
|
+
Enabled: false
|
70
|
+
Style/PercentLiteralDelimiters:
|
71
|
+
Description: Use `%`-literal delimiters consistently
|
72
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
|
73
|
+
Enabled: false
|
74
|
+
PreferredDelimiters:
|
75
|
+
"%": "()"
|
76
|
+
"%i": "()"
|
77
|
+
"%q": "()"
|
78
|
+
"%Q": "()"
|
79
|
+
"%r": "{}"
|
80
|
+
"%s": "()"
|
81
|
+
"%w": "()"
|
82
|
+
"%W": "()"
|
83
|
+
"%x": "()"
|
84
|
+
Style/PredicateName:
|
85
|
+
Description: Check the names of predicate methods.
|
86
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
87
|
+
Enabled: true
|
88
|
+
NamePrefix:
|
89
|
+
- is_
|
90
|
+
- has_
|
91
|
+
- have_
|
92
|
+
NamePrefixBlacklist:
|
93
|
+
- is_
|
94
|
+
Exclude:
|
95
|
+
- spec/**/*
|
96
|
+
Style/RaiseArgs:
|
97
|
+
Description: Checks the arguments passed to raise/fail.
|
98
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
99
|
+
Enabled: false
|
100
|
+
EnforcedStyle: exploded
|
101
|
+
SupportedStyles:
|
102
|
+
- compact
|
103
|
+
- exploded
|
104
|
+
Style/SignalException:
|
105
|
+
Description: Checks for proper usage of fail and raise.
|
106
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
107
|
+
Enabled: false
|
108
|
+
EnforcedStyle: semantic
|
109
|
+
SupportedStyles:
|
110
|
+
- only_raise
|
111
|
+
- only_fail
|
112
|
+
- semantic
|
113
|
+
Style/SingleLineBlockParams:
|
114
|
+
Description: Enforces the names of some block params.
|
115
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
116
|
+
Enabled: false
|
117
|
+
Methods:
|
118
|
+
- reduce:
|
119
|
+
- a
|
120
|
+
- e
|
121
|
+
- inject:
|
122
|
+
- a
|
123
|
+
- e
|
124
|
+
Style/SingleLineMethods:
|
125
|
+
Description: Avoid single-line methods.
|
126
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
127
|
+
Enabled: false
|
128
|
+
AllowIfMethodIsEmpty: true
|
129
|
+
Style/StringLiterals:
|
130
|
+
Description: Checks if uses of quotes match the configured preference.
|
131
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
132
|
+
Enabled: true
|
133
|
+
EnforcedStyle: single_quotes
|
134
|
+
SupportedStyles:
|
135
|
+
- single_quotes
|
136
|
+
- double_quotes
|
137
|
+
Style/StringLiteralsInInterpolation:
|
138
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
139
|
+
match the configured preference.
|
140
|
+
Enabled: true
|
141
|
+
EnforcedStyle: single_quotes
|
142
|
+
SupportedStyles:
|
143
|
+
- single_quotes
|
144
|
+
- double_quotes
|
145
|
+
Metrics/AbcSize:
|
146
|
+
Description: A calculated magnitude based on number of assignments, branches, and
|
147
|
+
conditions.
|
148
|
+
Enabled: false
|
149
|
+
Max: 15
|
150
|
+
Metrics/BlockLength:
|
151
|
+
ExcludedMethods: ['describe', 'context']
|
152
|
+
Metrics/ClassLength:
|
153
|
+
Description: Avoid classes longer than 100 lines of code.
|
154
|
+
Enabled: false
|
155
|
+
CountComments: false
|
156
|
+
Max: 100
|
157
|
+
Metrics/ModuleLength:
|
158
|
+
CountComments: false
|
159
|
+
Max: 100
|
160
|
+
Description: Avoid modules longer than 100 lines of code.
|
161
|
+
Enabled: false
|
162
|
+
Metrics/CyclomaticComplexity:
|
163
|
+
Description: A complexity metric that is strongly correlated to the number of test
|
164
|
+
cases needed to validate a method.
|
165
|
+
Enabled: false
|
166
|
+
Max: 6
|
167
|
+
Metrics/MethodLength:
|
168
|
+
Description: Avoid methods longer than 10 lines of code.
|
169
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
170
|
+
Enabled: false
|
171
|
+
CountComments: false
|
172
|
+
Max: 10
|
173
|
+
Metrics/ParameterLists:
|
174
|
+
Description: Avoid parameter lists longer than three or four parameters.
|
175
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
176
|
+
Enabled: false
|
177
|
+
Max: 5
|
178
|
+
CountKeywordArgs: true
|
179
|
+
Metrics/PerceivedComplexity:
|
180
|
+
Description: A complexity metric geared towards measuring complexity for a human
|
181
|
+
reader.
|
182
|
+
Enabled: false
|
183
|
+
Max: 7
|
184
|
+
Lint/AssignmentInCondition:
|
185
|
+
Description: Don't use assignment in conditions.
|
186
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
187
|
+
Enabled: false
|
188
|
+
AllowSafeAssignment: true
|
189
|
+
Style/InlineComment:
|
190
|
+
Description: Avoid inline comments.
|
191
|
+
Enabled: false
|
192
|
+
Style/AccessorMethodName:
|
193
|
+
Description: Check the naming of accessor methods for get_/set_.
|
194
|
+
Enabled: false
|
195
|
+
Style/Alias:
|
196
|
+
Description: Use alias_method instead of alias.
|
197
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
198
|
+
Enabled: false
|
199
|
+
Style/Documentation:
|
200
|
+
Description: Document classes and non-namespace modules.
|
201
|
+
Enabled: false
|
202
|
+
Style/DoubleNegation:
|
203
|
+
Description: Checks for uses of double negation (!!).
|
204
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
205
|
+
Enabled: false
|
206
|
+
Style/EachWithObject:
|
207
|
+
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
208
|
+
Enabled: false
|
209
|
+
Style/EmptyLiteral:
|
210
|
+
Description: Prefer literals to Array.new/Hash.new/String.new.
|
211
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
212
|
+
Enabled: false
|
213
|
+
Style/ModuleFunction:
|
214
|
+
Description: Checks for usage of `extend self` in modules.
|
215
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
216
|
+
Enabled: false
|
217
|
+
Style/OneLineConditional:
|
218
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
219
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
220
|
+
Enabled: false
|
221
|
+
Style/PerlBackrefs:
|
222
|
+
Description: Avoid Perl-style regex back references.
|
223
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
224
|
+
Enabled: false
|
225
|
+
Style/Send:
|
226
|
+
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
227
|
+
may overlap with existing methods.
|
228
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
229
|
+
Enabled: false
|
230
|
+
Style/SpecialGlobalVars:
|
231
|
+
Description: Avoid Perl-style global variables.
|
232
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
233
|
+
Enabled: false
|
234
|
+
Style/VariableInterpolation:
|
235
|
+
Description: Don't interpolate global, instance and class variables directly in
|
236
|
+
strings.
|
237
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
238
|
+
Enabled: false
|
239
|
+
Style/WhenThen:
|
240
|
+
Description: Use when x then ... for one-line cases.
|
241
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
242
|
+
Enabled: false
|
243
|
+
Lint/EachWithObjectArgument:
|
244
|
+
Description: Check for immutable argument given to each_with_object.
|
245
|
+
Enabled: true
|
246
|
+
Lint/HandleExceptions:
|
247
|
+
Description: Don't suppress exception.
|
248
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
249
|
+
Enabled: false
|
250
|
+
Lint/LiteralInCondition:
|
251
|
+
Description: Checks of literals used in conditions.
|
252
|
+
Enabled: false
|
253
|
+
Lint/LiteralInInterpolation:
|
254
|
+
Description: Checks for literals used in interpolation.
|
255
|
+
Enabled: false
|
256
|
+
|
257
|
+
Security/MarshalLoad:
|
258
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
mongo_db_store
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/.travis.yml
ADDED
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 qbantek@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
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
lsMIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Erich Quintero
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'mongo_db_store'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'mongoid'
|
5
|
+
require 'active_support'
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module ActiveSupport
|
9
|
+
module Cache
|
10
|
+
class MongoDbStore < Store
|
11
|
+
attr_reader :collection_name
|
12
|
+
|
13
|
+
def initialize(options={})
|
14
|
+
@collection_name = options[:collection] || :rails_cache
|
15
|
+
options[:expires_in] ||= 1.day
|
16
|
+
super(options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def clear
|
20
|
+
collection.find.delete_many
|
21
|
+
end
|
22
|
+
|
23
|
+
def cleanup
|
24
|
+
collection.find(expires_at: {'$lt' => Time.now.utc.to_i}).delete_many
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [Regexp] matcher
|
28
|
+
# @param [Hash] options
|
29
|
+
def delete_matched(matcher, options=nil)
|
30
|
+
options = merged_options(options)
|
31
|
+
collection.find(_id: key_matcher(matcher, options)).delete_many
|
32
|
+
end
|
33
|
+
|
34
|
+
def delete_entry(key)
|
35
|
+
collection.find(_id: key).delete_one
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
|
40
|
+
def write_entry(key, entry, options)
|
41
|
+
expires_at = entry.expires_at.to_i
|
42
|
+
created_at = Time.now.utc.to_i
|
43
|
+
value = options[:raw] ? entry.value.to_s : entry
|
44
|
+
rescue_error_with false do
|
45
|
+
collection.find(_id: key).update_one({'$set' => {data: Base64.encode64(Marshal.dump(value)),
|
46
|
+
expires_at: expires_at,
|
47
|
+
created_at: created_at}},
|
48
|
+
upsert: true)
|
49
|
+
end
|
50
|
+
entry
|
51
|
+
end
|
52
|
+
|
53
|
+
def read_entry(key, _)
|
54
|
+
doc = collection.find(_id: key, expires_at: {'$gt' => Time.now.utc.to_i}).first
|
55
|
+
rescue_error_with(nil) { deserialize_entry(doc['data']) } if doc
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def collection
|
61
|
+
::Mongoid.default_client[collection_name]
|
62
|
+
end
|
63
|
+
|
64
|
+
def deserialize_entry(raw_value)
|
65
|
+
entry = Marshal.load(Base64.decode64(raw_value))
|
66
|
+
entry.is_a?(Entry) ? entry : Entry.new(entry)
|
67
|
+
end
|
68
|
+
|
69
|
+
def rescue_error_with(fallback)
|
70
|
+
yield
|
71
|
+
rescue StandardError => e
|
72
|
+
Rails.logger.error("Error (#{e}): #{e.message}")
|
73
|
+
fallback
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'mongo_db_store/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'mongo_db_store'
|
10
|
+
spec.version = MongoDbStore::VERSION
|
11
|
+
spec.authors = ['Erich Quintero']
|
12
|
+
spec.email = ['qbantek@gmail.com']
|
13
|
+
|
14
|
+
spec.summary = 'Rails-compatible cache store for MongoDB using Mongoid.'
|
15
|
+
spec.homepage = 'https://github.com/qbantek/mongo_db_store'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'mongoid', '~> 6.1'
|
26
|
+
spec.add_runtime_dependency 'activesupport', '~> 5.1'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mongo_db_store
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Erich Quintero
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mongoid
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- qbantek@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".ruby-gemset"
|
94
|
+
- ".ruby-version"
|
95
|
+
- ".travis.yml"
|
96
|
+
- CODE_OF_CONDUCT.md
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/setup
|
103
|
+
- lib/active_support/cache/mongo_db_store.rb
|
104
|
+
- lib/mongo_db_store.rb
|
105
|
+
- lib/mongo_db_store/version.rb
|
106
|
+
- mongo_db_store.gemspec
|
107
|
+
homepage: https://github.com/qbantek/mongo_db_store
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.6.12
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: Rails-compatible cache store for MongoDB using Mongoid.
|
131
|
+
test_files: []
|