secretkey 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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Readme.md +4 -6
- data/lib/secretkey.rb +7 -17
- data/lib/version.rb +1 -1
- data/spec/unit/secretkey_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf61f7a13fe998dff0ca4b77cfb653c7eb8f7592
|
4
|
+
data.tar.gz: 9151480d9ceb538176ccd2ad2464c0a716ed57a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38a85d3aee4bc2097858df5406ba82fafd1771d0135a1c2c308c8286d33b46a7207effab7a929d0cd68eb26c2d964e90aac1e13b26b807a325c1d7677fdad2b
|
7
|
+
data.tar.gz: 12b0fb63bfd3a469d94d0a0517a13220bc768fe456310d6fd01ffd3f011779e9e01e66aa78c53d7fa150d987a2934a9417867f67162a3592e37fdf61225290f6
|
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# SecretKey
|
2
2
|
|
3
|
+
[](https://codeclimate.com/github/jobready/secretkey)
|
4
|
+
[](https://codeclimate.com/github/jobready/secretkey)
|
5
|
+
|
3
6
|
Ruby Gem for generating a unique access token when provided with an application id, application secret and timestamp
|
4
7
|
|
5
8
|
## Installation
|
@@ -40,11 +43,6 @@ Where:
|
|
40
43
|
* `secret` - application secret
|
41
44
|
* `timestamp` - an epoch timestamp in seconds i.e. 2014-07-24 14:03:30 +1000 would be 1406174610 in epoch format
|
42
45
|
|
43
|
-
|
44
|
-
## Development Guidelines
|
45
|
-
|
46
|
-
* https://jobready.atlassian.net/wiki/display/DEV/Development+Guidelines
|
47
|
-
|
48
46
|
## Style guidelines
|
49
47
|
|
50
48
|
We try to adhere to the following coding style guidelines
|
@@ -59,4 +57,4 @@ We try to adhere to the following coding style guidelines
|
|
59
57
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
58
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
59
|
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
-
5. Create new Pull Request
|
60
|
+
5. Create new Pull Request
|
data/lib/secretkey.rb
CHANGED
@@ -2,28 +2,18 @@ require 'digest'
|
|
2
2
|
|
3
3
|
module SecretKey
|
4
4
|
class SecretKey
|
5
|
+
attr_reader :key, :secret, :timestamp
|
6
|
+
|
7
|
+
def initialize(key, secret, timestamp: Time.now.to_i)
|
8
|
+
raise ArgumentError, 'Time Stamp is not a valid integer.' unless timestamp.is_a? Integer
|
5
9
|
|
6
|
-
def initialize(key, secret, options={})
|
7
10
|
@key = key
|
8
11
|
@secret = secret
|
9
|
-
@
|
10
|
-
|
11
|
-
extract_options!
|
12
|
+
@timestamp = timestamp
|
12
13
|
end
|
13
14
|
|
14
15
|
def token
|
15
|
-
|
16
|
-
Digest::SHA1.hexdigest("#{@key}:#{@secret}:#{@timestamp}")
|
17
|
-
end
|
18
|
-
|
19
|
-
def timestamp
|
20
|
-
@timestamp ||= Time.now.to_i
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def extract_options!
|
26
|
-
@timestamp = @options.fetch(:timestamp, timestamp)
|
16
|
+
Digest::SHA1.hexdigest("#{key}:#{secret}:#{timestamp}")
|
27
17
|
end
|
28
18
|
end
|
29
|
-
end
|
19
|
+
end
|
data/lib/version.rb
CHANGED
data/spec/unit/secretkey_spec.rb
CHANGED
@@ -31,9 +31,9 @@ describe SecretKey::SecretKey do
|
|
31
31
|
let(:timestamp) { 'askdfjlakshfdkjasd' }
|
32
32
|
|
33
33
|
it 'produces an Argument Error' do
|
34
|
-
expect
|
34
|
+
expect{ secret_key.token }.to raise_error(ArgumentError, 'Time Stamp is not a valid integer.')
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secretkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dinusha Bodhinayake
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|