carbon 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/carbon.gemspec +60 -36
- data/lib/carbon/cli.rb +1 -0
- data/lib/carbon/cli/irb.rb +2 -0
- data/lib/carbon/cli/shell.rb +17 -13
- data/spec/lib/carbon/cli/shell_spec.rb +30 -0
- metadata +144 -26
- data/.gitignore +0 -21
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.3
|
data/carbon.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{carbon}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Derek Kastner", "Seamus Abshere", "Andy Rossmeissl"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-19}
|
13
13
|
s.default_executable = %q{carbon}
|
14
14
|
s.description = %q{Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web service (http://carbon.brighterplanet.com). By querying the web service, it can estimate the carbon emissions of many real-life objects, such as cars and houses, based on particular attributes that they may have.}
|
15
15
|
s.email = %q{derek.kastner@brighterplanet.com}
|
@@ -18,46 +18,46 @@ Gem::Specification.new do |s|
|
|
18
18
|
"README.rdoc"
|
19
19
|
]
|
20
20
|
s.files = [
|
21
|
-
"
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"MIT-LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/carbon",
|
28
|
+
"carbon.gemspec",
|
29
|
+
"doc/INTEGRATION_GUIDE.rdoc",
|
30
|
+
"doc/examining-response-with-jsonview.png",
|
31
|
+
"doc/shell_example",
|
32
|
+
"doc/timeout-error.png",
|
33
|
+
"doc/with-committee-reports.png",
|
34
|
+
"doc/without-committee-reports.png",
|
35
|
+
"lib/carbon.rb",
|
36
|
+
"lib/carbon/base.rb",
|
37
|
+
"lib/carbon/cli.rb",
|
38
|
+
"lib/carbon/cli/emitter.rb",
|
39
|
+
"lib/carbon/cli/environment.rb",
|
40
|
+
"lib/carbon/cli/irb.rb",
|
41
|
+
"lib/carbon/cli/shell.rb",
|
42
|
+
"lib/carbon/emission_estimate.rb",
|
43
|
+
"lib/carbon/emission_estimate/request.rb",
|
44
|
+
"lib/carbon/emission_estimate/response.rb",
|
45
|
+
"lib/carbon/emission_estimate/storage.rb",
|
46
|
+
"spec/lib/carbon/cli/shell_spec.rb",
|
47
|
+
"spec/lib/carbon/emission_estimate/response_spec.rb",
|
48
|
+
"spec/lib/carbon_spec.rb",
|
49
|
+
"spec/spec_helper.rb",
|
50
|
+
"spec/specwatchr"
|
51
51
|
]
|
52
52
|
s.homepage = %q{http://carbon.brighterplanet.com/libraries}
|
53
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
54
53
|
s.require_paths = ["lib"]
|
55
54
|
s.rubygems_version = %q{1.3.7}
|
56
55
|
s.summary = %q{Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web service (http://carbon.brighterplanet.com).}
|
57
56
|
s.test_files = [
|
57
|
+
"spec/lib/carbon/cli/shell_spec.rb",
|
58
58
|
"spec/lib/carbon/emission_estimate/response_spec.rb",
|
59
|
-
|
60
|
-
|
59
|
+
"spec/lib/carbon_spec.rb",
|
60
|
+
"spec/spec_helper.rb"
|
61
61
|
]
|
62
62
|
|
63
63
|
if s.respond_to? :specification_version then
|
@@ -65,6 +65,14 @@ Gem::Specification.new do |s|
|
|
65
65
|
s.specification_version = 3
|
66
66
|
|
67
67
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
+
s.add_runtime_dependency(%q<carbon>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
70
|
+
s.add_runtime_dependency(%q<nap>, [">= 0.4"])
|
71
|
+
s.add_runtime_dependency(%q<timeframe>, [">= 0.0.7"])
|
72
|
+
s.add_runtime_dependency(%q<blockenspiel>, [">= 0.3.2"])
|
73
|
+
s.add_runtime_dependency(%q<conversions>, ["~> 1"])
|
74
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
75
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
|
68
76
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
69
77
|
s.add_runtime_dependency(%q<nap>, [">= 0.4"])
|
70
78
|
s.add_runtime_dependency(%q<timeframe>, [">= 0.0.7"])
|
@@ -73,6 +81,14 @@ Gem::Specification.new do |s|
|
|
73
81
|
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
74
82
|
s.add_development_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
|
75
83
|
else
|
84
|
+
s.add_dependency(%q<carbon>, [">= 0"])
|
85
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
86
|
+
s.add_dependency(%q<nap>, [">= 0.4"])
|
87
|
+
s.add_dependency(%q<timeframe>, [">= 0.0.7"])
|
88
|
+
s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
|
89
|
+
s.add_dependency(%q<conversions>, ["~> 1"])
|
90
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
91
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
|
76
92
|
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
77
93
|
s.add_dependency(%q<nap>, [">= 0.4"])
|
78
94
|
s.add_dependency(%q<timeframe>, [">= 0.0.7"])
|
@@ -82,6 +98,14 @@ Gem::Specification.new do |s|
|
|
82
98
|
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
|
83
99
|
end
|
84
100
|
else
|
101
|
+
s.add_dependency(%q<carbon>, [">= 0"])
|
102
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
103
|
+
s.add_dependency(%q<nap>, [">= 0.4"])
|
104
|
+
s.add_dependency(%q<timeframe>, [">= 0.0.7"])
|
105
|
+
s.add_dependency(%q<blockenspiel>, [">= 0.3.2"])
|
106
|
+
s.add_dependency(%q<conversions>, ["~> 1"])
|
107
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
108
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0.beta.17"])
|
85
109
|
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
86
110
|
s.add_dependency(%q<nap>, [">= 0.4"])
|
87
111
|
s.add_dependency(%q<timeframe>, [">= 0.0.7"])
|
data/lib/carbon/cli.rb
CHANGED
data/lib/carbon/cli/irb.rb
CHANGED
data/lib/carbon/cli/shell.rb
CHANGED
@@ -1,24 +1,28 @@
|
|
1
|
+
require 'carbon/cli/environment'
|
2
|
+
|
1
3
|
module Carbon
|
2
4
|
module Cli
|
3
5
|
class Shell < Environment
|
4
6
|
cattr_accessor :emitters
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
def self.init
|
9
|
+
emitters_url = "http://carbon.brighterplanet.com/models.json"
|
10
|
+
response = REST.get(emitters_url)
|
11
|
+
if true || response.ok?
|
12
|
+
self.emitters = JSON.parse(response.body)
|
13
|
+
emitters.map(&:underscore).each do |e|
|
14
|
+
define_method e.to_sym do |*args|
|
15
|
+
if args.any? and num = args.first and saved = $emitters[e.to_sym][num]
|
16
|
+
emitter e.to_sym, saved
|
17
|
+
else
|
18
|
+
emitter e.to_sym
|
19
|
+
end
|
16
20
|
end
|
17
21
|
end
|
22
|
+
else
|
23
|
+
puts " => Sorry, emitter types couldn't be retrieved (via #{emitters_url})"
|
24
|
+
done
|
18
25
|
end
|
19
|
-
else
|
20
|
-
puts " => Sorry, emitter types couldn't be retrieved (via #{emitters_url})"
|
21
|
-
done
|
22
26
|
end
|
23
27
|
|
24
28
|
def help
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'carbon/cli/shell'
|
3
|
+
|
4
|
+
describe Carbon::Cli::Shell do
|
5
|
+
let(:json) { %{
|
6
|
+
["Automobile","AutomobileTrip","BusTrip","Computation","Diet","Flight","FuelPurchase","Lodging","Meeting","Motorcycle","Pet","Purchase","RailTrip","Residence"]
|
7
|
+
} }
|
8
|
+
let(:mock_response) { mock(REST, :ok? => true, :body => json) }
|
9
|
+
let(:shell) { Carbon::Cli::Shell.new }
|
10
|
+
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
REST.stub!(:get).and_return mock_response
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '.init' do
|
17
|
+
it 'should create methods for each model' do
|
18
|
+
Carbon::Cli::Shell.init
|
19
|
+
Carbon::Cli::Shell.instance_methods.should include(:automobile)
|
20
|
+
end
|
21
|
+
it 'should exit if the models cannot be fetched' do
|
22
|
+
pending
|
23
|
+
|
24
|
+
mock_response.stub!(:ok?).and_return false
|
25
|
+
Carbon::Cli::Shell.should_receive :done
|
26
|
+
Carbon::Cli::Shell.init
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 3
|
9
|
+
version: 1.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Derek Kastner
|
@@ -16,13 +16,25 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-11-19 00:00:00 -05:00
|
20
20
|
default_executable: carbon
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
|
-
name:
|
24
|
-
prerelease: false
|
23
|
+
name: carbon
|
25
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activesupport
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
26
38
|
none: false
|
27
39
|
requirements:
|
28
40
|
- - ">="
|
@@ -33,11 +45,11 @@ dependencies:
|
|
33
45
|
- 5
|
34
46
|
version: 2.3.5
|
35
47
|
type: :runtime
|
36
|
-
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id002
|
37
50
|
- !ruby/object:Gem::Dependency
|
38
51
|
name: nap
|
39
|
-
|
40
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
53
|
none: false
|
42
54
|
requirements:
|
43
55
|
- - ">="
|
@@ -47,11 +59,11 @@ dependencies:
|
|
47
59
|
- 4
|
48
60
|
version: "0.4"
|
49
61
|
type: :runtime
|
50
|
-
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: *id003
|
51
64
|
- !ruby/object:Gem::Dependency
|
52
65
|
name: timeframe
|
53
|
-
|
54
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
55
67
|
none: false
|
56
68
|
requirements:
|
57
69
|
- - ">="
|
@@ -62,11 +74,11 @@ dependencies:
|
|
62
74
|
- 7
|
63
75
|
version: 0.0.7
|
64
76
|
type: :runtime
|
65
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: *id004
|
66
79
|
- !ruby/object:Gem::Dependency
|
67
80
|
name: blockenspiel
|
68
|
-
|
69
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
70
82
|
none: false
|
71
83
|
requirements:
|
72
84
|
- - ">="
|
@@ -77,11 +89,11 @@ dependencies:
|
|
77
89
|
- 2
|
78
90
|
version: 0.3.2
|
79
91
|
type: :runtime
|
80
|
-
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: *id005
|
81
94
|
- !ruby/object:Gem::Dependency
|
82
95
|
name: conversions
|
83
|
-
|
84
|
-
requirement: &id005 !ruby/object:Gem::Requirement
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
85
97
|
none: false
|
86
98
|
requirements:
|
87
99
|
- - ~>
|
@@ -90,11 +102,11 @@ dependencies:
|
|
90
102
|
- 1
|
91
103
|
version: "1"
|
92
104
|
type: :runtime
|
93
|
-
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: *id006
|
94
107
|
- !ruby/object:Gem::Dependency
|
95
108
|
name: fakeweb
|
96
|
-
|
97
|
-
requirement: &id006 !ruby/object:Gem::Requirement
|
109
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
98
110
|
none: false
|
99
111
|
requirements:
|
100
112
|
- - ">="
|
@@ -105,11 +117,115 @@ dependencies:
|
|
105
117
|
- 8
|
106
118
|
version: 1.2.8
|
107
119
|
type: :development
|
108
|
-
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: *id007
|
109
122
|
- !ruby/object:Gem::Dependency
|
110
123
|
name: rspec
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
segments:
|
130
|
+
- 2
|
131
|
+
- 0
|
132
|
+
- 0
|
133
|
+
- beta
|
134
|
+
- 17
|
135
|
+
version: 2.0.0.beta.17
|
136
|
+
type: :development
|
111
137
|
prerelease: false
|
112
|
-
|
138
|
+
version_requirements: *id008
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: activesupport
|
141
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
segments:
|
147
|
+
- 2
|
148
|
+
- 3
|
149
|
+
- 5
|
150
|
+
version: 2.3.5
|
151
|
+
type: :runtime
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: *id009
|
154
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: nap
|
156
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
- 4
|
164
|
+
version: "0.4"
|
165
|
+
type: :runtime
|
166
|
+
prerelease: false
|
167
|
+
version_requirements: *id010
|
168
|
+
- !ruby/object:Gem::Dependency
|
169
|
+
name: timeframe
|
170
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
171
|
+
none: false
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
segments:
|
176
|
+
- 0
|
177
|
+
- 0
|
178
|
+
- 7
|
179
|
+
version: 0.0.7
|
180
|
+
type: :runtime
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: *id011
|
183
|
+
- !ruby/object:Gem::Dependency
|
184
|
+
name: blockenspiel
|
185
|
+
requirement: &id012 !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
segments:
|
191
|
+
- 0
|
192
|
+
- 3
|
193
|
+
- 2
|
194
|
+
version: 0.3.2
|
195
|
+
type: :runtime
|
196
|
+
prerelease: false
|
197
|
+
version_requirements: *id012
|
198
|
+
- !ruby/object:Gem::Dependency
|
199
|
+
name: conversions
|
200
|
+
requirement: &id013 !ruby/object:Gem::Requirement
|
201
|
+
none: false
|
202
|
+
requirements:
|
203
|
+
- - ~>
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
segments:
|
206
|
+
- 1
|
207
|
+
version: "1"
|
208
|
+
type: :runtime
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: *id013
|
211
|
+
- !ruby/object:Gem::Dependency
|
212
|
+
name: fakeweb
|
213
|
+
requirement: &id014 !ruby/object:Gem::Requirement
|
214
|
+
none: false
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
segments:
|
219
|
+
- 1
|
220
|
+
- 2
|
221
|
+
- 8
|
222
|
+
version: 1.2.8
|
223
|
+
type: :development
|
224
|
+
prerelease: false
|
225
|
+
version_requirements: *id014
|
226
|
+
- !ruby/object:Gem::Dependency
|
227
|
+
name: rspec
|
228
|
+
requirement: &id015 !ruby/object:Gem::Requirement
|
113
229
|
none: false
|
114
230
|
requirements:
|
115
231
|
- - ">="
|
@@ -122,7 +238,8 @@ dependencies:
|
|
122
238
|
- 17
|
123
239
|
version: 2.0.0.beta.17
|
124
240
|
type: :development
|
125
|
-
|
241
|
+
prerelease: false
|
242
|
+
version_requirements: *id015
|
126
243
|
description: Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web service (http://carbon.brighterplanet.com). By querying the web service, it can estimate the carbon emissions of many real-life objects, such as cars and houses, based on particular attributes that they may have.
|
127
244
|
email: derek.kastner@brighterplanet.com
|
128
245
|
executables:
|
@@ -132,7 +249,6 @@ extensions: []
|
|
132
249
|
extra_rdoc_files:
|
133
250
|
- README.rdoc
|
134
251
|
files:
|
135
|
-
- .gitignore
|
136
252
|
- Gemfile
|
137
253
|
- Gemfile.lock
|
138
254
|
- MIT-LICENSE.txt
|
@@ -158,6 +274,7 @@ files:
|
|
158
274
|
- lib/carbon/emission_estimate/request.rb
|
159
275
|
- lib/carbon/emission_estimate/response.rb
|
160
276
|
- lib/carbon/emission_estimate/storage.rb
|
277
|
+
- spec/lib/carbon/cli/shell_spec.rb
|
161
278
|
- spec/lib/carbon/emission_estimate/response_spec.rb
|
162
279
|
- spec/lib/carbon_spec.rb
|
163
280
|
- spec/spec_helper.rb
|
@@ -167,8 +284,8 @@ homepage: http://carbon.brighterplanet.com/libraries
|
|
167
284
|
licenses: []
|
168
285
|
|
169
286
|
post_install_message:
|
170
|
-
rdoc_options:
|
171
|
-
|
287
|
+
rdoc_options: []
|
288
|
+
|
172
289
|
require_paths:
|
173
290
|
- lib
|
174
291
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -195,6 +312,7 @@ signing_key:
|
|
195
312
|
specification_version: 3
|
196
313
|
summary: Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web service (http://carbon.brighterplanet.com).
|
197
314
|
test_files:
|
315
|
+
- spec/lib/carbon/cli/shell_spec.rb
|
198
316
|
- spec/lib/carbon/emission_estimate/response_spec.rb
|
199
317
|
- spec/lib/carbon_spec.rb
|
200
318
|
- spec/spec_helper.rb
|