push_to_devices 0.1.1 → 0.1.2

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.
@@ -5,7 +5,7 @@ require "cgi"
5
5
  module PushToDevices
6
6
 
7
7
  module Config
8
- VERSION = '0.1.1'
8
+ VERSION = '0.1.2'
9
9
  end
10
10
 
11
11
  class Exception < ::StandardError
@@ -41,15 +41,7 @@ module PushToDevices
41
41
  def get(endpoint, params={})
42
42
 
43
43
  # Set up the HTTP connection
44
- http = Net::HTTP.new(
45
- host,
46
- api_port
47
- )
48
- http.use_ssl = (use_ssl == true)
49
- if debug == true
50
- http.set_debug_output($stdout)
51
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
52
- end
44
+ http = generate_http
53
45
 
54
46
  uri = self.generate_uri_from_params(endpoint, params)
55
47
 
@@ -73,15 +65,7 @@ module PushToDevices
73
65
  def post(endpoint, params = {})
74
66
 
75
67
  # Set up the HTTP connection
76
- http = Net::HTTP.new(
77
- host,
78
- api_port
79
- )
80
- http.use_ssl = (use_ssl == true)
81
- if debug == true
82
- http.set_debug_output($stdout)
83
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
84
- end
68
+ http = generate_http
85
69
 
86
70
  request = Net::HTTP::Post.new("/"+endpoint, initheader = {'Content-Type' =>'application/json'})
87
71
  request.body = params.to_json
@@ -100,6 +84,19 @@ module PushToDevices
100
84
  self.handle_response(response)
101
85
  end
102
86
 
87
+ def generate_http
88
+ http = Net::HTTP.new(
89
+ host,
90
+ api_port
91
+ )
92
+ http.use_ssl = (use_ssl == true)
93
+ if debug == true
94
+ http.set_debug_output($stdout)
95
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
96
+ end
97
+ http
98
+ end
99
+
103
100
  def api_port
104
101
  if port
105
102
  port
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = %q{push_to_devices}
3
- gem.version = "0.1.1"
3
+ gem.version = "0.1.2"
4
4
  gem.date = %q{2013-02-15}
5
5
  gem.authors = ["Lloyd Meta"]
6
6
  gem.email = ["lloydmeta@gmail.com"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: push_to_devices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: