tepco_usage_api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE.txt +21 -0
- data/lib/tepco_usage_api.rb +23 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/tepco_usage_api_spec.rb +33 -0
- metadata +59 -0
data/LICENCE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011 Tatsuya Sato
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class TepcoUsage
|
5
|
+
class << self
|
6
|
+
def latest
|
7
|
+
response = request('/latest.json')
|
8
|
+
JSON.parse(response.body)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def request(path)
|
13
|
+
http.request_get(path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def http
|
17
|
+
unless @http
|
18
|
+
@http = Net::HTTP.new('tepco-usage-api.appspot.com')
|
19
|
+
end
|
20
|
+
@http
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.expand_path(File.join(
|
2
|
+
File.dirname(__FILE__), 'spec_helper'))
|
3
|
+
|
4
|
+
describe TepcoUsage do
|
5
|
+
describe "#latest" do
|
6
|
+
before do
|
7
|
+
TepcoUsage.stub!(:request).with('/latest.json').and_return do
|
8
|
+
mock = mock(Object.new, :body => <<-JSON)
|
9
|
+
{
|
10
|
+
"saving": false,
|
11
|
+
"hour": 0,
|
12
|
+
"capacity_updated": "2011-03-26 09:30:00",
|
13
|
+
"month": 3,
|
14
|
+
"usage_updated": "2011-03-26 16:30:54",
|
15
|
+
"entryfor": "2011-03-26 15:00:00",
|
16
|
+
"capacity_peak_period": 18,
|
17
|
+
"year": 2011,
|
18
|
+
"usage": 2904,
|
19
|
+
"capacity": 3700,
|
20
|
+
"day": 27
|
21
|
+
}
|
22
|
+
JSON
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
subject{TepcoUsage}
|
27
|
+
its(:latest) { should_not be_nil }
|
28
|
+
it do
|
29
|
+
TepcoUsage.latest['saving'].should be_false
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tepco_usage_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tatsuya Sato
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-27 00:00:00 +09:00
|
14
|
+
default_executable:
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description:
|
18
|
+
email: satoryu.1981@gmail.com
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- LICENCE.txt
|
27
|
+
- lib/tepco_usage_api.rb
|
28
|
+
- spec/tepco_usage_api_spec.rb
|
29
|
+
- spec/spec_helper.rb
|
30
|
+
has_rdoc: true
|
31
|
+
homepage: http://github.com/satoryu/tepco_usage_api/
|
32
|
+
licenses: []
|
33
|
+
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 1.8.7
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.5.2
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: The gem to talk with Yahoo! Web API.
|
58
|
+
test_files: []
|
59
|
+
|