diff --git a/lib/generators/config.rb b/lib/generators/config.rb new file mode 100644 index 0000000000000000000000000000000000000000..2bafead533dce3de5a5d551470b1b99cde569687 --- /dev/null +++ b/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 + diff --git a/lib/generators/templates/initializer.rb b/lib/generators/templates/initializer.rb new file mode 100644 index 0000000000000000000000000000000000000000..0401d015895507530bd4545573d9f3c6c0de8357 --- /dev/null +++ b/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 + diff --git a/lib/geocoder/configuration.rb b/lib/geocoder/configuration.rb index 867a4727d0a9203984a70e00c950bff61cf7aeec..5ae37bce448e6e91038eaffd228430565766c7e8 100644 --- a/lib/geocoder/configuration.rb +++ b/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: