devstructure 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/devstructure/api.rb +16 -10
- metadata +4 -4
data/lib/devstructure/api.rb
CHANGED
@@ -21,7 +21,7 @@ class DevStructure::API < Net::HTTP
|
|
21
21
|
|
22
22
|
def initialize(token=nil)
|
23
23
|
@newimpl = true
|
24
|
-
uri = URI.parse("https://devstructure.com")
|
24
|
+
uri = URI.parse("https://api.devstructure.com")
|
25
25
|
super uri.host, uri.port
|
26
26
|
self.use_ssl = "https" == uri.scheme
|
27
27
|
@token = if token
|
@@ -37,14 +37,13 @@ class DevStructure::API < Net::HTTP
|
|
37
37
|
|
38
38
|
def path(*args)
|
39
39
|
args.reject! { |arg| arg.nil? }
|
40
|
-
"/#{args.join("/")}
|
40
|
+
"/#{args.join("/")}"
|
41
41
|
end
|
42
42
|
|
43
43
|
def headers
|
44
44
|
{
|
45
45
|
"Authorization" => "Token token=\"#{@token}\"",
|
46
|
-
"
|
47
|
-
"Host" => "devstructure.com",
|
46
|
+
"Host" => "api.devstructure.com",
|
48
47
|
}
|
49
48
|
end
|
50
49
|
|
@@ -85,16 +84,23 @@ class DevStructure::API < Net::HTTP
|
|
85
84
|
|
86
85
|
def post(name, options={})
|
87
86
|
@api.start unless @api.started?
|
88
|
-
|
89
|
-
|
90
|
-
|
87
|
+
params = {}
|
88
|
+
options.each do |key, value|
|
89
|
+
params[key] = if value.kind_of?(Hash)
|
90
|
+
JSON.generate(value)
|
91
|
+
else
|
92
|
+
value
|
93
|
+
end
|
94
|
+
end
|
95
|
+
request = Net::HTTP::Post.new(@api.path("blueprints", @username, name))
|
96
|
+
request.set_form_data params
|
97
|
+
@api.headers.each { |key, value| request[key] = value }
|
98
|
+
@api.request(request)
|
91
99
|
end
|
92
100
|
|
93
101
|
def delete(name, options={})
|
94
102
|
@api.start unless @api.started?
|
95
|
-
|
96
|
-
@api.headers)
|
97
|
-
response
|
103
|
+
@api.delete(@api.path("blueprints", @username, name), @api.headers)
|
98
104
|
end
|
99
105
|
|
100
106
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devstructure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Crowley
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-23 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|