attack / barometer Goto Github PK
View Code? Open in Web Editor NEWA multi API consuming weather forecasting superstar.
License: MIT License
A multi API consuming weather forecasting superstar.
License: MIT License
When using
weather.windy?(10)
or
weather.wet?(50)
an error is thrown
ArgumentError: invalid date
When I tried to upgrade to 0.9.0 I was constantly getting:
`require': cannot load such file -- addressable/uri (LoadError)
Rolling back to 0.8.0 fixed the issue.
Are the dependencies correct on 0.9.0?
This works: {1=>{:wunderground=>{:version=>:v1}}}
The readme shows it should be possible to use just the key directly instead of a hash:
irb(main):014:0> Barometer.config = {1 => :wunderground}
=> {1=>:wunderground}
irb(main):015:0> w = Barometer.new("London, England").measure.current
TypeError: can't convert nil into Hash
I'm not sure if this is just outdated documentation or an actual bug.
I keep receiving a
NoMethodError: undefined method `meta_add_field' for "":String
I'm using Rails4 with Ruby2.1.0dev
From the Rails console I typed:
@weather = Barometer.new("Orlando, FL")
As soon as I call:
@weather.measure
the error message is thrown.
For some locations, Barometer does not provides weather informations while the wunderground api itself does give weather informations.
I tried to look into it, and I don't see any differences beetween a working call and a non working one when hitting the wunderground API's, except in the geo lookup, the nearby_weather_stations is empty for a non working lookup (through Barometer)
Here's an example of non working call: http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=44.49696449763313,5.942831039428711
and
http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=44.49696449763313,5.942831039428711
and a working one: http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=50.22258185436699,4.894688129425049
and
http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=50.22258185436699,4.894688129425049
I tryed to figure it out, but could find the origin of the problem and I would probably need a lot of time.
Regards and thank you for the really useful Gem(s)
Geoffroy
If you're not going to support historical values, which seems to be the case based on #9, the gem should return an error instead of nil when someone attempts to get a reading from the past.
When I do pull data for US zipcode "41023" and use wunderground service in variable data['observation_time']
is value 'Last Updated on , ' (file: lib/barometer/weather_services/wunderground.rb line 107).
So 'current.updated_at = Data::LocalDateTime.parse(data['observation_time']) if data['observation_time']'
throw exception 'ArgumentError: ArgumentError '.
My config is: Barometer.config = { 1 => :wunderground, 2 => :google, 3 => :yahoo, 4 => :weather, 5 => :weather_bug}
Thanks.
I've been trying to get the weather for a specific date, but I keep getting this error message. I'm using rails 4. I've copied and pasted the exact code from the example. Seems like its not working?
Looking at master branch,
Wunderground returns a 0000 year:
Barometer.config = {1=>{:wunderground=>{:version=>:v1}}}
w = Barometer.new("London, England").measure.current
w.observed_at.year # == 0
w.stale_at.year # == 0
Yahoo throws an error:
Barometer.config = {1=>{:yahoo=>{:version=>:v1}}}
w = Barometer.new("London, England").measure.current
ArgumentError: invalid date
from gems/activesupport-3.2.12/lib/active_support/core_ext/date_time/conversions.rb:79:in `civil'
Hey there,
I haven't had any issues using the gem with yahoo or google but the gem is consistently crashing when I attempt to use weatherbugs API. My client specifically wants to use weatherbug for their project. Doh!
I am going to submit a pull request for parsing the latitude and longitude. But my question here is regarding the weatherbug API in general. It looks like the API may have changed. In the documentation I was able to find this:
http://i.wxbug.net/REST/SP/getLiveWeatherRSS.aspx?api_key=xxxxx&stationid=<stationid>&UnitType=<UnitType>&OutputType=<OutputType>
However, it looks like the current implementation for weatherbug is possibly calling a deprecated API:
"http://#{@api_code}.api.wxbug.net/getLiveWeatherRSS.aspx"
With the new API I'm uncertain what to supply for the stationID and unit/output types. I'll do further research but we'll most likely need to update the WeatherBugCassette in the spec suite unless I'm missing something. Here is the current implementation's request and access denied response from WeatherBug:
--- !ruby/object:HTTP::Message
http_header: !ruby/object:HTTP::Message::Headers
http_version: '1.1'
body_size: 0
chunked: false
request_method: GET
request_uri: !ruby/object:HTTPClient::Util::AddressableURI
validation_deferred: false
scheme: http
normalized_scheme:
uri_string:
hash:
host: [filtered].api.wxbug.net
authority:
normalized_host:
path: /getLiveWeatherRSS.aspx
normalized_path:
query: ACode=[filtered]&OutputType=1&UnitType=1&lat=33.4483771&long=-112.0740373
normalized_query:
request_query:
request_absolute_uri:
status_code: 200
reason_phrase: OK
body_type:
body_charset:
body_date:
body_encoding: !ruby/object:Encoding {}
is_request: false
header_item:
- - Cache-Control
- private
- - Content-Type
- text/html; charset=utf-8
- - Date
- Thu, 31 Oct 2013 20:27:33 GMT
- - Server
- Microsoft-IIS/7.5
- - Set-Cookie
- ASP.NET_SessionId=c2cudoyupsh5kwn40c2xecf4; path=/; HttpOnly
- - X-AspNet-Version
- 4.0.30319
- - X-Powered-By
- ASP.NET
- - Content-Length
- '13'
- - Connection
- keep-alive
dumped: false
peer_cert:
http_body: !ruby/object:HTTP::Message::Body
body: Access Denied
size: 0
positions:
chunk_size:
I think you forgot to create dependency to httparty in your gem.
Hello!
Thanks for publishing this gem.
I plan on building an HTML frontend to provide a simple GUI for daily weather and a weekly forecast.I would like to display the correct images for a Result object's icon property and so am curious about all possible values. I quickly perused the gem but did not see the exact answer.
Does this gem normalize the Icon property value to various strings? Or do various weather API's return different string values and the gem just passes them along?
In some environments (e.g. runit) there is no $HOME environment variable. Loading Barometer fails with this error:
/gems/barometer-0.8.0/lib/barometer/key_file_parser.rb:2:in `expand_path': couldn't find HOME environment -- expanding `~' (ArgumentError)
lat - 53.9
lon - 27.56667
timzeone comes as FET in barometer
barometer (0.9.3) lib/barometer/data/zone.rb:15:in `initialize' barometer (0.9.3) lib/barometer/weather_services/response/time_zone.rb:10:in `new' barometer (0.9.3) lib/barometer/weather_services/response/time_zone.rb:10:in `parse' barometer (0.9.3) lib/barometer/weather_services/wunderground_v1/current_response.rb:20:in `parse' barometer (0.9.3) lib/barometer/weather_services/wunderground_v1.rb:19:in `measure!' barometer (0.9.3) lib/barometer/weather_services/wunderground_v1.rb:10:in `call' barometer (0.9.3) lib/barometer/weather_services/base.rb:25:in `block in measure_and_record_status' barometer (0.9.3) lib/barometer/weather_services/base.rb:30:in `capture_status_code' barometer (0.9.3) lib/barometer/weather_services/base.rb:24:in `measure_and_record_status' barometer (0.9.3) lib/barometer/weather_services/base.rb:13:in `block in measure' barometer (0.9.3) lib/barometer/weather_services/base.rb:44:in `record_time' barometer (0.9.3) lib/barometer/weather_services/base.rb:12:in `measure' barometer (0.9.3) lib/barometer/base.rb:42:in `measure_and_record' barometer (0.9.3) lib/barometer/base.rb:37:in `block in measure_using_all_services_in_level' barometer (0.9.3) lib/barometer/utils/config_reader.rb:27:in `_dig' barometer (0.9.3) lib/barometer/utils/config_reader.rb:34:in `block in _dig' barometer (0.9.3) lib/barometer/utils/config_reader.rb:33:in `each' barometer (0.9.3) lib/barometer/utils/config_reader.rb:33:in `_dig' barometer (0.9.3) lib/barometer/utils/config_reader.rb:11:in `services' barometer (0.9.3) lib/barometer/base.rb:36:in `measure_using_all_services_in_level' barometer (0.9.3) lib/barometer/base.rb:29:in `block in measure_until_successful' barometer (0.9.3) lib/barometer/utils/config_reader.rb:6:in `block in take_level_while' barometer (0.9.3) lib/barometer/utils/config_reader.rb:5:in `each' barometer (0.9.3) lib/barometer/utils/config_reader.rb:5:in `take_while' barometer (0.9.3) lib/barometer/utils/config_reader.rb:5:in `take_level_while' barometer (0.9.3) lib/barometer/base.rb:28:in `measure_until_successful' barometer (0.9.3) lib/barometer/base.rb:12:in `block in measure' barometer (0.9.3) lib/barometer/base.rb:23:in `record_time' barometer (0.9.3) lib/barometer/base.rb:11:in `measure'
b = Barometer.new('55.75222,37.61556')
b.measure
ArgumentError: invalid date from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/utils/time.rb:25:in `strptime' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/utils/time.rb:25:in `strptime' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/utils/time.rb:13:in `parse' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/data/attributes/time.rb:6:in `coerce' from ~/.rvm/gems/ruby-2.1.1@cta/gems/virtus-1.0.2/lib/virtus/attribute/coercible.rb:14:in `set' from ~/.rvm/gems/ruby-2.1.1@cta/gems/virtus-1.0.2/lib/virtus/attribute_set.rb:146:in `block in define_writer_method' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/wunderground_v1/response/current_weather.rb:12:in `parse' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/wunderground_v1/current_response.rb:17:in `parse' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/wunderground_v1.rb:19:in `measure!' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/wunderground_v1.rb:10:in `call' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:25:in `block in measure_and_record_status' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:30:in `capture_status_code' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:24:in `measure_and_record_status' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:13:in `block in measure' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:44:in `record_time' from ~/.rvm/gems/ruby-2.1.1@cta/gems/barometer-0.9.5/lib/barometer/weather_services/base.rb:12:in `measure'
I discovered that payload.fetch('local_time') returns "April 25, 12:08 PM .tzname" in weather_services/wunderground_v1/response/current_weather.rb may be this is issue?
Using the default code for creating weather information .
barometer = Barometer.new("L0S1C0") creates error when postal code is entered but Zip codes working fine.
Keyless access to Google Maps APIs has been deprecated for over a year: https://mapsplatform.googleblog.com/2016/06/building-for-scale-updates-to-google.html
Error log:
[sx@sx-pc barometer]$ ruby w.rb
Traceback (most recent call last):
48: from w.rb:4:in `<main>'
47: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:11:in `measure'
46: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:23:in `record_time'
45: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:12:in `block in measure'
44: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:28:in `measure_until_successful'
43: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:5:in `take_level_while'
42: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:5:in `take_while'
41: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:5:in `each'
40: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:6:in `block in take_level_while'
39: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:29:in `block in measure_until_successful'
38: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:36:in `measure_using_all_services_in_level'
37: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:11:in `services'
36: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:33:in `_dig'
35: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:33:in `each'
34: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:34:in `block in _dig'
33: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/utils/config_reader.rb:27:in `_dig'
32: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:37:in `block in measure_using_all_services_in_level'
31: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/base.rb:42:in `measure_and_record'
30: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:12:in `measure'
29: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:44:in `record_time'
28: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:13:in `block in measure'
27: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:24:in `measure_and_record_status'
26: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:30:in `capture_status_code'
25: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/base.rb:25:in `block in measure_and_record_status'
24: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1.rb:10:in `call'
23: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1.rb:18:in `measure!'
22: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1.rb:18:in `new'
21: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1/current_api.rb:8:in `initialize'
20: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1/current_api.rb:8:in `new'
19: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1/query.rb:15:in `initialize'
18: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/weather_services/wunderground_v1/query.rb:25:in `convert_query'
17: from /usr/lib/ruby/2.5.0/delegate.rb:83:in `method_missing'
16: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/base.rb:40:in `convert!'
15: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/base.rb:78:in `do_conversion'
14: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/base.rb:78:in `map'
13: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/base.rb:81:in `block in do_conversion'
12: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/converters/to_geocode.rb:16:in `call'
11: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/services/google_geocode.rb:16:in `call'
10: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/services/google_geocode.rb:25:in `parse_payload'
9: from /home/sx/.gem/ruby/2.5.0/gems/barometer-0.9.7/lib/barometer/query/services/google_geocode.rb:37:in `latitude'
8: from /usr/lib/ruby/2.5.0/delegate.rb:83:in `method_missing'
7: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:19:in `fetch'
6: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:68:in `fetch_value_or_attribute'
5: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:68:in `inject'
4: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:68:in `each'
3: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:69:in `block in fetch_value_or_attribute'
2: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:75:in `fetch_value'
1: from /home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:80:in `fetch_native'
/home/sx/.gem/ruby/2.5.0/gems/choc_mool-0.0.1/lib/choc_mool.rb:80:in `fetch': no implicit conversion of String into Integer (TypeError)
Hi Mark,
Thanks for the gem, I love it. This is the first time I'm using the weather.for part of the gem and I am getting a nil back even when using your example. The only time it does work is when I pass in the current time.
I have pasted some output here: https://gist.github.com/1147675
Thanks again
Currently it is not possible to get historical weather data using
weather.for(time)
Update: E.g. http://english.wunderground.com/history/ is providing this data.
Create the option to choose the language that we want to bring the data.
There appears to be an issue either with httpparty or FakeWeb as the specs are failing due to httpparty not returning correctly parsed responses. The responses appear to be coming back as if they where strings rather then the usual response that can be used as a hash.
I have been adding the UK metoffice service and am having to make use of the vcr gem instead of just FakeWeb for testing purposes which is odd because VCR can make use of FakeWeb for its own stubbing.
I presume this is either a config issue or a version problem with either the httpparty or FakeWeb gems. It may help to lock these down to versions that are known to work together.
When I send a query that returns a place name that contains utf-8 characters in it, I get ~71 lines for the stack trace, and right at the top, I see this:
[2011/07/08 16:25:01.450] !! C:/Ruby192/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:441:in `rescue in pull': #<Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)>
I've done some research, and the way to fix it would be to use
Encoding.default_internal = Encoding.default_external = "UTF-8"`
at some point in the api query code.
Currently I have this monkey-patch solution included in our spec_helper so we can do Barometer.stub!
:
https://gist.github.com/avit/4747535
Ideally I think it should be possible to just configure Barometer with a :null
stub in the test environment so it returns a valid canned response instead of requiring VCR or Fakeweb set up on our end and linking it into your gem's cassettes, or recording our own responses.
I can try providing a patch, but I think there were some hard dependencies on current?
that I couldn't get around without monkey-patching. It might work fine if we make the null object respond with some dynamic values instead of loading from the fixture file. (It's been a while, I don't remember exactly what the issue was without digging into the code again.)
Is there a list of all the possible responses for
weather.current.icon
I'd like to map them to icons, but need to know the values before I am able to do that.
I'm wishing for the fix in 796f95a in an official version. There are a lot of commits since 0.8.0, I'm not sure if this should be a 0.8.1 patch release, 0.9, or go all the way to 1.0!
Haven't tested other weather providers besides wunderground, but when attempting to usie Yahoo, I'm experiencing a Psych parse error when barometer.measure is called. It was throwing an error trying to parse the zone_codes.yml file because of a control character on line 268:
SWT^L : 1
Once I deleted the control character on that line, things ran as normal.
Looking up the weather for this location via wunderground v1 throws an error:
Barometer.new('-8.69129,115.168').measure
It looks like the response includes measurement times in "CIT" timezone, and this throws the error when trying to parse it:
ArgumentError: invalid time zone
from /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/barometer-0.9.4/lib/barometer/data/zone.rb:15:in `initialize'
Hi,
I'm wondering whether it is possible to obtain the weather foreast for a certain defined time (e.g. 13:30 13/02/2013)? As far as I can see, there is no difference between querying on a time or on a date as you will get data for the whole day with high and low temperatures available but there is no data provided for the exact time of the day specified, is that correct?
I know historical data is not supported, my question only relates to forecasts.
Thanks for a great gem by the way!
Regards,
Nicolas
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.