hash_ids 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSE.txt → MIT-LICENSE} +1 -3
  3. data/Rakefile +23 -4
  4. data/lib/hash_ids/obfuscate.rb +6 -5
  5. data/lib/hash_ids/version.rb +1 -1
  6. data/lib/hash_ids.rb +1 -0
  7. data/lib/tasks/hash_ids_tasks.rake +4 -0
  8. data/spec/dummy/README.rdoc +28 -0
  9. data/spec/dummy/Rakefile +6 -0
  10. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  11. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  12. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  13. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  14. data/spec/dummy/app/models/user.rb +3 -0
  15. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  16. data/spec/dummy/bin/bundle +3 -0
  17. data/spec/dummy/bin/rails +4 -0
  18. data/spec/dummy/bin/rake +4 -0
  19. data/spec/dummy/bin/setup +29 -0
  20. data/spec/dummy/config/application.rb +32 -0
  21. data/spec/dummy/config/boot.rb +5 -0
  22. data/spec/dummy/config/database.yml +25 -0
  23. data/spec/dummy/config/environment.rb +5 -0
  24. data/spec/dummy/config/environments/development.rb +41 -0
  25. data/spec/dummy/config/environments/production.rb +79 -0
  26. data/spec/dummy/config/environments/test.rb +42 -0
  27. data/spec/dummy/config/initializers/assets.rb +11 -0
  28. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  30. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  31. data/spec/dummy/config/initializers/inflections.rb +16 -0
  32. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  33. data/spec/dummy/config/initializers/session_store.rb +3 -0
  34. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/spec/dummy/config/locales/en.yml +23 -0
  36. data/spec/dummy/config/routes.rb +57 -0
  37. data/spec/dummy/config/secrets.yml +22 -0
  38. data/spec/dummy/config.ru +4 -0
  39. data/spec/dummy/db/development.sqlite3 +0 -0
  40. data/spec/dummy/db/migrate/20150204045322_create_users.rb +10 -0
  41. data/spec/dummy/db/schema.rb +23 -0
  42. data/spec/dummy/db/test.sqlite3 +0 -0
  43. data/spec/dummy/log/development.log +16 -0
  44. data/spec/dummy/log/test.log +125 -0
  45. data/spec/dummy/public/404.html +67 -0
  46. data/spec/dummy/public/422.html +67 -0
  47. data/spec/dummy/public/500.html +66 -0
  48. data/spec/dummy/public/favicon.ico +0 -0
  49. data/spec/models/user_spec.rb +31 -0
  50. data/spec/spec_helper.rb +17 -0
  51. data/spec/views/users_routes_spec.rb +19 -0
  52. metadata +100 -21
  53. data/.gitignore +0 -14
  54. data/.rspec +0 -2
  55. data/.travis.yml +0 -3
  56. data/Gemfile +0 -5
  57. data/README.md +0 -60
  58. data/hash_ids.gemspec +0 -25
  59. data/spec/hash_ids_spec.rb +0 -55
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_ids
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kemingcao
@@ -11,49 +11,49 @@ cert_chain: []
11
11
  date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: hashids
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '4.0'
20
20
  type: :runtime
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: '1.0'
26
+ version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: hashids
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
34
- type: :development
33
+ version: '1.0'
34
+ type: :runtime
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: '1.7'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
42
+ name: sqlite3
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '1.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: rspec-rails
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
@@ -73,20 +73,57 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - ".gitignore"
77
- - ".rspec"
78
- - ".travis.yml"
79
- - Gemfile
80
- - LICENSE.txt
81
- - README.md
76
+ - MIT-LICENSE
82
77
  - Rakefile
83
- - hash_ids.gemspec
84
78
  - lib/hash_ids.rb
85
79
  - lib/hash_ids/configuration.rb
86
80
  - lib/hash_ids/obfuscate.rb
87
81
  - lib/hash_ids/version.rb
88
- - spec/hash_ids_spec.rb
82
+ - lib/tasks/hash_ids_tasks.rake
83
+ - spec/dummy/README.rdoc
84
+ - spec/dummy/Rakefile
85
+ - spec/dummy/app/assets/javascripts/application.js
86
+ - spec/dummy/app/assets/stylesheets/application.css
87
+ - spec/dummy/app/controllers/application_controller.rb
88
+ - spec/dummy/app/helpers/application_helper.rb
89
+ - spec/dummy/app/models/user.rb
90
+ - spec/dummy/app/views/layouts/application.html.erb
91
+ - spec/dummy/bin/bundle
92
+ - spec/dummy/bin/rails
93
+ - spec/dummy/bin/rake
94
+ - spec/dummy/bin/setup
95
+ - spec/dummy/config.ru
96
+ - spec/dummy/config/application.rb
97
+ - spec/dummy/config/boot.rb
98
+ - spec/dummy/config/database.yml
99
+ - spec/dummy/config/environment.rb
100
+ - spec/dummy/config/environments/development.rb
101
+ - spec/dummy/config/environments/production.rb
102
+ - spec/dummy/config/environments/test.rb
103
+ - spec/dummy/config/initializers/assets.rb
104
+ - spec/dummy/config/initializers/backtrace_silencers.rb
105
+ - spec/dummy/config/initializers/cookies_serializer.rb
106
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
107
+ - spec/dummy/config/initializers/inflections.rb
108
+ - spec/dummy/config/initializers/mime_types.rb
109
+ - spec/dummy/config/initializers/session_store.rb
110
+ - spec/dummy/config/initializers/wrap_parameters.rb
111
+ - spec/dummy/config/locales/en.yml
112
+ - spec/dummy/config/routes.rb
113
+ - spec/dummy/config/secrets.yml
114
+ - spec/dummy/db/development.sqlite3
115
+ - spec/dummy/db/migrate/20150204045322_create_users.rb
116
+ - spec/dummy/db/schema.rb
117
+ - spec/dummy/db/test.sqlite3
118
+ - spec/dummy/log/development.log
119
+ - spec/dummy/log/test.log
120
+ - spec/dummy/public/404.html
121
+ - spec/dummy/public/422.html
122
+ - spec/dummy/public/500.html
123
+ - spec/dummy/public/favicon.ico
124
+ - spec/models/user_spec.rb
89
125
  - spec/spec_helper.rb
126
+ - spec/views/users_routes_spec.rb
90
127
  homepage: https://github.com/kemingcao/hash_ids
91
128
  licenses:
92
129
  - MIT
@@ -112,5 +149,47 @@ signing_key:
112
149
  specification_version: 4
113
150
  summary: Obfuscate id like a foodie.
114
151
  test_files:
115
- - spec/hash_ids_spec.rb
152
+ - spec/dummy/public/favicon.ico
153
+ - spec/dummy/public/404.html
154
+ - spec/dummy/public/500.html
155
+ - spec/dummy/public/422.html
156
+ - spec/dummy/log/test.log
157
+ - spec/dummy/log/development.log
158
+ - spec/dummy/config.ru
159
+ - spec/dummy/config/initializers/mime_types.rb
160
+ - spec/dummy/config/initializers/session_store.rb
161
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
162
+ - spec/dummy/config/initializers/wrap_parameters.rb
163
+ - spec/dummy/config/initializers/cookies_serializer.rb
164
+ - spec/dummy/config/initializers/inflections.rb
165
+ - spec/dummy/config/initializers/assets.rb
166
+ - spec/dummy/config/initializers/backtrace_silencers.rb
167
+ - spec/dummy/config/database.yml
168
+ - spec/dummy/config/routes.rb
169
+ - spec/dummy/config/application.rb
170
+ - spec/dummy/config/environment.rb
171
+ - spec/dummy/config/boot.rb
172
+ - spec/dummy/config/secrets.yml
173
+ - spec/dummy/config/environments/development.rb
174
+ - spec/dummy/config/environments/test.rb
175
+ - spec/dummy/config/environments/production.rb
176
+ - spec/dummy/config/locales/en.yml
177
+ - spec/dummy/bin/rake
178
+ - spec/dummy/bin/bundle
179
+ - spec/dummy/bin/setup
180
+ - spec/dummy/bin/rails
181
+ - spec/dummy/db/schema.rb
182
+ - spec/dummy/db/development.sqlite3
183
+ - spec/dummy/db/test.sqlite3
184
+ - spec/dummy/db/migrate/20150204045322_create_users.rb
185
+ - spec/dummy/app/helpers/application_helper.rb
186
+ - spec/dummy/app/models/user.rb
187
+ - spec/dummy/app/views/layouts/application.html.erb
188
+ - spec/dummy/app/controllers/application_controller.rb
189
+ - spec/dummy/app/assets/stylesheets/application.css
190
+ - spec/dummy/app/assets/javascripts/application.js
191
+ - spec/dummy/Rakefile
192
+ - spec/dummy/README.rdoc
193
+ - spec/models/user_spec.rb
194
+ - spec/views/users_routes_spec.rb
116
195
  - spec/spec_helper.rb
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- gem 'hashids'
data/README.md DELETED
@@ -1,60 +0,0 @@
1
- # HashIds
2
-
3
- Obfuscate your id in the air
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'hash_ids'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install hash_ids
20
-
21
- ## Usage
22
-
23
-
24
- ```
25
- # create config/initializers/hashids.rb
26
-
27
- HashIds.config do |config|
28
- config.salt = 'secret salt'
29
- config.min_hash_length = 12 # id length
30
- config.alphabet = 'abcd12345' # random char pool require at least 16 unique characters
31
- end
32
-
33
- # add hash_as_id to model
34
-
35
- class User < ActiveRecord::Base
36
- hash_as_id
37
- end
38
- ```
39
-
40
- *Notice* please use `user_path(@user)` instead of `user_path(@user.id)`
41
-
42
- ```
43
- User.find "qeYay1x5bLKVMk5z"
44
- => [#<User id: 2, name: "some guy", created_at: "2015-02-03 07:11:14", updated_at: "2015-02-03 07:11:14">]
45
-
46
- User.find 2
47
- => [#<User id: 2, name: "some guy", created_at: "2015-02-03 07:11:14", updated_at: "2015-02-03 07:11:14">]
48
-
49
- app.user_path(User.last)
50
- => "/users/6n9w75n65da8"
51
- ```
52
-
53
-
54
- ## Contributing
55
-
56
- 1. Fork it ( https://github.com/[my-github-username]/hash_ids/fork )
57
- 2. Create your feature branch (`git checkout -b my-new-feature`)
58
- 3. Commit your changes (`git commit -am 'Add some feature'`)
59
- 4. Push to the branch (`git push origin my-new-feature`)
60
- 5. Create a new Pull Request
data/hash_ids.gemspec DELETED
@@ -1,25 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'hash_ids/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "hash_ids"
8
- spec.version = HashIds::VERSION
9
- spec.authors = ["kemingcao"]
10
- spec.email = ["keming.cao@gmail.com"]
11
- spec.summary = %q{Obfuscate id like a foodie.}
12
- spec.description = %q{Obfuscate id on your record.}
13
- spec.homepage = "https://github.com/kemingcao/hash_ids"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_dependency 'hashids', '~> 1.0'
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
25
- end
@@ -1,55 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class Foodie < ActiveRecord::Base
4
- extend HashIds
5
- hash_as_id
6
-
7
- attr_reader :id
8
- def id
9
- @id ||= Random.new.rand 10000
10
- end
11
- end
12
-
13
- describe HashIds do
14
-
15
- it 'has a version number' do
16
- expect(HashIds::VERSION).not_to be nil
17
- end
18
-
19
- before :all do
20
- @chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
21
-
22
- @salt = @chars.split('').sample(10).join('')
23
- @min_hash_length = Random.new.rand 2...20
24
- @alphabet = @chars.split('').sample(18).join('')
25
-
26
- HashIds.config do |c|
27
- c.salt = @salt
28
- c.min_hash_length = @min_hash_length
29
- c.alphabet = @alphabet
30
- end
31
-
32
- @foodie = Foodie.new
33
- end
34
-
35
-
36
- describe 'HashIds config and hasher' do
37
- it 'test config' do
38
- expect(HashIds.config.salt).to eq @salt
39
- expect(HashIds.config.min_hash_length).to eq @min_hash_length
40
- expect(HashIds.config.alphabet).to eq @alphabet
41
- end
42
-
43
- it 'test hasher' do
44
- expect(HashIds.hasher).not_to be nil
45
- end
46
- end
47
-
48
- describe 'test hasher' do
49
- it 'to_parmas' do
50
- expect(@foodie.to_param).not_to be nil
51
- expect(@foodie.to_param).to eq @foodie.hash_ids_encode(@foodie.id)
52
- end
53
- end
54
-
55
- end