hdcore 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTQ0MTYxMTFlMWZiOWM3NDc3Mzg0MWVhYTA2MGFmZTEwZTZlMjI4YQ==
4
+ YmQzMGRjZGIzMzZjMDdlMGNhYjMyZjAwYmVhODM0MWNiYjVmNTc1Mg==
5
5
  data.tar.gz: !binary |-
6
- NGI0MDZhMzFiYmMxZDMxZDk4YmViYzhiMmY2OWYyMGM3ZjlkZmRkNg==
6
+ MTRlYWQxYzk2NGZmYzllYzk0ZmNlNWU2YzQ2ZGMxZTZhOTE2ZGIzNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2M1ZmVkODBmMjhiOGUxODIzNzY4NWM5MDU2ZTEyNjhlYmIxZGYyNmU0NDBm
10
- YWZmNWUwZmYyODEzMzFlYWQ5NjJhOWI3OTdlNmQxZTQ1Yzc5ZDZjMjNlYzE2
11
- NzNjMmE4OWFkN2I5MDg4NzI0NjlhZGI5NzgwNWE5YWZlNzFkOGM=
9
+ MjQwZmFkNTU1ZTk0MWZjODUzNDdkOTk2MDYwNDcwOTMzNWQ4MDJiOWFhYWI5
10
+ MzI0YjlkZGNkYjY5MmZkY2Y4YjBjNTYzM2FmNTM4YjUwYTc2NWI1ZmY5MWE2
11
+ MTU3NzJlNDZiM2QzY2IxY2IwMTAyNTg2YmQ5ZTcyZjQ4Mzc0YjY=
12
12
  data.tar.gz: !binary |-
13
- ZGZhNjVmZDEyZDZmZjdmOGM3ZGY3NmIwNjMwYWEyMGViNThiNWE3NGEyOWZh
14
- OTIzM2MxNzBhOWQ5MDRjYzQ0ZTA3MWVlNTEyNDhkYmVhNzBlYWFlYjZhOGUy
15
- MWVmNmU2NmY5ZTc1YmQ4YTQ3ZDU5NDNiZTlhNjYyODI0ZTczZDM=
13
+ MjE4Njc5MDI5MTE1MTY4YmZmZjY1MTUxMTdhNDllYWRjOWM4M2Q1YjA1NmNm
14
+ MmQxNzMyNTY0MWY3Zjg2OTdkNjI3YjgyZjEwNDhlMzYzODZiYmYzNGZiNDQx
15
+ ODk1MDlhZDMxZTdkNWJjOTYxYTFlMzJhNWU4OWUyYWFiNTZjN2E=
data/hdcore.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec", "~> 2.13"
24
24
  spec.add_dependency "httparty", "~> 0.11"
25
25
  spec.add_dependency "json", "~> 1.5"
26
+ spec.add_dependency "active_support", "~> 3.0"
26
27
  end
data/lib/hdcore/hdcore.rb CHANGED
@@ -6,7 +6,8 @@ module Hdcore
6
6
  @config = {
7
7
  :api_endpoint => 'https://api.hostdime.com/v1',
8
8
  :public_key => nil,
9
- :private_key => nil
9
+ :private_key => nil,
10
+ :time_zone => 'US/Eastern'
10
11
  }
11
12
  @valid_config_keys = @config.keys
12
13
 
@@ -59,7 +59,7 @@ module Hdcore
59
59
  {
60
60
  :api_key => public_key,
61
61
  :api_unique => uuid = generate_uuid,
62
- :api_timestamp => timestamp = Time.now.to_i,
62
+ :api_timestamp => timestamp = generate_timestamp,
63
63
  :api_hash => generate_hash( timestamp,
64
64
  uuid,
65
65
  private_key,
@@ -68,6 +68,13 @@ module Hdcore
68
68
  }
69
69
  end
70
70
 
71
+
72
+ #
73
+ def generate_timestamp
74
+ zone = Hdcore.config[:time_zone]
75
+ Time.use_zone(zone) { Time.now.to_i }
76
+ end
77
+
71
78
  # @private
72
79
  # @return [String] SHA256 hash of all the arguments "joined:with:colons"
73
80
  def generate_hash(*args)
@@ -1,3 +1,3 @@
1
1
  module Hdcore
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/hdcore.rb CHANGED
@@ -6,6 +6,7 @@ require 'rubygems'
6
6
  require 'json'
7
7
  require 'digest/sha2' # to generate SHA256 hash
8
8
  require 'securerandom' # to generate v4 UUID
9
+ require 'active_support/time'
9
10
 
10
11
  Dir[File.dirname(__FILE__) + '/hdcore/*.rb'].each do |file|
11
12
  require file
@@ -3,8 +3,8 @@ require 'spec_helper'
3
3
  describe Hdcore do
4
4
 
5
5
  describe '.config' do
6
- it 'returns hash with expected keys [:api_endpoint, :public_key, :private_key]' do
7
- Hdcore.config.keys.should == [:api_endpoint, :public_key, :private_key]
6
+ it 'returns hash with expected keys [:api_endpoint, :public_key, :private_key, :time_zone]' do
7
+ Hdcore.config.keys.should == [:api_endpoint, :public_key, :private_key, :time_zone]
8
8
  end
9
9
 
10
10
  it 'returns default [:api_endpoint] => "https://api.hostdime.com/v1"' do
@@ -18,6 +18,10 @@ describe Hdcore do
18
18
  it 'returns default [:private_key] => nil' do
19
19
  Hdcore.config[:private_key].should == nil
20
20
  end
21
+
22
+ it 'returns default [:time_zone] => US/Eastern' do
23
+ Hdcore.config[:time_zone].should == 'US/Eastern'
24
+ end
21
25
  end
22
26
 
23
27
  describe '.configure' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hdcore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Pemble
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ~>
81
81
  - !ruby/object:Gem::Version
82
82
  version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: active_support
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
83
97
  description: A basic wrapper for HostDime's customer portal 'Core' API
84
98
  email:
85
99
  - ethan.p@hostdime.com