Skip to content

Commit

Permalink
Creating a config generator for Geocoder.
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jul 21, 2011
1 parent 86f418f commit 268f3d5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/generators/config.rb
@@ -0,0 +1,12 @@
module Geocoder
class ConfigGenerator < Rails::Generators::Base
source_root File.expand_path("../templates", __FILE__)

desc "This generator creates an initializer file at config/initializers, " +
"with the default configuration options for Geocoder."
def add_initializer
template "initializer.rb", "config/initializers/geocoder.rb"
end
end
end

25 changes: 25 additions & 0 deletions lib/generators/templates/initializer.rb
@@ -0,0 +1,25 @@
Geocoder.configure do
## Configurable parameters: if you wish to change some configurable
## behaviour in Geocoder, feel free to uncomment the following lines
## and provide custom parameters.

# config.timeout = 3 # geocoding service timeout (secs)
# config.lookup = :google # name of geocoding service (symbol)
# config.language = :en # ISO-639 language code
# config.use_https = false # use HTTPS for lookup requests? (if supported)
# config.http_proxy = nil # HTTP proxy server (user:pass@host:port)
# config.https_proxy = nil # HTTPS proxy server (user:pass@host:port)
# config.api_key = nil # API key for geocoding service
# config.cache = nil # cache object (must respond to #[], #[]=, and #keys)
# config.cache_prefix = "geocoder:" # prefix (string) to use for all cache keys

## exceptions that should not be rescued by default
## (if you want to implement custom error handling);
## supports SocketError and TimeoutError
# config.always_raise = []

## Calculation options
# config.units = :mi # :km for kilometers or :mi for miles
# config.method = :linear # :spherical or :linear
end

4 changes: 2 additions & 2 deletions lib/geocoder/configuration.rb
Expand Up @@ -28,8 +28,8 @@ module Geocoder
# config.always_raise = []
#
# # Calculation options
# @units = :mi # :km for kilometers or :mi for miles
# @method = :linear # :spherical or :linear
# config.units = :mi # :km for kilometers or :mi for miles
# config.method = :linear # :spherical or :linear
# end
#
# @example Using +Geocoder::Configuration+ class directly, like in:
Expand Down

0 comments on commit 268f3d5

Please sign in to comment.