stretchr 1.3.2 → 1.3.3
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.
- checksums.yaml +4 -4
- data/lib/stretchr/client.rb +2 -1
- data/lib/stretchr/defaults.yaml +1 -0
- data/lib/stretchr/request.rb +5 -1
- data/lib/stretchr/transporters/json_transporter.rb +1 -1
- data/test/test_client.rb +16 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 203c8335adca97f6815a985d709bf41e02136f69
|
4
|
+
data.tar.gz: 50de345a6b0bf7331782cebbda0e468c2417fad3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b398c4a540889222f4505de45763c588c7c8f5493544e9fb5cb285dbbad561097c3ad0bef6a996182a7be8459de68d78747cc27c83fa7163a0125d1ac63dc19
|
7
|
+
data.tar.gz: 8e527045abb7e9dcba51f163db573ac36cd898f7a30f207c67c858ecbbd0dbf9f22292dbb698c4fe8e12dbaa464165aabf76855fc90fce0ed7be8cfa755eac53
|
data/lib/stretchr/client.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Stretchr
|
2
2
|
class Client
|
3
|
-
attr_accessor :transporter, :api_version, :project, :key, :hostname, :account
|
3
|
+
attr_accessor :transporter, :api_version, :project, :key, :hostname, :account, :use_ssl
|
4
4
|
# Initializes a new stretchr client
|
5
5
|
# This is the main entrypoint into working with stretchr
|
6
6
|
#
|
@@ -16,6 +16,7 @@ module Stretchr
|
|
16
16
|
self.key = options[:key]
|
17
17
|
self.hostname = options[:hostname] || Stretchr.config["hostname"]
|
18
18
|
self.account = options[:account]
|
19
|
+
self.use_ssl = options[:use_ssl] == false ? false : Stretchr.config["use_ssl"]
|
19
20
|
end
|
20
21
|
|
21
22
|
# Catches everything you can throw at client and passes it on to a new request object
|
data/lib/stretchr/defaults.yaml
CHANGED
data/lib/stretchr/request.rb
CHANGED
@@ -32,7 +32,11 @@ module Stretchr
|
|
32
32
|
|
33
33
|
# Builds a URI object
|
34
34
|
def to_uri
|
35
|
-
|
35
|
+
if self.client.use_ssl
|
36
|
+
URI::HTTPS.build(host: merge_host, path: merge_path, query: merge_query)
|
37
|
+
else
|
38
|
+
URI::HTTP.build(host: merge_host, path: merge_path, query: merge_query)
|
39
|
+
end
|
36
40
|
end
|
37
41
|
|
38
42
|
# Set params for the url
|
@@ -14,7 +14,7 @@ module Stretchr
|
|
14
14
|
#convert to a json string unless the user already did it...
|
15
15
|
request[:body] = request[:body].to_json unless request[:body].is_a?(String)
|
16
16
|
|
17
|
-
Net::HTTP.start(request[:uri].host, request[:uri].port, {use_ssl:
|
17
|
+
Net::HTTP.start(request[:uri].host, request[:uri].port, {use_ssl: request[:client].use_ssl}) do |http|
|
18
18
|
http_request = generate_request(request)
|
19
19
|
response = http.request http_request # Net::HTTPResponse object
|
20
20
|
end
|
data/test/test_client.rb
CHANGED
@@ -56,5 +56,21 @@ describe "Client" do
|
|
56
56
|
assert_equal Stretchr::JSONTransporter, stretchr.transporter.class, "Should have defaulted to JSON transport"
|
57
57
|
end
|
58
58
|
|
59
|
+
it "Should accept a new hostname as valid" do
|
60
|
+
stretchr = Stretchr::Client.new({account: "asdf", project: "asdf", key: "asdf", hostname: "stretchr.it"})
|
61
|
+
url = stretchr.collection.to_url
|
62
|
+
assert_equal "https://asdf.stretchr.it/api/v1.1/asdf/collection?key=asdf", url, "Expected the URLs to match"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "Should let me use http" do
|
66
|
+
#default to true
|
67
|
+
stretchr = Stretchr::Client.new
|
68
|
+
assert_equal true, stretchr.use_ssl, "Should have default to true for ssl"
|
69
|
+
stretchr = Stretchr::Client.new({account: "asdf", project: "asdf", key: "asdf", use_ssl: false})
|
70
|
+
url = stretchr.collection.to_url
|
71
|
+
assert_equal false, stretchr.use_ssl, "Should have stored the ssl preference"
|
72
|
+
assert_equal "http://asdf.stretchr.com/api/v1.1/asdf/collection?key=asdf", url, "Should have set the url to http"
|
73
|
+
end
|
74
|
+
|
59
75
|
|
60
76
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stretchr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Quinn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A gem for interacting with your stretchr data
|
14
14
|
email: ryan@mazondo.com
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
53
|
version: '0'
|
54
54
|
requirements: []
|
55
55
|
rubyforge_project:
|
56
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.0.14
|
57
57
|
signing_key:
|
58
58
|
specification_version: 4
|
59
59
|
summary: A gem for managing your stretchr data
|