lib/ripple.rb in ripple-0.9.5 vs lib/ripple.rb in ripple-1.0.0.beta
- old
+ new
@@ -1,19 +1,5 @@
-# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
require 'riak'
require 'erb'
require 'yaml'
require 'active_model'
require 'ripple/core_ext'
@@ -66,18 +52,25 @@
# Evaluates the configuration with ERB before loading.
def load_configuration(config_file, config_keys = [:ripple])
config_file = File.expand_path(config_file)
config_hash = YAML.load(ERB.new(File.read(config_file)).result).with_indifferent_access
config_keys.each {|k| config_hash = config_hash[k]}
+ configure_ports(config_hash)
self.config = config_hash || {}
rescue Errno::ENOENT
raise Ripple::MissingConfiguration.new(config_file)
end
alias_method :load_config, :load_configuration
private
def client_config
config.slice(*Riak::Client::VALID_OPTIONS)
+ end
+
+ def configure_ports(config)
+ return unless config && config[:min_port]
+ config[:http_port] ||= (config[:min_port].to_i)
+ config[:pb_port] ||= (config[:min_port].to_i + 1)
end
end
# Exception raised when the path passed to
# {Ripple::load_configuration} does not point to a existing file.