Sha256: 0626af37f800cf47e730cf4b5881b8396e2180c7fe1bb72d33a5fdda1bd57b30
Contents?: true
Size: 1.56 KB
Versions: 3
Compression:
Stored size: 1.56 KB
Contents
module Sanford; end require 'ns-options' require 'pathname' require 'set' require 'sanford/host' require 'sanford/logger' require 'sanford/runner' require 'sanford/server' require 'sanford/service_handler' require 'sanford/version' ENV['SANFORD_SERVICES_FILE'] ||= 'config/services' module Sanford def self.register(host) @hosts.add(host) end def self.hosts @hosts end def self.config Sanford::Config end def self.configure(&block) self.config.define(&block) self.config end def self.init @hosts ||= Hosts.new require self.config.services_file end module Config include NsOptions::Proxy option :services_file, Pathname, :default => ENV['SANFORD_SERVICES_FILE'] option :logger, :default => Sanford::NullLogger.new option :runner, :default => Sanford::DefaultRunner end class Hosts def initialize(values = []) @set = Set.new(values) end # We want class names to take precedence over a configured name, so that if # a user specifies a specific class, they always get it def find(name) self.find_by_class_name(name) || self.find_by_name(name) end def find_by_class_name(class_name) @set.detect{|host_class| host_class.to_s == class_name.to_s } end def find_by_name(name) @set.detect{|host_class| host_class.name == name.to_s } end def method_missing(method, *args, &block) @set.send(method, *args, &block) end def respond_to?(method) super || @set.respond_to?(method) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sanford-0.6.3 | lib/sanford.rb |
sanford-0.6.2 | lib/sanford.rb |
sanford-0.6.1 | lib/sanford.rb |