hdcore 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.0.0
3
4
  - 1.9.3
4
5
  - 1.9.2
data/hdcore.gemspec CHANGED
@@ -22,4 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec", "~> 2.13"
24
24
  spec.add_dependency "httparty", "~> 0.11"
25
+ spec.add_dependency "json", "~> 1.5"
25
26
  end
data/lib/hdcore/hdcore.rb CHANGED
@@ -4,9 +4,9 @@ module Hdcore
4
4
 
5
5
  # Default configuration values
6
6
  @config = {
7
- api_endpoint: 'https://core.hostdime.com/api/v1',
8
- public_key: nil,
9
- private_key: nil
7
+ :api_endpoint => 'https://core.hostdime.com/api/v1',
8
+ :public_key => nil,
9
+ :private_key => nil
10
10
  }
11
11
  @valid_config_keys = @config.keys
12
12
 
@@ -56,14 +56,14 @@ module Hdcore
56
56
  # @return [Hash] required api parameters: {:api_key, :api_unique, :api_timestamp, :api_hash}
57
57
  def generate_api_params(action, params = {})
58
58
  {
59
- api_key: public_key,
60
- api_unique: uuid = generate_uuid,
61
- api_timestamp: timestamp = Time.now.to_i,
62
- api_hash: generate_hash( timestamp,
63
- uuid,
64
- private_key,
65
- action,
66
- params.to_json )
59
+ :api_key => public_key,
60
+ :api_unique => uuid = generate_uuid,
61
+ :api_timestamp => timestamp = Time.now.to_i,
62
+ :api_hash => generate_hash( timestamp,
63
+ uuid,
64
+ private_key,
65
+ action,
66
+ params.to_json )
67
67
  }
68
68
  end
69
69
 
@@ -1,3 +1,3 @@
1
1
  module Hdcore
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/hdcore.rb CHANGED
@@ -2,6 +2,7 @@ require 'hdcore/version'
2
2
  require 'httparty'
3
3
  require 'logger'
4
4
  require 'yaml'
5
+ require 'rubygems'
5
6
  require 'json'
6
7
  require 'digest/sha2' # to generate SHA256 hash
7
8
  require 'securerandom' # to generate v4 UUID
@@ -1,4 +1,4 @@
1
- require_relative '../../../lib/hdcore'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Hdcore do
4
4
 
@@ -23,20 +23,20 @@ describe Hdcore do
23
23
  describe '.configure' do
24
24
  it 'assigns value if the key is valid' do
25
25
  # public_key is known to be a valid config key
26
- Hdcore.configure(public_key: 'some_value')
26
+ Hdcore.configure(:public_key => 'some_value')
27
27
  Hdcore.config[:public_key].should == 'some_value'
28
28
  end
29
29
 
30
30
  it 'does nothing for invalid keys' do
31
- Hdcore.configure(bogus_key: 'some_value')
31
+ Hdcore.configure(:bogus_key => 'some_value')
32
32
  Hdcore.config[:bogus_key].should be_nil
33
33
  end
34
34
 
35
35
  after do
36
36
  # reset to expected nil values
37
37
  Hdcore.configure({
38
- public_key: nil,
39
- private_key: nil
38
+ :public_key => nil,
39
+ :private_key => nil
40
40
  })
41
41
  end
42
42
  end
@@ -47,12 +47,12 @@ describe Hdcore do
47
47
  end
48
48
 
49
49
  it 'returns true when a config value is nil' do
50
- Hdcore.stub(:config).and_return(some: nil)
50
+ Hdcore.stub(:config).and_return(:some => nil)
51
51
  Hdcore.missing_config_values?.should be_true
52
52
  end
53
53
 
54
54
  it 'returns false when config values are not nil' do
55
- Hdcore.stub(:config).and_return(some: 'not_nil')
55
+ Hdcore.stub(:config).and_return(:some => 'not_nil')
56
56
  Hdcore.missing_config_values?.should be_false
57
57
  end
58
58
  end
@@ -63,7 +63,7 @@ describe Hdcore do
63
63
  end
64
64
 
65
65
  it 'returns keys that have nil values' do
66
- Hdcore.stub(:config).and_return(empty_config_key: nil, not_empty: 'value')
66
+ Hdcore.stub(:config).and_return(:empty_config_key => nil, :not_empty => 'value')
67
67
  Hdcore.missing_config_values.should == [:empty_config_key]
68
68
  end
69
69
  end
@@ -1,11 +1,11 @@
1
- require_relative '../../../lib/hdcore'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Hdcore::Request do
4
4
 
5
5
  describe '.call' do
6
6
  it 'initializes and sends GET request to API endpoint' do
7
7
  test_action = 'some.action'
8
- Hdcore::Request.stub(:query_string).and_return(params = {some: 'params'})
8
+ Hdcore::Request.stub(:query_string).and_return(params = {:some => 'params'})
9
9
  Hdcore::Request.should_receive(:init)
10
10
  Hdcore::Request.should_receive(:get).with("/call/api_action/#{test_action}/format/json/", params)
11
11
  Hdcore::Request.call(test_action, {})
@@ -15,8 +15,8 @@ describe Hdcore::Request do
15
15
 
16
16
  describe '.query_string' do
17
17
  it 'returns parameters merged with generated api parameters' do
18
- Hdcore::Request.stub(:generate_api_params).and_return(api_params = {some: 'api_params'})
19
- actual = Hdcore::Request.send(:query_string, 'some.action', params = {some_other: 'params'})
18
+ Hdcore::Request.stub(:generate_api_params).and_return(api_params = {:some => 'api_params'})
19
+ actual = Hdcore::Request.send(:query_string, 'some.action', params = {:some_other => 'params'})
20
20
  actual.should == params.merge(api_params)
21
21
  end
22
22
  end
@@ -61,7 +61,7 @@ describe Hdcore::Request do
61
61
  uuid,
62
62
  private_key,
63
63
  action = 'some.action',
64
- (params = {some: 'optional_params'}).to_json
64
+ (params = {:some => 'optional_params'}).to_json
65
65
  )
66
66
 
67
67
  Hdcore::Request.send(:generate_api_params, action, params)
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(File.dirname(__FILE__)), '/lib/hdcore.rb')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hdcore
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ethan Pemble
@@ -76,6 +76,21 @@ dependencies:
76
76
  version: "0.11"
77
77
  type: :runtime
78
78
  version_requirements: *id004
79
+ - !ruby/object:Gem::Dependency
80
+ name: json
81
+ prerelease: false
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ hash: 5
88
+ segments:
89
+ - 1
90
+ - 5
91
+ version: "1.5"
92
+ type: :runtime
93
+ version_requirements: *id005
79
94
  description: A basic wrapper for HostDime's customer portal 'Core' API
80
95
  email:
81
96
  - ethan.p@hostdime.com
@@ -99,6 +114,7 @@ files:
99
114
  - lib/hdcore/version.rb
100
115
  - spec/lib/hdcore/hdcore_spec.rb
101
116
  - spec/lib/hdcore/request_spec.rb
117
+ - spec/spec_helper.rb
102
118
  homepage: https://github.com/hostdime/hdcore-rb
103
119
  licenses:
104
120
  - MIT
@@ -135,3 +151,4 @@ summary: ""
135
151
  test_files:
136
152
  - spec/lib/hdcore/hdcore_spec.rb
137
153
  - spec/lib/hdcore/request_spec.rb
154
+ - spec/spec_helper.rb