Skip to content

Commit

Permalink
provide inflections for the resource (etc) names involved
Browse files Browse the repository at this point in the history
  • Loading branch information
seamusabshere committed Jul 1, 2011
1 parent 2f38a49 commit 1499ba5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/brighter_planet_metadata/metadata.rb
Expand Up @@ -5,10 +5,19 @@
%w{
active_support/json
active_support/core_ext/object/blank
active_support/inflector/inflections
}.each do |active_support_3_requirement|
require active_support_3_requirement
end if ::ActiveSupport::VERSION::MAJOR == 3

::ActiveSupport::Inflector.inflections do |inflect|
inflect.uncountable %w{ aircraft bts_aircraft }
inflect.uncountable 'species'
inflect.irregular 'foot', 'feet'
inflect.plural /(gas)\z/i, '\1es'
inflect.singular /(gas)es\z/i, '\1'
end

module BrighterPlanet
class Metadata
include ::Singleton
Expand Down
9 changes: 9 additions & 0 deletions test/test_live_data1.rb
Expand Up @@ -53,4 +53,13 @@ def test_datasets
def test_what_must_come_from_other_sources
assert_equal ::BrighterPlanet::Metadata::FALLBACK['emitters'], ::BrighterPlanet.metadata.emitters
end

def test_inflection
assert_equal 'GreenhouseGases', 'GreenhouseGas'.pluralize
assert_equal 'greenhouse_gases', 'greenhouse_gas'.pluralize
assert_equal 'GreenhouseGas', 'GreenhouseGases'.singularize
assert_equal 'Aircraft', 'Aircraft'.pluralize
assert_equal 'aircraft', 'aircraft'.pluralize
assert_equal 'Aircraft', 'Aircraft'.singularize
end
end
1 change: 0 additions & 1 deletion test/test_live_remote.rb
@@ -1,7 +1,6 @@
require 'helper'

require 'active_support/json/encoding'
require 'active_support/inflector/inflections'

class TestLiveRemote < Test::Unit::TestCase
def setup
Expand Down

0 comments on commit 1499ba5

Please sign in to comment.