encrypted_id 1.1.0 → 1.1.1

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.
@@ -0,0 +1,2 @@
1
+ /spec/test.sqlite3
2
+ /pkg
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/Gemfile CHANGED
@@ -1,15 +1,2 @@
1
- source 'http://rubygems.org'
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem 'activesupport', '>= 2.3.5'
5
-
6
- # Add dependencies to develop your gem here.
7
- # Include everything needed to run rake, tests, features, etc.
8
- group :development do
9
- gem 'rspec', '~> 2.8.0'
10
- gem 'bundler', '~> 1.2.0'
11
- gem 'jeweler', '~> 1.8.4'
12
- gem 'sqlite3'
13
- end
14
-
15
- gem 'activerecord', '>= 3.0.0'
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -1,49 +1,45 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ encrypted_id (1.1.1)
5
+ activerecord (>= 3.0.0)
6
+
1
7
  GEM
2
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
3
9
  specs:
4
- activemodel (3.2.8)
5
- activesupport (= 3.2.8)
10
+ activemodel (3.2.13)
11
+ activesupport (= 3.2.13)
6
12
  builder (~> 3.0.0)
7
- activerecord (3.2.8)
8
- activemodel (= 3.2.8)
9
- activesupport (= 3.2.8)
13
+ activerecord (3.2.13)
14
+ activemodel (= 3.2.13)
15
+ activesupport (= 3.2.13)
10
16
  arel (~> 3.0.2)
11
17
  tzinfo (~> 0.3.29)
12
- activesupport (3.2.8)
13
- i18n (~> 0.6)
18
+ activesupport (3.2.13)
19
+ i18n (= 0.6.1)
14
20
  multi_json (~> 1.0)
15
21
  arel (3.0.2)
16
- builder (3.0.3)
17
- diff-lcs (1.1.3)
18
- git (1.2.5)
22
+ builder (3.0.4)
23
+ diff-lcs (1.2.4)
19
24
  i18n (0.6.1)
20
- jeweler (1.8.4)
21
- bundler (~> 1.0)
22
- git (>= 1.2.5)
23
- rake
24
- rdoc
25
- json (1.7.5)
26
- multi_json (1.3.6)
27
- rake (0.9.2.2)
28
- rdoc (3.12)
29
- json (~> 1.4)
30
- rspec (2.8.0)
31
- rspec-core (~> 2.8.0)
32
- rspec-expectations (~> 2.8.0)
33
- rspec-mocks (~> 2.8.0)
34
- rspec-core (2.8.0)
35
- rspec-expectations (2.8.0)
36
- diff-lcs (~> 1.1.2)
37
- rspec-mocks (2.8.0)
38
- sqlite3 (1.3.6)
39
- tzinfo (0.3.33)
25
+ multi_json (1.7.3)
26
+ rake (10.0.4)
27
+ rspec (2.13.0)
28
+ rspec-core (~> 2.13.0)
29
+ rspec-expectations (~> 2.13.0)
30
+ rspec-mocks (~> 2.13.0)
31
+ rspec-core (2.13.1)
32
+ rspec-expectations (2.13.0)
33
+ diff-lcs (>= 1.1.3, < 2.0)
34
+ rspec-mocks (2.13.1)
35
+ sqlite3 (1.3.7)
36
+ tzinfo (0.3.37)
40
37
 
41
38
  PLATFORMS
42
39
  ruby
43
40
 
44
41
  DEPENDENCIES
45
- activerecord (>= 3.0.0)
46
- bundler (~> 1.2.0)
47
- jeweler (~> 1.8.4)
48
- rspec (~> 2.8.0)
49
- sqlite3
42
+ encrypted_id!
43
+ rake (~> 10.0)
44
+ rspec (~> 2.12)
45
+ sqlite3 (~> 1.3)
data/Rakefile CHANGED
@@ -1,34 +1,11 @@
1
- # encoding: utf-8
2
-
3
- require 'rubygems'
4
1
  require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
2
  require 'rake'
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
13
5
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "encrypted_id"
18
- gem.homepage = "http://github.com/pencil/encrypted_id"
19
- gem.license = "MIT"
20
- gem.summary = "Allows you to encrypt the ID of your ActiveRecord model."
21
- gem.description = "Sometimes you don't want your users to see the actual ID of your databases entries. This gem allows you to hide the ID."
22
- gem.email = "ncaspar@me.com"
23
- gem.authors = ["Nils Caspar"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
6
+ task :default => :spec
27
7
 
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
8
+ desc 'Run all specs'
30
9
  RSpec::Core::RakeTask.new(:spec) do |spec|
31
10
  spec.pattern = FileList['spec/**/*_spec.rb']
32
11
  end
33
-
34
- task :default => :spec
@@ -1,66 +1,25 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'encrypted_id/version'
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = "encrypted_id"
8
- s.version = "1.1.0"
6
+ s.name = 'encrypted_id'
7
+ s.version = EncryptedId::VERSION
8
+ s.authors = ['Nils Caspar']
9
+ s.email = ['ncaspar@me.com']
10
+ s.homepage = 'https://github.com/pencil/encrypted_id'
11
+ s.license = 'MIT'
12
+ s.summary = 'Allows you to encrypt the ID of your ActiveRecord model.'
13
+ s.description = 'Sometimes you don\'t want your users to see the actual ID of your databases entries. This gem allows you to hide the ID.'
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Nils Caspar"]
12
- s.date = "2012-10-15"
13
- s.description = "Sometimes you don't want your users to see the actual ID of your databases entries. This gem allows you to hide the ID."
14
- s.email = "ncaspar@me.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- ".rvmrc",
23
- "Gemfile",
24
- "Gemfile.lock",
25
- "LICENSE.txt",
26
- "README.md",
27
- "Rakefile",
28
- "VERSION",
29
- "encrypted_id.gemspec",
30
- "lib/encrypted_id.rb",
31
- "spec/encrypted_id_spec.rb",
32
- "spec/spec_helper.rb",
33
- "spec/support/models/animal.rb",
34
- "spec/support/models/user.rb"
35
- ]
36
- s.homepage = "http://github.com/pencil/encrypted_id"
37
- s.licenses = ["MIT"]
38
- s.require_paths = ["lib"]
39
- s.rubygems_version = "1.8.24"
40
- s.summary = "Allows you to encrypt the ID of your ActiveRecord model."
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ['lib']
41
19
 
42
- if s.respond_to? :specification_version then
43
- s.specification_version = 3
20
+ s.add_development_dependency 'rake', '~> 10.0'
21
+ s.add_development_dependency 'rspec', '~> 2.12'
22
+ s.add_development_dependency 'sqlite3', '~> 1.3'
44
23
 
45
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
- s.add_runtime_dependency(%q<activerecord>, [">= 3.0.0"])
47
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
48
- s.add_development_dependency(%q<bundler>, ["~> 1.2.0"])
49
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
50
- s.add_development_dependency(%q<sqlite3>, [">= 0"])
51
- else
52
- s.add_dependency(%q<activerecord>, [">= 3.0.0"])
53
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
54
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
55
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
56
- s.add_dependency(%q<sqlite3>, [">= 0"])
57
- end
58
- else
59
- s.add_dependency(%q<activerecord>, [">= 3.0.0"])
60
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
61
- s.add_dependency(%q<bundler>, ["~> 1.2.0"])
62
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
63
- s.add_dependency(%q<sqlite3>, [">= 0"])
64
- end
24
+ s.add_runtime_dependency 'activerecord', '>= 3.0.0'
65
25
  end
66
-
@@ -1,5 +1,6 @@
1
1
  require 'openssl'
2
2
  require 'active_record'
3
+ require 'encrypted_id/version'
3
4
 
4
5
  module EncryptedId
5
6
 
@@ -57,6 +58,14 @@ module EncryptedId
57
58
  EncryptedId.encrypt(self.class.encrypted_id_key, self.id)
58
59
  end
59
60
 
61
+ def to_key
62
+ key = self.id or nil
63
+ if key
64
+ key = [EncryptedId.encrypt(self.class.encrypted_id_key, self.id)]
65
+ end
66
+ key
67
+ end
68
+
60
69
  def reload(options = nil)
61
70
  options = (options || {}).merge(:no_encrypted_id => true)
62
71
  super(options)
@@ -0,0 +1,3 @@
1
+ module EncryptedId
2
+ VERSION = '1.1.1'
3
+ end
@@ -23,6 +23,11 @@ describe 'EncryptedId' do
23
23
  @entity.to_param.should == @test_ids[15]
24
24
  end
25
25
 
26
+ it 'should give us the encrypted ID (in array) via to_key' do
27
+ @entity.id = 15
28
+ @entity.to_key.should == [@test_ids[15]]
29
+ end
30
+
26
31
  it 'should be possible to find an entry by the encrypted id' do
27
32
  @entity.id = 8
28
33
  @entity.save!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encrypted_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,32 +9,16 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-15 00:00:00.000000000 Z
12
+ date: 2013-05-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: activerecord
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: 3.0.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.0.0
30
- - !ruby/object:Gem::Dependency
31
- name: rspec
15
+ name: rake
32
16
  requirement: !ruby/object:Gem::Requirement
33
17
  none: false
34
18
  requirements:
35
19
  - - ~>
36
20
  - !ruby/object:Gem::Version
37
- version: 2.8.0
21
+ version: '10.0'
38
22
  type: :development
39
23
  prerelease: false
40
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,15 +26,15 @@ dependencies:
42
26
  requirements:
43
27
  - - ~>
44
28
  - !ruby/object:Gem::Version
45
- version: 2.8.0
29
+ version: '10.0'
46
30
  - !ruby/object:Gem::Dependency
47
- name: bundler
31
+ name: rspec
48
32
  requirement: !ruby/object:Gem::Requirement
49
33
  none: false
50
34
  requirements:
51
35
  - - ~>
52
36
  - !ruby/object:Gem::Version
53
- version: 1.2.0
37
+ version: '2.12'
54
38
  type: :development
55
39
  prerelease: false
56
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -58,15 +42,15 @@ dependencies:
58
42
  requirements:
59
43
  - - ~>
60
44
  - !ruby/object:Gem::Version
61
- version: 1.2.0
45
+ version: '2.12'
62
46
  - !ruby/object:Gem::Dependency
63
- name: jeweler
47
+ name: sqlite3
64
48
  requirement: !ruby/object:Gem::Requirement
65
49
  none: false
66
50
  requirements:
67
51
  - - ~>
68
52
  - !ruby/object:Gem::Version
69
- version: 1.8.4
53
+ version: '1.3'
70
54
  type: :development
71
55
  prerelease: false
72
56
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,48 +58,49 @@ dependencies:
74
58
  requirements:
75
59
  - - ~>
76
60
  - !ruby/object:Gem::Version
77
- version: 1.8.4
61
+ version: '1.3'
78
62
  - !ruby/object:Gem::Dependency
79
- name: sqlite3
63
+ name: activerecord
80
64
  requirement: !ruby/object:Gem::Requirement
81
65
  none: false
82
66
  requirements:
83
67
  - - ! '>='
84
68
  - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
69
+ version: 3.0.0
70
+ type: :runtime
87
71
  prerelease: false
88
72
  version_requirements: !ruby/object:Gem::Requirement
89
73
  none: false
90
74
  requirements:
91
75
  - - ! '>='
92
76
  - !ruby/object:Gem::Version
93
- version: '0'
77
+ version: 3.0.0
94
78
  description: Sometimes you don't want your users to see the actual ID of your databases
95
79
  entries. This gem allows you to hide the ID.
96
- email: ncaspar@me.com
80
+ email:
81
+ - ncaspar@me.com
97
82
  executables: []
98
83
  extensions: []
99
- extra_rdoc_files:
100
- - LICENSE.txt
101
- - README.md
84
+ extra_rdoc_files: []
102
85
  files:
103
86
  - .document
87
+ - .gitignore
104
88
  - .rspec
105
89
  - .rvmrc
90
+ - .travis.yml
106
91
  - Gemfile
107
92
  - Gemfile.lock
108
93
  - LICENSE.txt
109
94
  - README.md
110
95
  - Rakefile
111
- - VERSION
112
96
  - encrypted_id.gemspec
113
97
  - lib/encrypted_id.rb
98
+ - lib/encrypted_id/version.rb
114
99
  - spec/encrypted_id_spec.rb
115
100
  - spec/spec_helper.rb
116
101
  - spec/support/models/animal.rb
117
102
  - spec/support/models/user.rb
118
- homepage: http://github.com/pencil/encrypted_id
103
+ homepage: https://github.com/pencil/encrypted_id
119
104
  licenses:
120
105
  - MIT
121
106
  post_install_message:
@@ -130,17 +115,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
115
  version: '0'
131
116
  segments:
132
117
  - 0
133
- hash: 4307408867672767625
118
+ hash: -3479489131841139985
134
119
  required_rubygems_version: !ruby/object:Gem::Requirement
135
120
  none: false
136
121
  requirements:
137
122
  - - ! '>='
138
123
  - !ruby/object:Gem::Version
139
124
  version: '0'
125
+ segments:
126
+ - 0
127
+ hash: -3479489131841139985
140
128
  requirements: []
141
129
  rubyforge_project:
142
- rubygems_version: 1.8.24
130
+ rubygems_version: 1.8.25
143
131
  signing_key:
144
132
  specification_version: 3
145
133
  summary: Allows you to encrypt the ID of your ActiveRecord model.
146
- test_files: []
134
+ test_files:
135
+ - spec/encrypted_id_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/support/models/animal.rb
138
+ - spec/support/models/user.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 1.1.0