mongo_auto_increment 0.1.1

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: 6189fb9bb57a8953f2d3de53fd93552465b7383663efce69d47b8b3088ea5cb3
4
+ data.tar.gz: 155fdde7a72a9fa7a741caa7d3d1b1268b76cf3b0c6c0b42a45ff5b794f7ec08
5
+ SHA512:
6
+ metadata.gz: b14746405fa2c71231283b42f1af4360285032ff294998be21799ecb53a5be6e7e3d8d67d75a224e34465255c4218e52e4313032d488b634db309f9170b8c446
7
+ data.tar.gz: fc007a348d694ab2a2556a5390a14a2c9627f31d37a8603f915ad278f44ff90f11a33f8b521c761ae5fd9a7380992b14a0459800241a667719c2fd357b920c15
@@ -0,0 +1,52 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - master
7
+ push:
8
+ branches:
9
+ - master
10
+
11
+ jobs:
12
+ build:
13
+ name: Build + Publish
14
+ runs-on: ubuntu-latest
15
+ services:
16
+ mongodb:
17
+ image: mongo:3.4.23
18
+ ports:
19
+ - 27017:27017
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+ - name: Set up Ruby 2.6
24
+ uses: actions/setup-ruby@v1
25
+ with:
26
+ version: 2.6.x
27
+ - name: Publish to GPR
28
+ run: |
29
+ mkdir -p $HOME/.gem
30
+ touch $HOME/.gem/credentials
31
+ chmod 0600 $HOME/.gem/credentials
32
+ printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
33
+ gem install rspec
34
+ gem install mongoid
35
+ gem install mocha
36
+ rspec
37
+ gem build *.gemspec
38
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
39
+ env:
40
+ GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
41
+ OWNER: guptalakshya92
42
+
43
+ - name: Publish to RubyGems
44
+ run: |
45
+ mkdir -p $HOME/.gem
46
+ touch $HOME/.gem/credentials
47
+ chmod 0600 $HOME/.gem/credentials
48
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
49
+ gem build *.gemspec
50
+ gem push *.gem
51
+ env:
52
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
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/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
@@ -0,0 +1,6 @@
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
+ </profile>
6
+ </component>
data/.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JavaScriptSettings">
4
+ <option name="languageLevel" value="ES6" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.5.5 [global]" project-jdk-type="RUBY_SDK" />
7
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/mongo_auto_increment.iml" filepath="$PROJECT_DIR$/.idea/mongo_auto_increment.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,12 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$" />
8
+ <orderEntry type="inheritedJdk" />
9
+ <orderEntry type="sourceFolder" forTests="false" />
10
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.3, RVM: ruby-2.5.5 [global]) [gem]" level="application" />
11
+ </component>
12
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,339 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ChangeListManager">
4
+ <list default="true" id="b85fc9ee-2118-4eb5-9c34-0438c49d6050" name="Default Changelist" comment="">
5
+ <change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
6
+ <change afterPath="$PROJECT_DIR$/.rspec" afterDir="false" />
7
+ <change afterPath="$PROJECT_DIR$/.travis.yml" afterDir="false" />
8
+ <change afterPath="$PROJECT_DIR$/CODE_OF_CONDUCT.md" afterDir="false" />
9
+ <change afterPath="$PROJECT_DIR$/Gemfile" afterDir="false" />
10
+ <change afterPath="$PROJECT_DIR$/LICENSE.txt" afterDir="false" />
11
+ <change afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
12
+ <change afterPath="$PROJECT_DIR$/Rakefile" afterDir="false" />
13
+ <change afterPath="$PROJECT_DIR$/bin/console" afterDir="false" />
14
+ <change afterPath="$PROJECT_DIR$/bin/setup" afterDir="false" />
15
+ <change afterPath="$PROJECT_DIR$/lib/mongo_auto_increment.rb" afterDir="false" />
16
+ <change afterPath="$PROJECT_DIR$/lib/mongo_auto_increment/config.rb" afterDir="false" />
17
+ <change afterPath="$PROJECT_DIR$/lib/mongo_auto_increment/version.rb" afterDir="false" />
18
+ <change afterPath="$PROJECT_DIR$/mongo_auto_increment.gemspec" afterDir="false" />
19
+ <change afterPath="$PROJECT_DIR$/spec/mongo_auto_increment_spec.rb" afterDir="false" />
20
+ <change afterPath="$PROJECT_DIR$/spec/spec_helper.rb" afterDir="false" />
21
+ </list>
22
+ <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
23
+ <option name="SHOW_DIALOG" value="false" />
24
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
25
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
26
+ <option name="LAST_RESOLUTION" value="IGNORE" />
27
+ </component>
28
+ <component name="FileEditorManager">
29
+ <leaf>
30
+ <file pinned="false" current-in-tab="false">
31
+ <entry file="file://$PROJECT_DIR$/spec/base_spec.rb">
32
+ <provider selected="true" editor-type-id="text-editor">
33
+ <state relative-caret-position="330">
34
+ <caret line="130" column="73" selection-start-line="130" selection-start-column="73" selection-end-line="130" selection-end-column="73" />
35
+ </state>
36
+ </provider>
37
+ </entry>
38
+ </file>
39
+ <file pinned="false" current-in-tab="false">
40
+ <entry file="file://$PROJECT_DIR$/spec/mongo_auto_increment_spec.rb">
41
+ <provider selected="true" editor-type-id="text-editor">
42
+ <state relative-caret-position="60">
43
+ <caret line="4" column="2" selection-start-line="4" selection-start-column="2" selection-end-line="4" selection-end-column="2" />
44
+ </state>
45
+ </provider>
46
+ </entry>
47
+ </file>
48
+ <file pinned="false" current-in-tab="true">
49
+ <entry file="file://$PROJECT_DIR$/README.md">
50
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
51
+ <state split_layout="SPLIT">
52
+ <first_editor relative-caret-position="-415">
53
+ <caret line="31" column="31" lean-forward="true" selection-start-line="31" selection-start-column="31" selection-end-line="31" selection-end-column="31" />
54
+ </first_editor>
55
+ <second_editor />
56
+ </state>
57
+ </provider>
58
+ </entry>
59
+ </file>
60
+ <file pinned="false" current-in-tab="false">
61
+ <entry file="file://$PROJECT_DIR$/lib/mongo_auto_increment/version.rb">
62
+ <provider selected="true" editor-type-id="text-editor" />
63
+ </entry>
64
+ </file>
65
+ <file pinned="false" current-in-tab="false">
66
+ <entry file="file://$PROJECT_DIR$/spec/models.rb">
67
+ <provider selected="true" editor-type-id="text-editor">
68
+ <state relative-caret-position="160">
69
+ <caret line="13" column="6" selection-start-line="13" selection-start-column="6" selection-end-line="13" selection-end-column="6" />
70
+ </state>
71
+ </provider>
72
+ </entry>
73
+ </file>
74
+ <file pinned="false" current-in-tab="false">
75
+ <entry file="file://$PROJECT_DIR$/lib/mongo_auto_increment.rb">
76
+ <provider selected="true" editor-type-id="text-editor">
77
+ <state relative-caret-position="384">
78
+ <caret line="73" column="16" selection-start-line="73" selection-start-column="8" selection-end-line="73" selection-end-column="16" />
79
+ </state>
80
+ </provider>
81
+ </entry>
82
+ </file>
83
+ </leaf>
84
+ </component>
85
+ <component name="FindInProjectRecents">
86
+ <findStrings>
87
+ <find>MongoidAutoIncrement</find>
88
+ <find>MAII_TABLE_NAME</find>
89
+ <find>huacnlee</find>
90
+ <find>opts</find>
91
+ <find>belongs_to</find>
92
+ <find>Mongoid::AutoIncrementId</find>
93
+ </findStrings>
94
+ <replaceStrings>
95
+ <replace>guptalakshya92</replace>
96
+ <replace>MongoAutoIncrement</replace>
97
+ </replaceStrings>
98
+ </component>
99
+ <component name="Git.Settings">
100
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
101
+ </component>
102
+ <component name="IdeDocumentHistory">
103
+ <option name="CHANGED_PATHS">
104
+ <list>
105
+ <option value="$PROJECT_DIR$/lib/mongo_auto_increment/config.rb" />
106
+ <option value="$PROJECT_DIR$/mongo_auto_increment.gemspec" />
107
+ <option value="$PROJECT_DIR$/spec/spec_helper.rb" />
108
+ <option value="$PROJECT_DIR$/spec/models.rb" />
109
+ <option value="$PROJECT_DIR$/lib/mongo_auto_increment.rb" />
110
+ <option value="$PROJECT_DIR$/spec/base_spec.rb" />
111
+ <option value="$PROJECT_DIR$/spec/mongo_auto_increment_spec.rb" />
112
+ <option value="$PROJECT_DIR$/README.md" />
113
+ </list>
114
+ </option>
115
+ </component>
116
+ <component name="ProjectConfigurationFiles">
117
+ <option name="files">
118
+ <list>
119
+ <option value="$PROJECT_DIR$/.idea/mongo_auto_increment.iml" />
120
+ <option value="$PROJECT_DIR$/.idea/vcs.xml" />
121
+ <option value="$PROJECT_DIR$/.idea/misc.xml" />
122
+ <option value="$PROJECT_DIR$/.idea/modules.xml" />
123
+ <option value="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
124
+ </list>
125
+ </option>
126
+ </component>
127
+ <component name="ProjectFrameBounds" fullScreen="true">
128
+ <option name="x" value="726" />
129
+ <option name="width" value="714" />
130
+ <option name="height" value="900" />
131
+ </component>
132
+ <component name="ProjectView">
133
+ <navigator proportions="" version="1">
134
+ <foldersAlwaysOnTop value="true" />
135
+ </navigator>
136
+ <panes>
137
+ <pane id="Scope" />
138
+ <pane id="ProjectPane">
139
+ <subPane>
140
+ <expand>
141
+ <path>
142
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
143
+ <item name="mongo_auto_increment" type="462c0819:PsiDirectoryNode" />
144
+ </path>
145
+ <path>
146
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
147
+ <item name="mongo_auto_increment" type="462c0819:PsiDirectoryNode" />
148
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
149
+ </path>
150
+ <path>
151
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
152
+ <item name="mongo_auto_increment" type="462c0819:PsiDirectoryNode" />
153
+ <item name="lib" type="462c0819:PsiDirectoryNode" />
154
+ <item name="mongo_auto_increment" type="462c0819:PsiDirectoryNode" />
155
+ </path>
156
+ <path>
157
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
158
+ <item name="mongo_auto_increment" type="462c0819:PsiDirectoryNode" />
159
+ <item name="spec" type="462c0819:PsiDirectoryNode" />
160
+ </path>
161
+ <path>
162
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
163
+ <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
164
+ </path>
165
+ <path>
166
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
167
+ <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
168
+ <item name="&lt; RVM: ruby-2.5.5 [global] &gt;" type="70bed36:NamedLibraryElementNode" />
169
+ </path>
170
+ <path>
171
+ <item name="mongo_auto_increment" type="b2602c69:ProjectViewProjectNode" />
172
+ <item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
173
+ <item name="&lt; RVM: ruby-2.5.5 [global] &gt;" type="70bed36:NamedLibraryElementNode" />
174
+ <item name="rubystubs25" type="462c0819:PsiDirectoryNode" />
175
+ </path>
176
+ </expand>
177
+ <select />
178
+ </subPane>
179
+ </pane>
180
+ </panes>
181
+ </component>
182
+ <component name="PropertiesComponent">
183
+ <property name="WebServerToolWindowFactoryState" value="false" />
184
+ <property name="last_opened_file_path" value="$PROJECT_DIR$" />
185
+ <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
186
+ <property name="nodejs_npm_path_reset_for_default_project" value="true" />
187
+ </component>
188
+ <component name="RecentsManager">
189
+ <key name="CopyFile.RECENT_KEYS">
190
+ <recent name="$PROJECT_DIR$" />
191
+ <recent name="$PROJECT_DIR$/lib/mongo_auto_increment" />
192
+ </key>
193
+ </component>
194
+ <component name="RunDashboard">
195
+ <option name="ruleStates">
196
+ <list>
197
+ <RuleState>
198
+ <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
199
+ </RuleState>
200
+ <RuleState>
201
+ <option name="name" value="StatusDashboardGroupingRule" />
202
+ </RuleState>
203
+ </list>
204
+ </option>
205
+ </component>
206
+ <component name="SpringUtil" SPRING_PRE_LOADER_OPTION="true" />
207
+ <component name="SvnConfiguration">
208
+ <configuration />
209
+ </component>
210
+ <component name="TaskManager">
211
+ <task active="true" id="Default" summary="Default task">
212
+ <changelist id="b85fc9ee-2118-4eb5-9c34-0438c49d6050" name="Default Changelist" comment="" />
213
+ <created>1582878615068</created>
214
+ <option name="number" value="Default" />
215
+ <option name="presentableId" value="Default" />
216
+ <updated>1582878615068</updated>
217
+ <workItem from="1582878616416" duration="9765000" />
218
+ </task>
219
+ <servers />
220
+ </component>
221
+ <component name="TimeTrackingManager">
222
+ <option name="totallyTimeSpent" value="9765000" />
223
+ </component>
224
+ <component name="ToolWindowManager">
225
+ <frame x="0" y="0" width="1440" height="900" extended-state="0" />
226
+ <layout>
227
+ <window_info id="Favorites" side_tool="true" />
228
+ <window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.24964234" />
229
+ <window_info id="Structure" order="1" side_tool="true" weight="0.25" />
230
+ <window_info anchor="bottom" id="Docker" show_stripe_button="false" />
231
+ <window_info anchor="bottom" id="Database Changes" />
232
+ <window_info anchor="bottom" id="Version Control" />
233
+ <window_info anchor="bottom" id="Messages" weight="0.32891566" />
234
+ <window_info active="true" anchor="bottom" id="Terminal" visible="true" weight="0.32891566" />
235
+ <window_info anchor="bottom" id="Event Log" side_tool="true" />
236
+ <window_info anchor="bottom" id="Message" order="0" />
237
+ <window_info anchor="bottom" id="Find" order="1" />
238
+ <window_info anchor="bottom" id="Run" order="2" />
239
+ <window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
240
+ <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
241
+ <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
242
+ <window_info anchor="bottom" id="TODO" order="6" />
243
+ <window_info anchor="right" id="Database" />
244
+ <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
245
+ <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
246
+ <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
247
+ </layout>
248
+ </component>
249
+ <component name="TypeScriptGeneratedFilesManager">
250
+ <option name="version" value="1" />
251
+ </component>
252
+ <component name="editorHistoryManager">
253
+ <entry file="file://$PROJECT_DIR$/Gemfile">
254
+ <provider selected="true" editor-type-id="text-editor" />
255
+ </entry>
256
+ <entry file="file://$USER_HOME$/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/cgi/session.rb">
257
+ <provider selected="true" editor-type-id="text-editor">
258
+ <state relative-caret-position="268">
259
+ <caret line="451" column="10" selection-start-line="451" selection-start-column="10" selection-end-line="451" selection-end-column="10" />
260
+ </state>
261
+ </provider>
262
+ </entry>
263
+ <entry file="file://$PROJECT_DIR$/lib/mongo_auto_increment/config.rb">
264
+ <provider selected="true" editor-type-id="text-editor">
265
+ <state relative-caret-position="30">
266
+ <caret line="2" column="45" selection-start-line="2" selection-start-column="45" selection-end-line="2" selection-end-column="45" />
267
+ </state>
268
+ </provider>
269
+ </entry>
270
+ <entry file="file://$PROJECT_DIR$/LICENSE.txt">
271
+ <provider selected="true" editor-type-id="text-editor" />
272
+ </entry>
273
+ <entry file="file://$PROJECT_DIR$/mongo_auto_increment.gemspec">
274
+ <provider selected="true" editor-type-id="text-editor">
275
+ <state relative-caret-position="390">
276
+ <caret line="41" column="41" selection-start-line="41" selection-start-column="41" selection-end-line="41" selection-end-column="41" />
277
+ </state>
278
+ </provider>
279
+ </entry>
280
+ <entry file="file://$PROJECT_DIR$/spec/spec_helper.rb">
281
+ <provider selected="true" editor-type-id="text-editor">
282
+ <state>
283
+ <caret line="18" column="4" selection-start-line="18" selection-start-column="4" selection-end-line="18" selection-end-column="4" />
284
+ </state>
285
+ </provider>
286
+ </entry>
287
+ <entry file="file://$APPLICATION_HOME_DIR$/rubystubs25/basic_object.rb">
288
+ <provider selected="true" editor-type-id="text-editor">
289
+ <state relative-caret-position="177">
290
+ <caret line="231" column="8" selection-start-line="231" selection-start-column="8" selection-end-line="231" selection-end-column="8" />
291
+ </state>
292
+ </provider>
293
+ </entry>
294
+ <entry file="file://$PROJECT_DIR$/spec/monkey_patch_spec.rb">
295
+ <provider selected="true" editor-type-id="text-editor" />
296
+ </entry>
297
+ <entry file="file://$PROJECT_DIR$/lib/mongo_auto_increment.rb">
298
+ <provider selected="true" editor-type-id="text-editor">
299
+ <state relative-caret-position="384">
300
+ <caret line="73" column="16" selection-start-line="73" selection-start-column="8" selection-end-line="73" selection-end-column="16" />
301
+ </state>
302
+ </provider>
303
+ </entry>
304
+ <entry file="file://$PROJECT_DIR$/spec/models.rb">
305
+ <provider selected="true" editor-type-id="text-editor">
306
+ <state relative-caret-position="160">
307
+ <caret line="13" column="6" selection-start-line="13" selection-start-column="6" selection-end-line="13" selection-end-column="6" />
308
+ </state>
309
+ </provider>
310
+ </entry>
311
+ <entry file="file://$PROJECT_DIR$/spec/base_spec.rb">
312
+ <provider selected="true" editor-type-id="text-editor">
313
+ <state relative-caret-position="330">
314
+ <caret line="130" column="73" selection-start-line="130" selection-start-column="73" selection-end-line="130" selection-end-column="73" />
315
+ </state>
316
+ </provider>
317
+ </entry>
318
+ <entry file="file://$PROJECT_DIR$/spec/mongo_auto_increment_spec.rb">
319
+ <provider selected="true" editor-type-id="text-editor">
320
+ <state relative-caret-position="60">
321
+ <caret line="4" column="2" selection-start-line="4" selection-start-column="2" selection-end-line="4" selection-end-column="2" />
322
+ </state>
323
+ </provider>
324
+ </entry>
325
+ <entry file="file://$PROJECT_DIR$/lib/mongo_auto_increment/version.rb">
326
+ <provider selected="true" editor-type-id="text-editor" />
327
+ </entry>
328
+ <entry file="file://$PROJECT_DIR$/README.md">
329
+ <provider selected="true" editor-type-id="split-provider[text-editor;markdown-preview-editor]">
330
+ <state split_layout="SPLIT">
331
+ <first_editor relative-caret-position="-415">
332
+ <caret line="31" column="31" lean-forward="true" selection-start-line="31" selection-start-column="31" selection-end-line="31" selection-end-column="31" />
333
+ </first_editor>
334
+ <second_editor />
335
+ </state>
336
+ </provider>
337
+ </entry>
338
+ </component>
339
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.5
7
+ before_install: gem install bundler -v 1.17.3
@@ -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 lakshya@yabx.co. 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
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in mongo_auto_increment.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,60 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mongo_auto_increment (0.1.0)
5
+ mongoid (~> 7.0.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activemodel (6.0.2.1)
11
+ activesupport (= 6.0.2.1)
12
+ activesupport (6.0.2.1)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 0.7, < 2)
15
+ minitest (~> 5.1)
16
+ tzinfo (~> 1.1)
17
+ zeitwerk (~> 2.2)
18
+ bson (4.8.0)
19
+ concurrent-ruby (1.1.6)
20
+ diff-lcs (1.3)
21
+ i18n (1.8.2)
22
+ concurrent-ruby (~> 1.0)
23
+ minitest (5.14.0)
24
+ mocha (1.11.2)
25
+ mongo (2.11.3)
26
+ bson (>= 4.4.2, < 5.0.0)
27
+ mongoid (7.0.5)
28
+ activemodel (>= 5.1, < 6.1)
29
+ mongo (>= 2.5.1, < 3.0.0)
30
+ rake (10.4.2)
31
+ rspec (3.9.0)
32
+ rspec-core (~> 3.9.0)
33
+ rspec-expectations (~> 3.9.0)
34
+ rspec-mocks (~> 3.9.0)
35
+ rspec-core (3.9.1)
36
+ rspec-support (~> 3.9.1)
37
+ rspec-expectations (3.9.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.9.0)
40
+ rspec-mocks (3.9.1)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.9.0)
43
+ rspec-support (3.9.2)
44
+ thread_safe (0.3.6)
45
+ tzinfo (1.2.6)
46
+ thread_safe (~> 0.1)
47
+ zeitwerk (2.2.2)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ bundler (~> 1.17)
54
+ mocha
55
+ mongo_auto_increment!
56
+ rake (~> 10.0)
57
+ rspec (~> 3.0)
58
+
59
+ BUNDLED WITH
60
+ 1.17.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
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,83 @@
1
+ This gem for change Mongoid id field as Integer like MySQL.
2
+
3
+ Idea from MongoDB document: [How to Make an Auto Incrementing Field](http://www.mongodb.org/display/DOCS/How+to+Make+an+Auto+Incrementing+Field)
4
+
5
+
6
+ ## Status
7
+ - ![Ruby Gem](https://github.com/guptalakshya92/mongo_auto_increment/workflows/Ruby%20Gem/badge.svg)
8
+ - [![Gem Version](https://badge.fury.io/rb/mongo_auto_increment.svg)](https://rubygems.org/gems/mongo_auto_increment)
9
+
10
+ ## Installation
11
+
12
+ ```ruby
13
+ gem 'mongo_auto_increment', "0.1.0"
14
+ ```
15
+
16
+ ## Configure
17
+
18
+ If you want use sequence cache to reduce MongoDB write, you can enable cache:
19
+
20
+ config/initializes/mongoid_auto_increment_id.rb
21
+
22
+ ```ruby
23
+ # MongoAutoIncrement.cache_store = ActiveSupport::Cache::MemoryStore.new
24
+ # First call will generate 200 ids and caching in cache_store
25
+ # Then the next 199 ids will return from cache_store
26
+ # Until 200 ids used, it will generate next 200 ids again.
27
+ MongoAutoIncrement.seq_cache_size = 200
28
+ ```
29
+
30
+ > NOTE: 1) mongo_auto_increment is very fast in default config, you may don't need enable that, if you project not need insert huge rows in a moment.
31
+ 2) The ID generated will be ***64-bit combination of Timestamp and above sequence*** so that it will be unique in cluster mode and index will also work. ex: Model.last and Model.first
32
+
33
+
34
+
35
+ ## USAGE
36
+
37
+ ```ruby
38
+ ruby > post = Post.new(:title => "Hello world")
39
+ => #<Post _id: 1582902420, _type: nil, title: "Hello world", body: nil>
40
+ ruby > post.save
41
+ => true
42
+ ruby > post.inspect
43
+ => "#<Post _id: 1582902420, _type: nil, title: \"Hello world\", body: nil>"
44
+ ruby > Post.find("1582902420")
45
+ => "#<Post _id: 1582902420, _type: nil, title: \"Hello world\", body: nil>"
46
+ ruby > Post.find(1582902420)
47
+ => "#<Post _id: 1582902420, _type: nil, title: \"Hello world\", body: nil>"
48
+ ruby > Post.desc(:_id).all.to_a.collect { |row| row.id }
49
+ => [1582902420, 1582886820, 1582886818, 1582886729, 1582886728, 1582886722, 1582886720, 1582886714, 1582886696]
50
+ ```
51
+
52
+
53
+ ## Performance
54
+
55
+ This is a branchmark results run in MacBook Pro Retina.
56
+
57
+ with `mongoid_auto_increment_id`:
58
+
59
+ ```
60
+ user system total real
61
+ Generate 1 0.000000 0.000000 0.000000 ( 0.004301)
62
+ Post current: 1
63
+
64
+ Generate 100 0.070000 0.000000 0.070000 ( 0.091638)
65
+ Post current: 101
66
+
67
+ Generate 10,000 7.300000 0.570000 7.870000 ( 9.962469)
68
+ Post current: 10101
69
+ ```
70
+
71
+ without:
72
+
73
+ ```
74
+ user system total real
75
+ Generate 1 0.000000 0.000000 0.000000 ( 0.002569)
76
+ Post current: 1
77
+
78
+ Generate 100 0.050000 0.000000 0.050000 ( 0.052045)
79
+ Post current: 101
80
+
81
+ Generate 10,000 5.220000 0.170000 5.390000 ( 5.389207)
82
+ Post current: 10101
83
+ ```
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mongo_auto_increment"
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,26 @@
1
+ module MongoAutoIncrement
2
+ @seq_cache_size = 1
3
+ @cache_store = ActiveSupport::Cache::MemoryStore.new
4
+
5
+ class << self
6
+ # How many ids generate in once call, and it will cache ids in Memroy, to reduce MongoDB write
7
+ # default: 1
8
+ #
9
+ # [Call first] -> [occupancy N and Write MongoDB] -> [Save N ids in Memory variable `aii_cache`]
10
+ # [Next call] -> [Shift aii_cache and return]
11
+ # .....
12
+ # [N+1 call] -> [occupancy N and Write MongoDB] -> [Save N ids in Memory variable `aii_cache`]
13
+ attr_accessor :seq_cache_size
14
+
15
+ # ActiveSupport::Cache::Store
16
+ # default: ActiveSupport::Cache.lookup_store(:memory_store)
17
+ #
18
+ # MongoAutoIncrement.cache_store = ActiveSupport::Cache.lookup_store(:memcache_store, "127.0.0.1")
19
+ # For cache ids
20
+ attr_accessor :cache_store
21
+
22
+ def cache_enabled?
23
+ self.seq_cache_size > 1
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ module MongoAutoIncrement
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,88 @@
1
+ require "mongoid"
2
+ require 'active_support/all'
3
+ require "mongo_auto_increment/version"
4
+ require "mongo_auto_increment/config"
5
+
6
+ module MongoAutoIncrement
7
+ class Error < StandardError; end
8
+ # Your code goes here...
9
+
10
+ class Identity
11
+ MAII_TABLE_NAME = 'auto_increment_ids'.freeze
12
+
13
+ class << self
14
+
15
+ # Generate auto increment id
16
+ # params:
17
+ def generate_id(document)
18
+ if MongoAutoIncrement.cache_enabled?
19
+ cache_key = self.maii_cache_key(document)
20
+ if ids = MongoAutoIncrement.cache_store.read(cache_key)
21
+ cached_id = self.shift_id(ids, cache_key)
22
+ return self.generated_token(cached_id) if !cached_id.blank?
23
+ end
24
+ end
25
+
26
+ opts = {
27
+ findAndModify: MAII_TABLE_NAME,
28
+ query: { _id: document.collection_name },
29
+ update: { '$inc' => { c: MongoAutoIncrement.seq_cache_size } },
30
+ upsert: true,
31
+ new: true
32
+ }
33
+ o = Mongoid.default_client.database.command(opts, {})
34
+
35
+ last_seq = o.documents[0]['value']['c'].to_i
36
+
37
+ if MongoAutoIncrement.cache_enabled?
38
+ ids = ((last_seq - MongoAutoIncrement.seq_cache_size) + 1 .. last_seq).to_a
39
+ self.generated_token(self.shift_id(ids, cache_key))
40
+ else
41
+ self.generated_token(last_seq)
42
+ end
43
+ end
44
+
45
+ def generated_token(cache_key)
46
+ return Time.now.to_i + cache_key
47
+ end
48
+
49
+ def shift_id(ids, cache_key)
50
+ return nil if ids.blank?
51
+ first_id = ids.shift
52
+ MongoAutoIncrement.cache_store.write(cache_key, ids)
53
+ first_id
54
+ end
55
+
56
+ def maii_cache_key(document)
57
+ "maii-seqs-#{document.collection_name}"
58
+ end
59
+ end
60
+ end
61
+
62
+ module Mongoid::Document
63
+ ID_FIELD = '_id'.freeze
64
+
65
+ def self.included(base)
66
+ base.class_eval do
67
+ # define Integer for id field
68
+ Mongoid.register_model(self)
69
+ field :_id, type: Integer, overwrite: true, default: -> {Identity.generate_id(self)}
70
+ end
71
+ end
72
+
73
+ # hack id nil when Document.new
74
+ def identify
75
+ Identity.new(self).create
76
+ nil
77
+ end
78
+
79
+ alias_method :super_as_document, :as_document
80
+ def as_document
81
+ result = super_as_document
82
+ if result[ID_FIELD].blank?
83
+ result[ID_FIELD] = Identity.generate_id(self)
84
+ end
85
+ result
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,44 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "mongo_auto_increment/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mongo_auto_increment"
8
+ spec.version = MongoAutoIncrement::VERSION
9
+ spec.authors = ["Lakshya Gupta"]
10
+ spec.email = ["guptalakshya92@gmail.com"]
11
+
12
+ spec.summary = %q{Override id field with MySQL like auto increment for Mongoid}
13
+ spec.description = %q{This gem for change Mongoid id field as Integer like MySQL.}
14
+ spec.homepage = "https://github.com/guptalakshya92/mongo_auto_increment"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ #
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.17"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ spec.add_development_dependency "mocha"
43
+ spec.add_dependency "mongoid", "~> 7.0.5"
44
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mongo_auto_increment
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Lakshya Gupta
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mongoid
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 7.0.5
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 7.0.5
83
+ description: This gem for change Mongoid id field as Integer like MySQL.
84
+ email:
85
+ - guptalakshya92@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".github/workflows/gempush.yml"
91
+ - ".gitignore"
92
+ - ".idea/.rakeTasks"
93
+ - ".idea/inspectionProfiles/Project_Default.xml"
94
+ - ".idea/misc.xml"
95
+ - ".idea/modules.xml"
96
+ - ".idea/mongo_auto_increment.iml"
97
+ - ".idea/vcs.xml"
98
+ - ".idea/workspace.xml"
99
+ - ".rspec"
100
+ - ".travis.yml"
101
+ - CODE_OF_CONDUCT.md
102
+ - Gemfile
103
+ - Gemfile.lock
104
+ - LICENSE.txt
105
+ - README.md
106
+ - Rakefile
107
+ - bin/console
108
+ - bin/setup
109
+ - lib/mongo_auto_increment.rb
110
+ - lib/mongo_auto_increment/config.rb
111
+ - lib/mongo_auto_increment/version.rb
112
+ - mongo_auto_increment.gemspec
113
+ homepage: https://github.com/guptalakshya92/mongo_auto_increment
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.0.3
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: Override id field with MySQL like auto increment for Mongoid
136
+ test_files: []