helium-ruby 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Tue Aug 30 08:16:47 2016 by
105
+ Generated on Wed Aug 31 12:32:54 2016 by
106
106
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.3 (ruby-2.3.1).
108
108
  </div>
@@ -6,8 +6,8 @@ require 'helium/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "helium-ruby"
8
8
  spec.version = Helium::VERSION
9
- spec.authors = ["Andrew Allen"]
10
- spec.email = ["allenan@helium.com"]
9
+ spec.authors = ["Andrew Allen", "Jared Morrow"]
10
+ spec.email = ["allenan@helium.com", "jared@helium.com"]
11
11
 
12
12
  spec.summary = %q{A Ruby gem for building applications with the Helium API}
13
13
  spec.description = %q{A Ruby gem for building applications with the Helium API}
@@ -15,11 +15,16 @@ module Helium
15
15
  include Helium::Client::Labels
16
16
  include Helium::Client::Elements
17
17
 
18
+ API_VERSION = 1
19
+ HOST = 'api.helium.com'
20
+ PROTOCOL = 'https'
21
+
18
22
  attr_accessor :api_key
19
23
 
20
24
  def initialize(opts = {})
21
- @api_key = opts.fetch(:api_key)
22
- @debug = opts.fetch(:debug, false)
25
+ @api_key = opts.fetch(:api_key)
26
+ @api_host = opts.fetch(:host, HOST)
27
+ @debug = opts.fetch(:debug, false)
23
28
  end
24
29
 
25
30
  def inspect
@@ -1,10 +1,6 @@
1
1
  module Helium
2
2
  class Client
3
3
  module Http
4
- API_VERSION = 1
5
- HOST = 'api.helium.com'
6
- PROTOCOL = 'https'
7
-
8
4
  BASE_HTTP_HEADERS = {
9
5
  'Accept' => 'application/json',
10
6
  'Content-Type' => 'application/json',
@@ -35,6 +31,19 @@ module Helium
35
31
  response.code == 204
36
32
  end
37
33
 
34
+ def base_url
35
+ "#{PROTOCOL}://#{@api_host}/v#{API_VERSION}"
36
+ end
37
+
38
+ # Contructs a proper url given a path. If the path is already a full url
39
+ # it will simply pass through
40
+ def url_for(path)
41
+ return path if path =~ /^http/
42
+
43
+ path = path.gsub(/^\//, '')
44
+ "#{base_url}/#{path}"
45
+ end
46
+
38
47
  private
39
48
 
40
49
  def http_headers
@@ -53,14 +62,7 @@ module Helium
53
62
  method = opts.fetch(:method)
54
63
  params = opts.fetch(:params, {})
55
64
  body = opts.fetch(:body, {})
56
-
57
-
58
- url = if path =~ /^http/
59
- path
60
- else
61
- path = path.gsub(/^\//, '')
62
- "#{PROTOCOL}://#{HOST}/v#{API_VERSION}/#{path}"
63
- end
65
+ url = url_for(path)
64
66
 
65
67
  Typhoeus::Request.new(url, {
66
68
  method: method,
@@ -1,3 +1,3 @@
1
1
  module Helium
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helium-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Allen
8
+ - Jared Morrow
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2016-08-30 00:00:00.000000000 Z
12
+ date: 2016-08-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: typhoeus
@@ -223,6 +224,7 @@ dependencies:
223
224
  description: A Ruby gem for building applications with the Helium API
224
225
  email:
225
226
  - allenan@helium.com
227
+ - jared@helium.com
226
228
  executables: []
227
229
  extensions: []
228
230
  extra_rdoc_files: []