sandy 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ gemfile:
5
+ - Gemfile
6
+ script: bundle exec rspec spec
data/README.md CHANGED
@@ -1,17 +1,42 @@
1
1
  # Sandy
2
2
 
3
+ Rubygem for consuming power outage data for the Greater New York area. Currently supports ConEd.
4
+ [![Build Status](https://secure.travis-ci.org/ckundo/sandy.png)](https://travis-ci.org/ckundo/sandy)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'sandy'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install sandy
19
+
20
+
3
21
  ## Usage
4
22
 
5
23
  ### ConEd
24
+ The ConEd outage feed is only updated every 15 minutes. Repeated polling won't get you new results.
25
+ You can schedule a task to run every 15 minutes and you'll have up to date results.
26
+
27
+ Example:
28
+
6
29
  report = Sandy::Provider::ConEd::Report.new
7
30
 
8
- #### Regions
31
+ Regions:
32
+
9
33
  regions = report.regions
10
34
  regions.each do |region|
11
35
  puts "#{region.name}, #{region.customers_affected}"
12
36
  end
13
37
 
14
- Outputs:
38
+ =>
39
+
15
40
  Bronx, 28644
16
41
  Brooklyn, 37016
17
42
  Manhattan, 226225
@@ -21,14 +46,15 @@ Outputs:
21
46
 
22
47
  Also available are `region.latitude`, `region.longitude`, and `region.total_customers` (see neighborhoods section)
23
48
 
24
- #### Neighborhoods
49
+ Neighborhoods:
25
50
 
26
51
  neighborhoods = report.neighborhoods
27
52
  neighborhoods.each do |neighborhood|
28
53
  puts "#{neighborhood.name} (#{neighborhood.latitude}, #{neighborhood.longitude}) #{neighborhood.customers_affected} out of #{neighborhood.total_customers}"
29
54
  end
30
55
 
31
- Outputs:
56
+ =>
57
+
32
58
  Central Bronx (40.82, -73.86) 26 out of 44452
33
59
  Fordham (40.86, -73.9) 164 out of 114772
34
60
  Northeast Bronx (40.87, -73.82) 13139 out of 79942
@@ -36,24 +62,6 @@ Outputs:
36
62
  Southeast Bronx (40.83, -73.82) 5919 out of 89736
37
63
  ...
38
64
 
39
- ## Installation
40
-
41
- Add this line to your application's Gemfile:
42
-
43
- gem 'sandy'
44
-
45
- And then execute:
46
-
47
- $ bundle
48
-
49
- Or install it yourself as:
50
-
51
- $ gem install sandy
52
-
53
- ## Usage
54
-
55
- TODO: Write usage instructions here
56
-
57
65
  ## Contributing
58
66
 
59
67
  1. Fork it
data/lib/sandy/area.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  module Sandy
2
2
  class Area
3
- attr_reader :name, :region, :customers_affected, :latitude, :longitude, :total_customers
3
+ attr_reader :name,
4
+ :region,
5
+ :customers_affected,
6
+ :latitude,
7
+ :longitude,
8
+ :total_customers,
9
+ :estimated_recovery_time
4
10
 
5
11
  def initialize(customers_affected, location, options = {})
6
12
  @name = location
@@ -9,6 +15,7 @@ module Sandy
9
15
  @total_customers = options[:total_customers]
10
16
  @latitude = options[:latitude]
11
17
  @longitude = options[:longitude]
18
+ @estimated_recovery_time = options[:estimated_recovery_time]
12
19
  end
13
20
  end
14
21
  end
@@ -21,6 +21,7 @@ module Sandy::Provider
21
21
  Sandy::Area.new(area.fetch("custs_out"), area.fetch("area_name"),
22
22
  { latitude: area["latitude"],
23
23
  longitude: area["longitude"],
24
+ estimated_recovery_time: area["etr"],
24
25
  total_customers: area["total_custs"] })
25
26
 
26
27
  end
@@ -33,6 +34,7 @@ module Sandy::Provider
33
34
  neighborhoods << Sandy::Area.new(sub_area.fetch("custs_out"), sub_area.fetch("area_name"),
34
35
  { region: area["area_name"],
35
36
  total_customers: sub_area["total_custs"],
37
+ estimated_recovery_time: sub_area["etr"],
36
38
  latitude: sub_area["latitude"],
37
39
  longitude: sub_area["longitude"] })
38
40
  end
data/lib/sandy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sandy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/spec/area_spec.rb CHANGED
@@ -29,5 +29,11 @@ describe Sandy::Area do
29
29
  its(:latitude) { should == 70.5 }
30
30
  its(:longitude) { should == -115.5 }
31
31
  end
32
+
33
+ context "with lat/lng" do
34
+ let(:etr) { Time.now + 600 }
35
+ subject { Sandy::Area.new(customers_affected, nil, { estimated_recovery_time: etr }) }
36
+ its(:estimated_recovery_time) { should == etr }
37
+ end
32
38
  end
33
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sandy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-02 00:00:00.000000000 Z
12
+ date: 2012-11-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -100,6 +100,7 @@ extensions: []
100
100
  extra_rdoc_files: []
101
101
  files:
102
102
  - .gitignore
103
+ - .travis.yml
103
104
  - Gemfile
104
105
  - LICENSE.txt
105
106
  - README.md