effective_obfuscation 1.2.3 → 1.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 66c78820411ac85c68890ea7c820e8edde646c71
4
- data.tar.gz: abc972df5fc6965e0aee00aa6a07853fd801b646
2
+ SHA256:
3
+ metadata.gz: 8c6e7de8d7952b1908c410cb22eac9d30fcde46d61cba65afa8261c684d6386e
4
+ data.tar.gz: 25556589bebd12bd7c1986ee5ce4d5e46afc359be6911e2b331252bebcb19315
5
5
  SHA512:
6
- metadata.gz: 22abb8a737752142e3c2811b46820f81319884e6630fc80646a242791e300d4e23bd4a457a23f9e22e85cd4ca0ab510324327e6780428ff66ed75af5cf0e4321
7
- data.tar.gz: 7a7f19881dbe5cc360ed4376e36cffcf9f2b822bce399268279de9e3288f8f1c54f771f2d70472b8cd1b661a2d961928d96fd78acf1fa881969cd4324413d8c4
6
+ metadata.gz: 33293e400fab0e47d49ec08d3b53e5b7a47029689ecc9a5dcfeb52876259424abad7abf99f4c8b9a715e999c69a969a502ac221b81f99159cb952a8bd7233332
7
+ data.tar.gz: 3d3815196f2a571b47e267bb8455b21fe775fb944d1226efa03419f131c6545802af3cf4c57e003abc8f7a091e1224f3b62737a9fdf6b5e9a649ad1e35889eed
data/README.md CHANGED
@@ -33,7 +33,7 @@ This is a Rails 4 compatible version of obfuscate_id (https://github.com/namick/
33
33
  Add to Gemfile:
34
34
 
35
35
  ```ruby
36
- gem 'effective_obfuscation', :git => 'https://github.com/code-and-effect/effective_obfuscation.git'
36
+ gem 'effective_obfuscation'
37
37
  ```
38
38
 
39
39
  Run the bundle command to install it:
@@ -50,10 +50,10 @@ module ActsAsObfuscated
50
50
  ransacker :id, :formatter => Proc.new { |original|
51
51
  obfuscated_id = original.to_s.delete('^0-9').first(10)
52
52
  obfuscated_id.length == 10 ? deobfuscate(original) : 0
53
- } { |parent| parent.table[:id] }
53
+ } do |parent| parent.table[:id] end
54
54
  end
55
55
 
56
- extend FinderMethods if Gem::Version.new(Rails.version) >= Gem::Version.new('4.2.0')
56
+ extend FinderMethods if EffectiveObfuscation.extend_klass?
57
57
  end
58
58
 
59
59
  module ClassMethods
@@ -111,7 +111,7 @@ module ActsAsObfuscated
111
111
  acts_as_obfuscated_opts[:max_id] ||= (self.unscoped.maximum(:id) rescue 2147483647)
112
112
  end
113
113
 
114
- if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
114
+ if EffectiveObfuscation.extend_relation?
115
115
  def relation
116
116
  super.tap { |relation| relation.extend(FinderMethods) }
117
117
  end
@@ -120,7 +120,9 @@ module ActsAsObfuscated
120
120
 
121
121
  module FinderMethods
122
122
  def find(*args)
123
- return find_by_id(args.first) if @_effective_obfuscation_reloading
123
+ if @_effective_obfuscation_reloading || (respond_to?(:klass) && klass.try(:instance_variable_get, :@_effective_obfuscation_reloading))
124
+ return find_by_id(args.first)
125
+ end
124
126
 
125
127
  super(deobfuscate(args.first, false))
126
128
  end
@@ -150,7 +152,7 @@ module ActsAsObfuscated
150
152
  next unless (d = deobfuscator(left))
151
153
  args.first[left] = d.call(right)
152
154
  end
153
- elsif args.first.class.parent == Arel::Nodes
155
+ elsif args.first.kind_of?(String) == false
154
156
  deobfuscate_arel!(args.first)
155
157
  end
156
158
 
@@ -185,4 +187,3 @@ module ActsAsObfuscated
185
187
  end
186
188
 
187
189
  end
188
-
@@ -10,4 +10,17 @@ module EffectiveObfuscation
10
10
  def self.show(id, spin)
11
11
  ::ScatterSwap.reverse_hash(id, spin).to_i
12
12
  end
13
+
14
+ def self.extend_klass?
15
+ return false if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
16
+ return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
17
+ false
18
+ end
19
+
20
+ def self.extend_relation?
21
+ return true if Gem::Version.new(Rails.version) < Gem::Version.new('4.2')
22
+ return true if Gem::Version.new(Rails.version) >= Gem::Version.new('5')
23
+ false
24
+ end
25
+
13
26
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveObfuscation
2
- VERSION = '1.2.3'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_obfuscation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-09 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,9 +38,8 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.0.3
41
- description: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the
42
- ID param so curious website visitors are unable to determine your user or order
43
- count.
41
+ description: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the
42
+ ID param so curious website visitors are unable to determine your resource count.
44
43
  email:
45
44
  - info@codeandeffect.com
46
45
  executables: []
@@ -57,7 +56,7 @@ homepage: https://github.com/code-and-effect/effective_obfuscation
57
56
  licenses:
58
57
  - MIT
59
58
  metadata: {}
60
- post_install_message:
59
+ post_install_message:
61
60
  rdoc_options: []
62
61
  require_paths:
63
62
  - lib
@@ -72,10 +71,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
71
  - !ruby/object:Gem::Version
73
72
  version: '0'
74
73
  requirements: []
75
- rubyforge_project:
76
- rubygems_version: 2.4.5.1
77
- signing_key:
74
+ rubygems_version: 3.1.2
75
+ signing_key:
78
76
  specification_version: 4
79
- summary: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the ID
80
- param so curious website visitors are unable to determine your user or order count.
77
+ summary: Display unique 10-digit numbers instead of ActiveRecord IDs. Hides the ID
78
+ param so curious website visitors are unable to determine your resource count.
81
79
  test_files: []