carbon 0.0.4.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  require 'uri'
2
- require 'rest_client'
3
- require 'active_support'
2
+ require 'active_support/inflector'
3
+ require 'net/http'
4
4
 
5
5
  module Carbon
6
6
  class EmissionsCalculation
@@ -33,11 +33,6 @@ module Carbon
33
33
  @result
34
34
  end
35
35
 
36
- def resource
37
- url = URI.join(Carbon.base_url, options.emitter_type.to_s.pluralize)
38
- @resource ||= RestClient::Resource.new(url.to_s)
39
- end
40
-
41
36
  def fields
42
37
  options.characteristics.inject({}) do |hsh, characteristic|
43
38
  hsh[characteristic.name] = source.send(characteristic.field)
@@ -46,7 +41,11 @@ module Carbon
46
41
  end
47
42
 
48
43
  def fetch_calculation
49
- response = resource.post fields, :accept => :json
44
+ url = URI.join(Carbon.base_url, options.emitter_type.to_s.pluralize)
45
+ request = Net::HTTP::Post.new(url.path, 'Accept' => 'application/json')
46
+ request.set_form_data(fields)
47
+ response = Net::HTTP.new(url.host).start { |http| http.request(request) }
48
+
50
49
  @result = JSON.parse(response.body)
51
50
  end
52
51
  end
metadata CHANGED
@@ -5,9 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 4
9
- - 1
10
- version: 0.0.4.1
8
+ - 5
9
+ version: 0.0.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Derek Kastner
@@ -19,7 +18,7 @@ date: 2010-04-27 00:00:00 -04:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: rest-client
21
+ name: active_support
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  requirements:
@@ -42,6 +41,18 @@ dependencies:
42
41
  version: "0"
43
42
  type: :development
44
43
  version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: rspec
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :development
55
+ version_requirements: *id003
45
56
  description: Carbon allows you to easily calculate the carbon footprint of various activities. This is an API for the Brighter Planet Carbon Middleware service.
46
57
  email: derek@brighterplanet.com
47
58
  executables: []