Class: BrighterPlanet::Metadata
- Inherits:
-
Object
- Object
- BrighterPlanet::Metadata
- Includes:
- Singleton
- Defined in:
- lib/brighter_planet_metadata/metadata.rb
Constant Summary collapse
- LIVE_URL =
{ 'datasets' => 'http://data.brighterplanet.com/datasets.json', 'emitters' => 'http://impact.brighterplanet.com/emitters.json', 'certified_emitters' => 'http://certified.impact.brighterplanet.com/emitters.json', 'resources' => 'http://data.brighterplanet.com/resources.json', 'protocols' => 'http://impact.brighterplanet.com/protocols.json', 'automobiles_options' => 'http://impact.brighterplanet.com/automobiles/options.json', 'automobile_trips_options' => 'http://impact.brighterplanet.com/automobile_trips/options.json', 'bus_trips_options' => 'http://impact.brighterplanet.com/bus_trips/options.json', 'computations_options' => 'http://impact.brighterplanet.com/computations/options.json', 'diets_options' => 'http://impact.brighterplanet.com/diets/options.json', 'electricity_uses_options' => 'http://impact.brighterplanet.com/electricity_uses/options.json', 'flights_options' => 'http://impact.brighterplanet.com/flights/options.json', 'fuel_purchases_options' => 'http://impact.brighterplanet.com/fuel_purchases/options.json', 'lodgings_options' => 'http://impact.brighterplanet.com/lodgings/options.json', 'meetings_options' => 'http://impact.brighterplanet.com/meetings/options.json', 'motorcycles_options' => 'http://impact.brighterplanet.com/motorcycles/options.json', 'pets_options' => 'http://impact.brighterplanet.com/pets/options.json', 'purchases_options' => 'http://impact.brighterplanet.com/purchases/options.json', 'rail_trips_options' => 'http://impact.brighterplanet.com/rail_trips/options.json', 'residences_options' => 'http://impact.brighterplanet.com/residences/options.json', 'shipments_options' => 'http://impact.brighterplanet.com/shipments/options.json', 'automobiles_committees' => 'http://impact.brighterplanet.com/automobiles/committees.json', 'automobile_trips_committees' => 'http://impact.brighterplanet.com/automobile_trips/committees.json', 'bus_trips_committees' => 'http://impact.brighterplanet.com/bus_trips/committees.json', 'computations_committees' => 'http://impact.brighterplanet.com/computations/committees.json', 'diets_committees' => 'http://impact.brighterplanet.com/diets/committees.json', 'electricity_uses_committees' => 'http://impact.brighterplanet.com/electricity_uses/committees.json', 'flights_committees' => 'http://impact.brighterplanet.com/flights/committees.json', 'fuel_purchases_committees' => 'http://impact.brighterplanet.com/fuel_purchases/committees.json', 'lodgings_committees' => 'http://impact.brighterplanet.com/lodgings/committees.json', 'meetings_committees' => 'http://impact.brighterplanet.com/meetings/committees.json', 'motorcycles_committees' => 'http://impact.brighterplanet.com/motorcycles/committees.json', 'pets_committees' => 'http://impact.brighterplanet.com/pets/committees.json', 'purchases_committees' => 'http://impact.brighterplanet.com/purchases/committees.json', 'rail_trips_committees' => 'http://impact.brighterplanet.com/rail_trips/committees.json', 'residences_committees' => 'http://impact.brighterplanet.com/residences/committees.json', 'shipments_committees' => 'http://impact.brighterplanet.com/shipments/committees.json', }.freeze
- FALLBACK =
begin ::MultiJson.decode(::File.read(::File.('../fallbacks.json', __FILE__))).freeze rescue $stderr.puts "[brighter_planet_metadata] Error while loading fallbacks. Please reinstall library." {} end
Instance Method Summary collapse
-
#as_cache_key ⇒ Object
for cache_method.
-
#certified_emitters ⇒ Object
What certified_emitters are available.
-
#committees(emitter) ⇒ Object
committees (decisions) available for a given emitter.
-
#datasets ⇒ Object
What datasets are available.
-
#emitters ⇒ Object
What emitters are available.
-
#options(emitter) ⇒ Object
options (characteristics) available for a given emitter.
-
#protocols ⇒ Object
What protocols are recognized.
-
#refresh ⇒ Object
Clear out any cached values.
-
#resources ⇒ Object
What resources are available.
Instance Method Details
#as_cache_key ⇒ Object
for cache_method
114 115 116 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 114 def as_cache_key 'BrighterPlanet::Metadata.instance' end |
#certified_emitters ⇒ Object
What certified_emitters are available.
78 79 80 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 78 def certified_emitters 'certified_emitters' end |
#committees(emitter) ⇒ Object
committees (decisions) available for a given emitter
103 104 105 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 103 def committees(emitter) "#{emitter.to_s.pluralize.downcase}_committees" end |
#datasets ⇒ Object
What datasets are available.
88 89 90 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 88 def datasets 'datasets' end |
#emitters ⇒ Object
What emitters are available.
83 84 85 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 83 def emitters 'emitters' end |
#options(emitter) ⇒ Object
options (characteristics) available for a given emitter
98 99 100 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 98 def (emitter) "#{emitter.to_s.pluralize.downcase}_options" end |
#protocols ⇒ Object
What protocols are recognized
93 94 95 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 93 def protocols 'protocols' end |
#refresh ⇒ Object
Clear out any cached values
108 109 110 111 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 108 def refresh # instance_variables.each { |ivar_name| instance_variable_set ivar_name, nil } cache_method_clear :authoritative_value_or_fallback end |
#resources ⇒ Object
What resources are available.
73 74 75 |
# File 'lib/brighter_planet_metadata/metadata.rb', line 73 def resources 'resources' end |