ketsuban 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +19 -4
- data/lib/ketsuban/adapters/abstract_adapter.rb +1 -5
- data/lib/ketsuban/base.rb +20 -7
- data/lib/ketsuban/utils.rb +14 -0
- data/lib/ketsuban/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4f7c4a677493a4b2a693280d0db1107aec0932ba
|
4
|
+
data.tar.gz: 2c44b0a66a5bf05bd135a89da19a8597f2591e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d49afbf4e5288f84b0eb6a20bd36c452b24b9608843f8995dfcbdf36b06e7dcdf38c753e473aa966f670a1f5fe9adf32b67ec06a7b24b5d1fa12439e90351d0e
|
7
|
+
data.tar.gz: 4f1802118a2ee05cebfe50c68adb4c94a2aa410180ad772908ad927ebeb41101b2d699d837ff6bd99562a07844203347944a1e428e2f678b8f35c8188f0c8c7b
|
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://rubygems.org/gems/ketsuban)
|
2
|
+
[](https://travis-ci.org/oieioi/ketsuban)
|
3
|
+
|
1
4
|
# Ketsuban
|
2
5
|
|
3
6
|
Skip unlucky numbers for ActiveRecord surrogate key.
|
@@ -7,18 +10,30 @@ Skip unlucky numbers for ActiveRecord surrogate key.
|
|
7
10
|
```ruby
|
8
11
|
class User < ApplicationRecord
|
9
12
|
include Ketsuban
|
10
|
-
unlucky_numbers [4,
|
13
|
+
unlucky_numbers [4, 5]
|
11
14
|
end
|
15
|
+
|
16
|
+
5.times.map { User.create.id }
|
17
|
+
# => [1, 2, 3, 6, 7]
|
12
18
|
```
|
13
19
|
|
20
|
+
or
|
21
|
+
|
14
22
|
```ruby
|
15
|
-
|
16
|
-
|
23
|
+
class User < ApplicationRecord
|
24
|
+
include Ketsuban
|
25
|
+
unlucky_numbers -> next_id { next_id.odd? }
|
26
|
+
end
|
27
|
+
|
28
|
+
5.times.map { User.create.id }
|
29
|
+
# => [2, 4, 6, 8, 10]
|
17
30
|
```
|
18
31
|
|
32
|
+
|
33
|
+
|
19
34
|
## TODO
|
20
35
|
|
21
|
-
- Support
|
36
|
+
- Support sqlite3
|
22
37
|
|
23
38
|
## License
|
24
39
|
|
data/lib/ketsuban/base.rb
CHANGED
@@ -1,19 +1,32 @@
|
|
1
1
|
require_relative './adapter'
|
2
|
+
require_relative './utils'
|
2
3
|
|
3
4
|
module Ketsuban
|
4
5
|
extend ActiveSupport::Concern
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
@unlucky_numbers = [4, 13, 42, 44, 400, 404, 444, 503]
|
7
|
+
module ClassMethod
|
8
|
+
@unlucky_numbers = []
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
def unlucky_numbers(news = nil)
|
11
|
+
return @unlucky_numbers if news.nil?
|
12
12
|
|
13
|
-
|
13
|
+
self.unlucky_numbers = news
|
14
|
+
end
|
15
|
+
|
16
|
+
def unlucky_numbers=(news)
|
17
|
+
case news.class.to_s
|
18
|
+
when 'Array' then @unlucky_numbers = news.sort
|
19
|
+
when 'Proc' then @unlucky_numbers = Ketsuban::Utils.includenize!(news)
|
20
|
+
else raise "Not support #{news.class} for ketsuban args"
|
14
21
|
end
|
22
|
+
end
|
15
23
|
|
16
|
-
|
24
|
+
alias ketsuban unlucky_numbers
|
25
|
+
end
|
26
|
+
|
27
|
+
included do
|
28
|
+
class << self
|
29
|
+
include ClassMethod
|
17
30
|
end
|
18
31
|
|
19
32
|
before_create do
|
data/lib/ketsuban/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ketsuban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oieioi
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description:
|
97
|
+
description: Skip unlucky numbers for ActiveRecord surrogate key
|
98
98
|
email:
|
99
99
|
- atsuinatsu.samuifuyu@gmail.com
|
100
100
|
executables: []
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/ketsuban/adapters/postgresql_adapter.rb
|
112
112
|
- lib/ketsuban/base.rb
|
113
113
|
- lib/ketsuban/railtie.rb
|
114
|
+
- lib/ketsuban/utils.rb
|
114
115
|
- lib/ketsuban/version.rb
|
115
116
|
- lib/tasks/ketsuban_tasks.rake
|
116
117
|
homepage: https://github.com/oieioi/ketsuban
|
@@ -125,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
126
|
requirements:
|
126
127
|
- - ">="
|
127
128
|
- !ruby/object:Gem::Version
|
128
|
-
version: '
|
129
|
+
version: '2.4'
|
129
130
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
131
|
requirements:
|
131
132
|
- - ">="
|
@@ -133,8 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
134
|
version: '0'
|
134
135
|
requirements: []
|
135
136
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
137
|
+
rubygems_version: 2.6.14
|
137
138
|
signing_key:
|
138
139
|
specification_version: 4
|
139
|
-
summary:
|
140
|
+
summary: Skip unlucky numbers for ActiveRecord surrogate key
|
140
141
|
test_files: []
|