Sha256: 8110170046307e4da0c6a38b6f940b2bfbf5e225fa36b329a9df748ed1cfcc5c

Contents?: true

Size: 1.76 KB

Versions: 28

Compression:

Stored size: 1.76 KB

Contents

module Naether
  
  #
  # Naether runtime configuration
  #
  class Configurator
    def initialize(data={})
      gem_dir = File.expand_path("#{File.dirname(__FILE__)}/../../")
      
      version = nil
      
      # Load VERSION file from gem to VERSION var
      if File.exists?( File.expand_path("#{File.dirname(__FILE__)}/../../VERSION") )
        version = IO.read(File.expand_path("#{File.dirname(__FILE__)}/../../VERSION")).strip
          
      # VERSION file not found in gem dir, assume in current path, e.g.running from checkout
      else
        version = IO.read(File.expand_path("VERSION")).strip
      end
      
      
      
      @data = {
        :version => version,
        :gem_dir =>     gem_dir,
        :naether_jar => File.join( gem_dir, "core-#{version}.jar"),
        :platform =>    ($platform || RUBY_PLATFORM[/java/] || 'ruby'),
        :version =>     version,
        :dependencies_yml => File.expand_path("#{File.dirname( __FILE__ )}/../../jar_dependencies.yml")
      }
      
      update!(data)
    end
  
    def update!(data)
      data.each do |key, value|
        self[key] = value
      end
    end
  
    def [](key)
      @data[key.to_sym]
    end
  
    def []=(key, value)
      if value.class == Hash
        @data[key.to_sym] = Config.new(value)
      else
        @data[key.to_sym] = value
      end
    end
  
    def method_missing(sym, *args)
      if sym.to_s =~ /(.+)=$/
        self[$1] = args.first
      else
        self[sym]
      end
    end
  end

  if RUBY_VERSION == '1.8.7'
    unless Naether.const_defined?('Configuration')
      Naether::Configuration = Naether::Configurator.new
    end
  else
    unless Naether.const_defined?('Configuration', false)
      Naether::Configuration = Naether::Configurator.new
    end
  end

end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
naether-0.13.4-java lib/naether/configuration.rb
naether-0.13.3-java lib/naether/configuration.rb
naether-0.13.3 lib/naether/configuration.rb
naether-0.13.2-java lib/naether/configuration.rb
naether-0.13.1 lib/naether/configuration.rb
naether-0.13.1-java lib/naether/configuration.rb
naether-0.13.0-java lib/naether/configuration.rb
naether-0.13.0 lib/naether/configuration.rb