shared-secret-authentication 0.1.4 → 0.1.5

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.
data/.gitignore CHANGED
@@ -5,6 +5,8 @@
5
5
  *.tmproj
6
6
  tmtags
7
7
 
8
+ .idea
9
+
8
10
  ## EMACS
9
11
  *~
10
12
  \#*
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
@@ -7,3 +7,4 @@ require 'digest'
7
7
  #end
8
8
  require 'shared-secret-authentication/load_secret'
9
9
  require 'shared-secret-authentication/hash_signatures'
10
+ require 'shared-secret-authentication/generator'
@@ -0,0 +1,13 @@
1
+ module SharedSecretAuthentication
2
+ class Generator
3
+
4
+ def self.shared_secret(length = 10)
5
+ raise ArgumentError.new 'a key has a maximum of 64 numbers and letters' if length > 64
6
+ Digest::SHA2.hexdigest(Time.now.to_s + rand(123456789).to_s)[0..length - 1]
7
+ end
8
+
9
+ class << self
10
+ alias :api_key :shared_secret
11
+ end
12
+ end
13
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{shared-secret-authentication}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Moore"]
12
- s.date = %q{2010-11-03}
12
+ s.date = %q{2010-11-16}
13
13
  s.description = %q{helper methods to make shared secret authentication easier}
14
14
  s.email = %q{joshsmoore@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -25,9 +25,11 @@ Gem::Specification.new do |s|
25
25
  "VERSION",
26
26
  "config/shared_secret.yml",
27
27
  "lib/shared-secret-authentication.rb",
28
+ "lib/shared-secret-authentication/generator.rb",
28
29
  "lib/shared-secret-authentication/hash_signatures.rb",
29
30
  "lib/shared-secret-authentication/load_secret.rb",
30
31
  "shared-secret-authentication.gemspec",
32
+ "spec/shared-secret-authentication/generator_spec.rb",
31
33
  "spec/shared-secret-authentication/hash_signatures_spec.rb",
32
34
  "spec/shared-secret-authentication/load_secret_spec.rb",
33
35
  "spec/shared-secret-authentication_spec.rb",
@@ -41,7 +43,8 @@ Gem::Specification.new do |s|
41
43
  s.rubygems_version = %q{1.3.7}
42
44
  s.summary = %q{helper methods to make shared secret authentication easier}
43
45
  s.test_files = [
44
- "spec/shared-secret-authentication/hash_signatures_spec.rb",
46
+ "spec/shared-secret-authentication/generator_spec.rb",
47
+ "spec/shared-secret-authentication/hash_signatures_spec.rb",
45
48
  "spec/shared-secret-authentication/load_secret_spec.rb",
46
49
  "spec/shared-secret-authentication_spec.rb",
47
50
  "spec/spec_helper.rb"
@@ -0,0 +1,26 @@
1
+ require "spec/spec_helper"
2
+
3
+
4
+ describe SharedSecretAuthentication::Generator do
5
+ describe '.shared_secret' do
6
+ it "should should generate a random secret" do
7
+ SharedSecretAuthentication::Generator.shared_secret.should be_instance_of String
8
+ SharedSecretAuthentication::Generator.shared_secret.should have(10).characters
9
+ end
10
+
11
+ it 'should make the shared_secret to be the same length as the passed in integer' do
12
+ SharedSecretAuthentication::Generator.shared_secret(64).should have(64).characters
13
+ end
14
+
15
+ it 'should raise an Argument error if the argument is over 64' do
16
+ lambda { SharedSecretAuthentication::Generator.shared_secret(67)}.should raise_error ArgumentError
17
+ end
18
+ end
19
+
20
+ describe '.api_key' do
21
+ it 'should respond to api_key' do
22
+ SharedSecretAuthentication::Generator.should respond_to :api_key
23
+ end
24
+ end
25
+
26
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
 
4
- Bundler.require :default
4
+ #Bundler.require :default
5
5
 
6
6
  require 'shared-secret-authentication'
7
- require 'spec'
8
- require 'spec/autorun'
7
+ require 'rspec'
8
+ require 'rspec/autorun'
9
9
 
10
10
 
11
- Spec::Runner.configure do |config|
11
+ RSpec.configure do |config|
12
12
 
13
13
  end
data/watchr.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  puts "\n### Watching specs and features ... ###\n"
2
2
 
3
3
  #def cmd() 'bundle exec spec -O spec/spec.opts '; end
4
- def cmd() 'spec -O spec/spec.opts '; end
4
+ def cmd() 'rspec '; end
5
5
 
6
6
  def run_all_specs
7
7
  system(cmd + 'spec/')
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  def run_spec(spec)
11
11
  puts "Running #{spec}"
12
+ puts(cmd + spec)
12
13
  system(cmd + spec)
13
14
  puts
14
15
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shared-secret-authentication
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 4
10
- version: 0.1.4
9
+ - 5
10
+ version: 0.1.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Moore
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-03 00:00:00 +08:00
18
+ date: 2010-11-16 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -52,9 +52,11 @@ files:
52
52
  - VERSION
53
53
  - config/shared_secret.yml
54
54
  - lib/shared-secret-authentication.rb
55
+ - lib/shared-secret-authentication/generator.rb
55
56
  - lib/shared-secret-authentication/hash_signatures.rb
56
57
  - lib/shared-secret-authentication/load_secret.rb
57
58
  - shared-secret-authentication.gemspec
59
+ - spec/shared-secret-authentication/generator_spec.rb
58
60
  - spec/shared-secret-authentication/hash_signatures_spec.rb
59
61
  - spec/shared-secret-authentication/load_secret_spec.rb
60
62
  - spec/shared-secret-authentication_spec.rb
@@ -96,6 +98,7 @@ signing_key:
96
98
  specification_version: 3
97
99
  summary: helper methods to make shared secret authentication easier
98
100
  test_files:
101
+ - spec/shared-secret-authentication/generator_spec.rb
99
102
  - spec/shared-secret-authentication/hash_signatures_spec.rb
100
103
  - spec/shared-secret-authentication/load_secret_spec.rb
101
104
  - spec/shared-secret-authentication_spec.rb