Sha256: 193fd30d286d6eb5ced6a38d701df2eba45e41ed0b6ee7adfaa4bf99367f9f04

Contents?: true

Size: 1.58 KB

Versions: 10

Compression:

Stored size: 1.58 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
  
  unless defined?(Naether::Configuration)
    Naether::Configuration = Naether::Configurator.new
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
naether-0.12.2 lib/naether/configuration.rb
naether-0.12.2-java lib/naether/configuration.rb
naether-0.12.1-java lib/naether/configuration.rb
naether-0.12.1 lib/naether/configuration.rb
naether-0.12.0-java lib/naether/configuration.rb
naether-0.12.0 lib/naether/configuration.rb
naether-0.11.1-java lib/naether/configuration.rb
naether-0.11.1 lib/naether/configuration.rb
naether-0.11.0-java lib/naether/configuration.rb
naether-0.11.0 lib/naether/configuration.rb