devstructure 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. data/lib/devstructure/api.rb +16 -10
  2. metadata +4 -4
@@ -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("/")}.json"
40
+ "/#{args.join("/")}"
41
41
  end
42
42
 
43
43
  def headers
44
44
  {
45
45
  "Authorization" => "Token token=\"#{@token}\"",
46
- "Content-Type" => "application/json",
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
- response = @api.post(@api.path("blueprints", @username, name),
89
- JSON.generate(options), @api.headers)
90
- response
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
- response = @api.delete(@api.path("blueprints", @username, name),
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: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
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-12 00:00:00 +00:00
18
+ date: 2010-07-23 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency