Git Product home page Git Product logo

barometer's Introduction

Barometer

Build Status Gem Version Code Climate Coverage Status

A multi API consuming weather forecasting superstar.

Barometer provides a common public API to one or more weather services (APIs) of your choice. Weather services can co-exist to retrieve extensive information, or they can be used in a hierarchical configuration where lower preferred weather services are only used if previous services are unavailable.

Barometer handles all conversions of the supplied query, so that the same query can be used for all (or most) services, even if they don't support the query directly. See the "Queries" section for more info.

Key Features

  • works and tested with ruby >= 2.2, but might be fine >= 1.9.3 (see Travis CI status to confirm)
  • supports 4 weather services, more planned
  • the same query can be used with any supported weather service
  • provides a powerful data object to hold the weather information
  • provides a simple plugin api to allow more weather services to be added
  • failover configuration
  • multiple services configuration to provide average values

Usage

You can use barometer right out of the box, as it is configured to use one register-less (no API key required) international weather service (wunderground.com).

require 'barometer'

barometer = Barometer.new('Paris')
weather = barometer.measure

puts weather.current.temperature

See detailed usage further down.

Dependencies

Dependency Status

Queries

The query handling is one of the most beneficial and powerful features of Barometer. Every weather service accepts a different set of possible queries, so it usually is the case that the same query can only be used for a couple weather services.

Barometer will allow the use of all query formats for all services. It does this by first determining the original query format, then converting the query to a compatible format for each specific weather service.

For example, Yahoo! only accepts US Zip Code or Weather.com ID. With Barometer you can query Yahoo! with a simple location (ie: Paris) or even an Airport code (ICAO) and it will return the weather as expected.

Acceptable Formats

  • zipcode
  • icao (international airport code)
  • coordinates (latitude and longitude)
  • postal code
  • weather.com ID
  • location name (ie address, city, state, landmark, etc.)
  • woeid (where on earth id, by Yahoo!)

Detailed Usage

Sources

The current available sources are:

Source Configuration

Barometer can be configured to use multiple weather service APIs (either in a primary/failover config or in parallel). Each weather service can also have its own config.

Weather services in parallel

Barometer.config = { 1 => [:yahoo, :wunderground] }

Weather services in primary/failover

Barometer.config = { 1 => [:yahoo], 2 => :wunderground }

Weather services, one with some configuration. In this case we are setting a weight value, this weight is respected when calculating averages.

Barometer.config = { 1 => [{wunderground: {weight: 2}}, :yahoo] }

Weather services, one with keys.

Barometer.config = { 1 => [:yahoo, {noaa: {keys: {code: CODE_KEY} }}] }

Multiple weather API, with hierarchy

require 'barometer'

# use yahoo and noaag, if they both fail, use wunderground
Barometer.config = { 1 => [:yahoo, :noaa], 2 => :wunderground }

barometer = Barometer.new('Paris')
weather = barometer.measure

puts weather.current.temperature

Command Line

Extracted to separate gem: barometer-cli

Searching

After you have measured the data, Barometer provides several methods to help you get the data you are after. All examples assume you already have measured the data as shown in the above examples.

By relativity

weather.current       # returns the first successful current_measurement
weather.forecast      # returns the first successful forecast_measurements
weather.today         # returns the first successful forecast_measurement for today
weather.tomorrow      # returns the first successful forecast_measurement for tomorrow

puts weather.current.temperature.c
puts weather.tomorrow.high.c

By date

# note, the date is the date of the locations weather, not the date of the
# user measuring the weather
date = Date.parse('01-01-2009')
weather.for(date)       # returns the first successful forecast_measurement for the date

puts weather.for(date).high.c

By time

# note, the time is the time of the locations weather, not the time of the
# user measuring the weather
time = Time.parse('13:00 01-01-2009')
weather.for(time)       # returns the first successful forecast_measurement for the time

puts weather.for(time).low.f

Averages

If you consume more then one weather service, Barometer will provide averages for the values (currently only for the 'current' values and not the forecasted values).

require 'barometer'

# use yahoo and wunderground
Barometer.config = { 1 => [:yahoo, :wunderground] }

barometer = Barometer.new('90210')
weather = barometer.measure

puts weather.temperature

This will calculate the average temperature as given by :yahoo and :wunderground

Weights

You can weight the values from a weather service so that the values from that web service have more influence then other values. The weights are set in the config ... see the config section

Contributions

Thank you to these developers who have contributed. No contribution is too small.

Links

Copyright

Copyright (c) 2009-2018 Mark Gangl. See LICENSE for details.

barometer's People

Contributors

attack avatar avit avatar floere avatar internethostage avatar jimjeffers avatar plukevdh avatar saulius avatar williamcodes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

barometer's Issues

undefined method `high' for nil:NilClass

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?

measure fails with ArgumentError: invalid date

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?

Add a WeatherService::Null object for testing in client apps

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.)

i18n

Create the option to choose the language that we want to bring the data.

Release updated gem

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!

v0.8.0...master

All possible Barometer::Measurement::Result Icon property values

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?

Errors with Time parsing from response

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'

Support for WeatherBug API?

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: 

Unable to run; neither this repo nor CLI version

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)

FYI: Had to rollback to 0.8.0

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?

Measurement fails for some locations due to time zone error

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'

Parse observation_time error from wunderground service

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.

Weather Icons

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.

Config fails with :wunderground key as described in README

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.

crash - Invalid time zone (wunderground)

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'

Forecast temperature at a specific time?

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

YAML parse error in zone_codes.yml

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.

rexml throws up when utf-8 characters are returned.

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.

Key file parser depends on $HOME

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)

weather.for(time) problem

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

undefined method 'meta_add_field' for "":String

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.

Testing Problems with httpparty and FakeWeb

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.

Wunderground.com / coordinates problem

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.