uniqable 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4114db480c0e9252f47842d2b146924b7e5e1f83
4
- data.tar.gz: 0b4f10b5940dfcb66d7c636cce0b5dd0a7fa7f20
2
+ SHA256:
3
+ metadata.gz: d23a35ab4db3ce7e1fab9f0f2d85babe9348fd576f35a211d0b6efb6800250dd
4
+ data.tar.gz: 73d06f7cb72df8f4ddd3a17ea99ba13ad45efc543753384262fec109a8cbccee
5
5
  SHA512:
6
- metadata.gz: 261020540cb88c7799eca3add448c1628245e4f02af17c7f5516cdf58224cf57574111f334db84b767ecdb9be36780df99f8587253f48acaf6b32fd153ef3ca9
7
- data.tar.gz: b35eb3bdbb3bfa4f2b66ec45775ee46cb7be44fd736ccb2ba957e7ff8d85bfbc5e96533a8173d171c42628bd1514ad4280e54a640aa97d86fe897a8d588a3eea
6
+ metadata.gz: 47742bd209a1f122428e76a41daba88620c7ae44f49c9f0071df6fd061a50db7457b0c47cc834b34b435643019cde2c64faaa1dbc9ee6b174362114a21d3a9fe
7
+ data.tar.gz: 529fe623b7ad729c4a88fc3c97b198c23f8dabc693996eae367c13bc0299ff136061778bd9a28634102985a1af8f91929ccdbdd75f2b96dbcf1c611f6fb803fe
@@ -7,7 +7,7 @@ jobs:
7
7
  build:
8
8
  docker:
9
9
  # specify the version you desire here
10
- - image: circleci/ruby:2.3-node-browsers
10
+ - image: circleci/ruby:2.4-node-browsers
11
11
 
12
12
  # Specify service dependencies here if necessary
13
13
  # CircleCI maintains a library of pre-built images
@@ -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>
@@ -3,4 +3,21 @@ Metrics/LineLength:
3
3
  Metrics/BlockLength:
4
4
  ExcludedMethods: ['describe', 'context']
5
5
  AllCops:
6
- TargetRubyVersion: 2.3
6
+ TargetRubyVersion: 2.4
7
+
8
+ Layout/SpaceAroundMethodCallOperator:
9
+ Enabled: true
10
+ Lint/RaiseException:
11
+ Enabled: true
12
+ Lint/StructNewOverride:
13
+ Enabled: true
14
+ Style/ExponentialNotation:
15
+ Enabled: true
16
+ Style/HashEachMethods:
17
+ Enabled: true
18
+ Style/HashTransformKeys:
19
+ Enabled: true
20
+ Style/HashTransformValues:
21
+ Enabled: true
22
+ Style/MultilineTernaryOperator:
23
+ Enabled: false
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.4
@@ -1,82 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniqable (0.3.0)
4
+ uniqable (0.3.5)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activemodel (4.1.14.2)
10
- activesupport (= 4.1.14.2)
11
- builder (~> 3.1)
12
- activerecord (4.1.14.2)
13
- activemodel (= 4.1.14.2)
14
- activesupport (= 4.1.14.2)
15
- arel (~> 5.0.0)
16
- activesupport (4.1.14.2)
17
- i18n (~> 0.6, >= 0.6.9)
18
- json (~> 1.7, >= 1.7.7)
9
+ activemodel (5.2.4.3)
10
+ activesupport (= 5.2.4.3)
11
+ activerecord (5.2.4.3)
12
+ activemodel (= 5.2.4.3)
13
+ activesupport (= 5.2.4.3)
14
+ arel (>= 9.0)
15
+ activesupport (5.2.4.3)
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ i18n (>= 0.7, < 2)
19
18
  minitest (~> 5.1)
20
- thread_safe (~> 0.1)
21
19
  tzinfo (~> 1.1)
22
- arel (5.0.1.20140414130214)
23
- ast (2.4.0)
20
+ arel (9.0.0)
21
+ ast (2.4.1)
24
22
  awesome_print (1.8.0)
25
- builder (3.2.3)
26
- concurrent-ruby (1.0.5)
27
- diff-lcs (1.3)
28
- i18n (0.9.5)
23
+ concurrent-ruby (1.1.6)
24
+ diff-lcs (1.4.2)
25
+ i18n (1.8.3)
29
26
  concurrent-ruby (~> 1.0)
30
- json (1.8.6)
31
- minitest (5.11.3)
32
- parallel (1.12.1)
33
- parser (2.5.1.0)
34
- ast (~> 2.4.0)
35
- powerpack (0.1.1)
27
+ minitest (5.14.1)
28
+ parallel (1.19.2)
29
+ parser (2.7.1.4)
30
+ ast (~> 2.4.1)
36
31
  rainbow (3.0.0)
37
- rake (10.5.0)
38
- rspec (3.7.0)
39
- rspec-core (~> 3.7.0)
40
- rspec-expectations (~> 3.7.0)
41
- rspec-mocks (~> 3.7.0)
42
- rspec-core (3.7.1)
43
- rspec-support (~> 3.7.0)
44
- rspec-expectations (3.7.0)
32
+ rake (13.0.1)
33
+ regexp_parser (1.7.1)
34
+ rexml (3.2.4)
35
+ rspec (3.9.0)
36
+ rspec-core (~> 3.9.0)
37
+ rspec-expectations (~> 3.9.0)
38
+ rspec-mocks (~> 3.9.0)
39
+ rspec-core (3.9.2)
40
+ rspec-support (~> 3.9.3)
41
+ rspec-expectations (3.9.2)
45
42
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.7.0)
47
- rspec-mocks (3.7.0)
43
+ rspec-support (~> 3.9.0)
44
+ rspec-mocks (3.9.1)
48
45
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.7.0)
50
- rspec-support (3.7.1)
46
+ rspec-support (~> 3.9.0)
47
+ rspec-support (3.9.3)
51
48
  rspec_junit_formatter (0.4.1)
52
49
  rspec-core (>= 2, < 4, != 2.12.0)
53
- rubocop (0.56.0)
50
+ rubocop (0.86.0)
54
51
  parallel (~> 1.10)
55
- parser (>= 2.5)
56
- powerpack (~> 0.1)
52
+ parser (>= 2.7.0.1)
57
53
  rainbow (>= 2.2.2, < 4.0)
54
+ regexp_parser (>= 1.7)
55
+ rexml
56
+ rubocop-ast (>= 0.0.3, < 1.0)
58
57
  ruby-progressbar (~> 1.7)
59
- unicode-display_width (~> 1.0, >= 1.0.1)
60
- ruby-progressbar (1.9.0)
58
+ unicode-display_width (>= 1.4.0, < 2.0)
59
+ rubocop-ast (0.0.3)
60
+ parser (>= 2.7.0.1)
61
+ ruby-progressbar (1.10.1)
61
62
  sqlite3 (1.3.13)
62
63
  thread_safe (0.3.6)
63
- tzinfo (1.2.5)
64
+ tzinfo (1.2.7)
64
65
  thread_safe (~> 0.1)
65
- unicode-display_width (1.4.0)
66
+ unicode-display_width (1.7.0)
66
67
 
67
68
  PLATFORMS
68
69
  ruby
69
70
 
70
71
  DEPENDENCIES
71
- activerecord (~> 4.1.14.1)
72
- awesome_print
72
+ activerecord (~> 5.0)
73
+ awesome_print (~> 1.8.0)
73
74
  bundler (~> 1.16)
74
- rake (~> 10.0)
75
- rspec (~> 3.0)
75
+ rake (>= 13.0.1)
76
+ rspec (~> 3.9)
76
77
  rspec_junit_formatter
77
- rubocop (~> 0.49)
78
- sqlite3
78
+ rubocop (~> 0.82)
79
+ sqlite3 (~> 1.3.13)
79
80
  uniqable!
80
81
 
81
82
  BUNDLED WITH
82
- 1.16.3
83
+ 1.17.3
data/README.md CHANGED
@@ -43,10 +43,6 @@ anyway you have one more method `.find_uniqable` which one you can use to find y
43
43
  MyModel.find_uniqable params[:uid]
44
44
  # or
45
45
  MyModel.find_uniqable! params[:uid] # this will raise exception ActiveRecord::RecordNotFound if record is absent
46
- # or you can use numerical ID same time and Uniqable will detect it and tries to find by primary key (as regular id)
47
- MyModel.find_uniqable params[:id]
48
- # or
49
- MyModel.find_uniqable! params[:id]
50
46
  ```
51
47
  and another one is `.uniqable_fields`
52
48
  ```ruby
@@ -57,7 +53,7 @@ You can also create your own token callback method and set the field:
57
53
 
58
54
  ```ruby
59
55
  class MyModel
60
- ...
56
+ #...
61
57
  def uniqable_uid(field)
62
58
  self[field] = 100_000 + rand(999_999)
63
59
  end
data/Rakefile CHANGED
@@ -6,3 +6,4 @@ require 'rspec/core/rake_task'
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  task default: :spec
9
+ task test: :spec
@@ -24,6 +24,7 @@ module Uniqable
24
24
  end
25
25
 
26
26
  return if to_param.blank? # :to_param option
27
+
27
28
  define_method :to_param do
28
29
  public_send(to_param)
29
30
  end
@@ -34,7 +35,7 @@ module Uniqable
34
35
  def where_uniqable(uid)
35
36
  where_sql = key_uid?(uid) ?
36
37
  uniqable_fields.map { |r| "#{table_name}.#{r} = :uid" }.join(' OR ') :
37
- "#{self.primary_key} = :uid"
38
+ "#{table_name}.#{primary_key} = :uid"
38
39
  where(where_sql, uid: uid)
39
40
  end
40
41
 
@@ -57,7 +58,7 @@ module Uniqable
57
58
  private
58
59
 
59
60
  def key_uid?(uid)
60
- uid.to_s =~ /\D+/
61
+ uid.to_s =~ /\D+/ || uid.to_s.length >= 16
61
62
  end
62
63
  end
63
64
 
@@ -66,8 +67,10 @@ module Uniqable
66
67
  def uniqable_uid(field)
67
68
  loop do
68
69
  uniq_code = SecureRandom.hex(8)
69
- send("#{field}=", uniq_code)
70
- break unless self.class.where(field => uniq_code).exists?
70
+ if uniq_code =~ /\D+/
71
+ send("#{field}=", uniq_code)
72
+ break unless self.class.where(field => uniq_code).exists?
73
+ end
71
74
  end
72
75
  end
73
76
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uniqable
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.5'
5
5
  end
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  lib = File.expand_path('lib', __dir__)
@@ -22,11 +21,11 @@ Gem::Specification.new do |spec|
22
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
22
  spec.require_paths = ['lib']
24
23
 
25
- spec.add_development_dependency 'activerecord', '~> 4.1.14.1'
26
- spec.add_development_dependency 'awesome_print'
24
+ spec.add_development_dependency 'activerecord', '~> 5.0'
25
+ spec.add_development_dependency 'awesome_print', '~> 1.8.0'
27
26
  spec.add_development_dependency 'bundler', '~> 1.16'
28
- spec.add_development_dependency 'rake', '~> 10.0'
29
- spec.add_development_dependency 'rspec', '~> 3.0'
30
- spec.add_development_dependency 'rubocop', '~> 0.49'
31
- spec.add_development_dependency 'sqlite3'
27
+ spec.add_development_dependency 'rake', '>= 13.0.1'
28
+ spec.add_development_dependency 'rspec', '~> 3.9'
29
+ spec.add_development_dependency 'rubocop', '~> 0.82'
30
+ spec.add_development_dependency 'sqlite3', '~> 1.3.13'
32
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniqable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renat "MpaK" Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-25 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 4.1.14.1
19
+ version: '5.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 4.1.14.1
26
+ version: '5.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: awesome_print
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.8.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.8.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -56,58 +56,58 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: 13.0.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: 13.0.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '3.9'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '3.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.49'
89
+ version: '0.82'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0.49'
96
+ version: '0.82'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: sqlite3
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 1.3.13
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 1.3.13
111
111
  description: Generate a unique, random token for ActiveRecord models.
112
112
  email:
113
113
  - mrak69@gmail.com
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - ".circleci/config.yml"
119
119
  - ".gitignore"
120
+ - ".rakeTasks"
120
121
  - ".rspec"
121
122
  - ".rubocop.yml"
122
123
  - ".ruby-gems"
@@ -151,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
152
  - !ruby/object:Gem::Version
152
153
  version: '0'
153
154
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.6.11
155
+ rubygems_version: 3.0.8
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: Uniqable - uniq and random token for ActiveRecord models