uniqable 0.3.1 → 0.3.2

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: 4291fffdee96aa5e85cc2ea3207125e104bf544d
4
- data.tar.gz: a9fc14ee36417858c15a2079d550c0175351ab6a
2
+ SHA256:
3
+ metadata.gz: b28ea2e4128fd506d1983847dfde61915acf8550c417fbc5eaba75e11da56986
4
+ data.tar.gz: 39ef933406d49dcf040aabf68f2c5469c317d52630dd4f65a52b4a40a993bb97
5
5
  SHA512:
6
- metadata.gz: 180a1eebaccd029ce8cbdbebadc96a9994993ed73b3da0b8697d616d81c7f4ecc9f02d999af35cf428c194584414cb692ce3df6ea9f4500abbac2d3ea60c1dc3
7
- data.tar.gz: d4d0f5f90ae81f5a542d0ae895fb0ec23f351b05fa70c75924548a88890cb486f8734e0cf8953814f391c0091391708149a4630f002120577fe40569be4c84f7
6
+ metadata.gz: 45d7d098218f0071b1373e23c824f119f0c9b03cf5ee097fb668e34653a11328b9d0684c519a6eaeaa9e450d265f34fa3fc4e7035c4989186b00faef987b088e
7
+ data.tar.gz: 37802f6ce7ba3f591559a271d597111ca13743b43345b8b37e986426e2360a9e089b032de476567ed444a924864aca22dba1e339b9fb04603b7e48dcf2fac3d2
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniqable (0.3.0)
4
+ uniqable (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -23,46 +23,46 @@ GEM
23
23
  ast (2.4.0)
24
24
  awesome_print (1.8.0)
25
25
  builder (3.2.3)
26
- concurrent-ruby (1.0.5)
26
+ concurrent-ruby (1.1.5)
27
27
  diff-lcs (1.3)
28
28
  i18n (0.9.5)
29
29
  concurrent-ruby (~> 1.0)
30
+ jaro_winkler (1.5.3)
30
31
  json (1.8.6)
31
32
  minitest (5.11.3)
32
- parallel (1.12.1)
33
- parser (2.5.1.0)
33
+ parallel (1.17.0)
34
+ parser (2.6.3.0)
34
35
  ast (~> 2.4.0)
35
- powerpack (0.1.1)
36
36
  rainbow (3.0.0)
37
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)
38
+ rspec (3.8.0)
39
+ rspec-core (~> 3.8.0)
40
+ rspec-expectations (~> 3.8.0)
41
+ rspec-mocks (~> 3.8.0)
42
+ rspec-core (3.8.1)
43
+ rspec-support (~> 3.8.0)
44
+ rspec-expectations (3.8.4)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.7.0)
47
- rspec-mocks (3.7.0)
46
+ rspec-support (~> 3.8.0)
47
+ rspec-mocks (3.8.1)
48
48
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.7.0)
50
- rspec-support (3.7.1)
49
+ rspec-support (~> 3.8.0)
50
+ rspec-support (3.8.2)
51
51
  rspec_junit_formatter (0.4.1)
52
52
  rspec-core (>= 2, < 4, != 2.12.0)
53
- rubocop (0.56.0)
53
+ rubocop (0.71.0)
54
+ jaro_winkler (~> 1.5.1)
54
55
  parallel (~> 1.10)
55
- parser (>= 2.5)
56
- powerpack (~> 0.1)
56
+ parser (>= 2.6)
57
57
  rainbow (>= 2.2.2, < 4.0)
58
58
  ruby-progressbar (~> 1.7)
59
- unicode-display_width (~> 1.0, >= 1.0.1)
60
- ruby-progressbar (1.9.0)
59
+ unicode-display_width (>= 1.4.0, < 1.7)
60
+ ruby-progressbar (1.10.1)
61
61
  sqlite3 (1.3.13)
62
62
  thread_safe (0.3.6)
63
63
  tzinfo (1.2.5)
64
64
  thread_safe (~> 0.1)
65
- unicode-display_width (1.4.0)
65
+ unicode-display_width (1.6.0)
66
66
 
67
67
  PLATFORMS
68
68
  ruby
@@ -75,8 +75,8 @@ DEPENDENCIES
75
75
  rspec (~> 3.0)
76
76
  rspec_junit_formatter
77
77
  rubocop (~> 0.49)
78
- sqlite3
78
+ sqlite3 (~> 1.3.6)
79
79
  uniqable!
80
80
 
81
81
  BUNDLED WITH
82
- 1.16.3
82
+ 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
@@ -32,10 +33,10 @@ module Uniqable
32
33
 
33
34
  # @return [self]
34
35
  def where_uniqable(uid)
35
- where_sql = key_uid?(uid) ?
36
- uniqable_fields.map { |r| "#{table_name}.#{r} = :uid" }.join(' OR ') :
37
- "#{table_name}.#{self.primary_key} = :uid"
38
- where(where_sql, uid: uid)
36
+ where(
37
+ uniqable_fields.map { |r| "#{table_name}.#{r} = :uid" }.join(' OR '),
38
+ uid: uid
39
+ )
39
40
  end
40
41
 
41
42
  # Find record by one of the uniq field
@@ -53,12 +54,6 @@ module Uniqable
53
54
  def find_uniqable!(uid)
54
55
  where_uniqable(uid).take!
55
56
  end
56
-
57
- private
58
-
59
- def key_uid?(uid)
60
- uid.to_s =~ /\D+/
61
- end
62
57
  end
63
58
 
64
59
  # Generate and set random and uniq field
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uniqable
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
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
 
24
+ spec.add_development_dependency 'sqlite3', '~> 1.3.6'
25
25
  spec.add_development_dependency 'activerecord', '~> 4.1.14.1'
26
26
  spec.add_development_dependency 'awesome_print'
27
27
  spec.add_development_dependency 'bundler', '~> 1.16'
28
28
  spec.add_development_dependency 'rake', '~> 10.0'
29
29
  spec.add_development_dependency 'rspec', '~> 3.0'
30
30
  spec.add_development_dependency 'rubocop', '~> 0.49'
31
- spec.add_development_dependency 'sqlite3'
32
31
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniqable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
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-26 00:00:00.000000000 Z
11
+ date: 2019-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sqlite3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.6
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.6
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: activerecord
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,20 +108,6 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0.49'
97
- - !ruby/object:Gem::Dependency
98
- name: sqlite3
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
111
  description: Generate a unique, random token for ActiveRecord models.
112
112
  email:
113
113
  - mrak69@gmail.com
@@ -151,8 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  requirements: []
154
- rubyforge_project:
155
- rubygems_version: 2.6.11
154
+ rubygems_version: 3.0.4
156
155
  signing_key:
157
156
  specification_version: 4
158
157
  summary: Uniqable - uniq and random token for ActiveRecord models