Module: OpenWeatherClient

Defined in:
lib/open_weather_client.rb,
lib/open_weather_client/caching.rb,
lib/open_weather_client/request.rb,
lib/open_weather_client/version.rb,
lib/open_weather_client/weather.rb,
lib/open_weather_client/configuration.rb,
lib/open_weather_client/caching/memory.rb

Overview

Get weather data from OpenWeatherMap

Defined Under Namespace

Classes: APIVersionNotSupportedError, AuthenticationError, Caching, Configuration, NotCurrentError, Request, Weather

Constant Summary collapse

VERSION =

Version of OpenWeatherClient

'0.2.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.cacheCaching

Get the singleton cache instance

Returns:



32
33
34
# File 'lib/open_weather_client.rb', line 32

def self.cache
  @cache ||= Caching.new
end

.configurationConfiguration

Get the singleton configuration instance

Returns:



40
41
42
# File 'lib/open_weather_client.rb', line 40

def self.configuration
  @configuration ||= Configuration.new
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Configure OpenWeatherClient

Yields:



53
54
55
# File 'lib/open_weather_client.rb', line 53

def self.configure
  yield configuration
end

.gem_rootObject

Get the gem root



68
69
70
71
72
73
# File 'lib/open_weather_client.rb', line 68

def self.gem_root
  spec = Gem::Specification.find_by_name('open_weather_client')
  spec.gem_dir
rescue NoMethodError
  project_root
end

.project_rootObject

Get the project root



59
60
61
62
63
64
# File 'lib/open_weather_client.rb', line 59

def self.project_root
  return Rails.root if defined?(Rails)
  return Bundler.root if defined?(Bundler)

  Dir.pwd
end

.resetObject

Reset cache and configuration



46
47
48
49
# File 'lib/open_weather_client.rb', line 46

def self.reset
  @cache = Caching.new
  @configuration = Configuration.new
end