Permalink
Browse files

Creating a config generator for Geocoder.

  • Loading branch information...
1 parent 86f418f commit 268f3d54eb0c1e01db610c970df59bf08bb96242 Anderson Bravalheri committed Jul 21, 2011
Showing with 39 additions and 2 deletions.
  1. +12 −0 lib/generators/config.rb
  2. +25 −0 lib/generators/templates/initializer.rb
  3. +2 −2 lib/geocoder/configuration.rb
View
12 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
+
View
25 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
+
View
4 lib/geocoder/configuration.rb
@@ -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:

0 comments on commit 268f3d5

Please sign in to comment.