lib/elasticsearch/transport/client.rb in elasticsearch-transport-1.0.4 vs lib/elasticsearch/transport/client.rb in elasticsearch-transport-1.0.5

- old
+ new

@@ -31,10 +31,12 @@ # attr_accessor :transport # Create a client connected to an Elasticsearch cluster. # + # Specify the URL via arguments or set the `ELASTICSEARCH_URL` environment variable. + # # @option arguments [String,Array] :hosts Single host passed as a String or Hash, or multiple hosts # passed as an Array; `host` or `url` keys are also valid # # @option arguments [Boolean] :log Use the default logger (disabled by default) # @@ -71,11 +73,11 @@ # # @option arguments [Constant] :selector An instance of selector strategy implemented with # {Elasticsearch::Transport::Transport::Connections::Selector::Base}. # def initialize(arguments={}) - hosts = arguments[:hosts] || arguments[:host] || arguments[:url] + hosts = arguments[:hosts] || arguments[:host] || arguments[:url] || ENV.fetch('ELASTICSEARCH_URL', 'localhost:9200') arguments[:logger] ||= arguments[:log] ? DEFAULT_LOGGER.call() : nil arguments[:tracer] ||= arguments[:trace] ? DEFAULT_TRACER.call() : nil arguments[:reload_connections] ||= false arguments[:retry_on_failure] ||= false @@ -112,11 +114,11 @@ # @return [Array<Hash>] # @raise [ArgumentError] # # @api private # - def __extract_hosts(hosts_config=nil, options={}) - hosts_config = hosts_config.nil? ? ['localhost'] : Array(hosts_config) + def __extract_hosts(hosts_config, options={}) + hosts_config = Array(hosts_config) hosts = hosts_config.map do |host| case host when String if host =~ /^[a-z]+\:\/\//