weatherbug 0.0.1 → 0.0.2

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.
@@ -13,6 +13,20 @@ module WeatherBug
13
13
  register_transformer 'aws:hi/@units', :name => :temp_units
14
14
  register_transformer 'aws:prob-of-precip', :name => :probability_of_precipitation
15
15
 
16
+ def date
17
+ date ||= begin
18
+ key = title.split[0] # Remove 'night'
19
+ return Date.today if key == 'Today' || key == 'Tonight'
20
+ return Date.today + 1 if key == 'Tomorrow'
21
+ # Figure out how far forward to go
22
+ return nil unless appropriate_wday_index = Date::DAYNAMES.index(key)
23
+ today_index = Date.today.wday
24
+
25
+ distance = appropriate_wday_index - today_index
26
+ Date.today + (distance > 0 ? distance : distance + 7)
27
+ end
28
+ end
29
+
16
30
  end
17
31
 
18
32
  end
@@ -1,6 +1,6 @@
1
1
  module WeatherBug
2
2
 
3
- VERSION = [0, 0, 1]
3
+ VERSION = [0, 0, 2]
4
4
 
5
5
  def self.version
6
6
  VERSION.join('.')
data/lib/weatherbug.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'rubygems'
3
3
  require 'nokogiri'
4
4
  require 'open-uri'
5
+ require 'date'
5
6
 
6
7
  module WeatherBug
7
8
 
@@ -14,7 +15,6 @@ module WeatherBug
14
15
 
15
16
  API_URL = 'datafeed.weatherbug.com'
16
17
 
17
-
18
18
  # Set your application's partner ID
19
19
  def self.partner_id=(partner_id)
20
20
  @partner_id = partner_id
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weatherbug
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Crepezzi
@@ -32,6 +32,34 @@ dependencies:
32
32
  version: "0"
33
33
  type: :development
34
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: nokogiri
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: open-uri
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :runtime
62
+ version_requirements: *id003
35
63
  description: Light Wrapper for the WeatherBug partner API
36
64
  email: john.crepezzi@patch.com
37
65
  executables: []