google_business_api_url_signer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aae27011f775e21039372eb281f8013e83982e04
4
+ data.tar.gz: dbe7cdba147dc9cf2a4d2d586c9bb2252e86a356
5
+ SHA512:
6
+ metadata.gz: 7ab91b37e6ebf532d724eb4461b16390ded05e6e243cc48bba7372529eae73d220e48d6ec0da62751f5f34fa6eced68e3352f82ee1e56806b07d787a74d91e97
7
+ data.tar.gz: 57545e0a4ab4ca0b9c22090923b7a16fe1e90082fc63977650dcbad8352b58c194b74092d02c2daf327f7fe54d6f846cdb05435faefd5cdd982be0d5a1dd3dba
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.1.2
6
+ - ruby-head
7
+ - jruby-19mode
8
+ - jruby
9
+ - jruby-head
10
+ matrix:
11
+ allow_failures:
12
+ - rvm: jruby-head
13
+ - rvm: ruby-head
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Signs URLs used to call Google's business APIs.
4
4
 
5
+ [![Build Status](https://travis-ci.org/Skalar/google_business_api_url_signer.svg?branch=master)](https://travis-ci.org/Skalar/google_business_api_url_signer)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,2 +1,9 @@
1
- #!/usr/bin/env rake
2
1
  require "bundler/gem_tasks"
2
+
3
+ require "rspec/core/rake_task"
4
+ RSpec::Core::RakeTask.new(:spec) do |t|
5
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
6
+ t.pattern = 'spec/**/*_spec.rb'
7
+ end
8
+
9
+ task default: :spec
@@ -17,4 +17,5 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_dependency "activesupport", "~> 3.2.0"
19
19
  gem.add_development_dependency "rspec", "2.11.0"
20
+ gem.add_development_dependency "rake"
20
21
  end
@@ -8,8 +8,6 @@ module GoogleBusinessApiUrlSigner
8
8
  # https://developers.google.com/maps/documentation/business/webservices#generating_valid_signatures
9
9
  #
10
10
  class Signer
11
- BASE_64_DECODE_ENCODE_REPLACEMENTS = ['-_', '+/']
12
-
13
11
  cattr_accessor :default_private_key
14
12
  self.default_private_key = ''
15
13
 
@@ -34,7 +32,7 @@ module GoogleBusinessApiUrlSigner
34
32
 
35
33
  # Public: Calculates the signature from the given URL and private key
36
34
  def signature
37
- Base64.encode64(signature_digest).tr(*BASE_64_DECODE_ENCODE_REPLACEMENTS.reverse).chomp
35
+ Base64.urlsafe_encode64 signature_digest
38
36
  end
39
37
 
40
38
  # Public: Calculates the signature and returns a signed version of the URL
@@ -56,7 +54,7 @@ module GoogleBusinessApiUrlSigner
56
54
  def signature_digest
57
55
  OpenSSL::HMAC.digest(
58
56
  OpenSSL::Digest.new('sha1'),
59
- private_key_decoded,
57
+ private_key_decoded,
60
58
  path_and_query
61
59
  )
62
60
  end
@@ -97,7 +95,7 @@ module GoogleBusinessApiUrlSigner
97
95
 
98
96
 
99
97
  def private_key_decoded
100
- Base64.decode64 private_key.tr(*BASE_64_DECODE_ENCODE_REPLACEMENTS)
98
+ Base64.urlsafe_decode64 private_key
101
99
  end
102
100
  end
103
101
  end
@@ -1,3 +1,3 @@
1
1
  module GoogleBusinessApiUrlSigner
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -44,14 +44,14 @@ describe GoogleBusinessApiUrlSigner::Signer do
44
44
  it "uses default private key when set" do
45
45
  described_class.default_private_key = 'default'
46
46
 
47
- Base64.should_receive(:decode64).with('default').and_return 'decoded'
47
+ Base64.should_receive(:urlsafe_decode64).with('default').and_return 'decoded'
48
48
  described_class.new(url: url).signature
49
49
  end
50
50
 
51
51
  it "uses the private key when options are filled with a blank private key" do
52
52
  described_class.default_private_key = 'default'
53
53
 
54
- Base64.should_receive(:decode64).with('default').and_return 'decoded'
54
+ Base64.should_receive(:urlsafe_decode64).with('default').and_return 'decoded'
55
55
  described_class.new(url: url, private_key: nil).signature
56
56
  end
57
57
  end
metadata CHANGED
@@ -1,48 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_business_api_url_signer
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.1
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thorbjørn Hermansen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-26 00:00:00.000000000 Z
11
+ date: 2014-08-30 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- prerelease: false
16
14
  name: activesupport
17
- type: :runtime
18
- version_requirements: !ruby/object:Gem::Requirement
15
+ requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
- - - ~>
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
19
  version: 3.2.0
23
- none: false
24
- requirement: !ruby/object:Gem::Requirement
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
25
23
  requirements:
26
- - - ~>
24
+ - - "~>"
27
25
  - !ruby/object:Gem::Version
28
26
  version: 3.2.0
29
- none: false
30
27
  - !ruby/object:Gem::Dependency
31
- prerelease: false
32
28
  name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.11.0
33
34
  type: :development
35
+ prerelease: false
34
36
  version_requirements: !ruby/object:Gem::Requirement
35
37
  requirements:
36
38
  - - '='
37
39
  - !ruby/object:Gem::Version
38
40
  version: 2.11.0
39
- none: false
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
40
43
  requirement: !ruby/object:Gem::Requirement
41
44
  requirements:
42
- - - '='
45
+ - - ">="
43
46
  - !ruby/object:Gem::Version
44
- version: 2.11.0
45
- none: false
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
46
55
  description: Signs URLs used to call Google's business APIs
47
56
  email:
48
57
  - thhermansen@gmail.com
@@ -50,7 +59,8 @@ executables: []
50
59
  extensions: []
51
60
  extra_rdoc_files: []
52
61
  files:
53
- - .gitignore
62
+ - ".gitignore"
63
+ - ".travis.yml"
54
64
  - Gemfile
55
65
  - LICENSE
56
66
  - README.md
@@ -65,33 +75,26 @@ files:
65
75
  - spec/spec_helper.rb
66
76
  homepage: ''
67
77
  licenses: []
78
+ metadata: {}
68
79
  post_install_message:
69
80
  rdoc_options: []
70
81
  require_paths:
71
82
  - lib
72
83
  required_ruby_version: !ruby/object:Gem::Requirement
73
84
  requirements:
74
- - - ! '>='
85
+ - - ">="
75
86
  - !ruby/object:Gem::Version
76
- segments:
77
- - 0
78
- hash: -119753422113709265
79
87
  version: '0'
80
- none: false
81
88
  required_rubygems_version: !ruby/object:Gem::Requirement
82
89
  requirements:
83
- - - ! '>='
90
+ - - ">="
84
91
  - !ruby/object:Gem::Version
85
- segments:
86
- - 0
87
- hash: -119753422113709265
88
92
  version: '0'
89
- none: false
90
93
  requirements: []
91
94
  rubyforge_project:
92
- rubygems_version: 1.8.23
95
+ rubygems_version: 2.2.2
93
96
  signing_key:
94
- specification_version: 3
97
+ specification_version: 4
95
98
  summary: Signs URLs used to call Google's business APIs
96
99
  test_files:
97
100
  - spec/google_business_api_url_signer/signer_spec.rb