Sha256: 7ca534d5b1b3ee0e14e6b9d35bb52b50579d9d33765762138327796a3d3818e6

Contents?: true

Size: 969 Bytes

Versions: 5

Compression:

Stored size: 969 Bytes

Contents

module Scide

  # Global scide options (base path for all projects,
  # shared options).
  class Global
    
    # The path under which all projects reside by default.
    # (Can be overriden at the project level.)
    attr_reader :path

    # Global options shared by all projects.
    attr_reader :options
  
    # Builds global options.
    #
    # == Arguments
    # * <tt>contents</tt> - The global options hash.
    def initialize contents
      raise ArgumentError, 'global configuration must be a hash' unless contents.kind_of? Hash
      raise ArgumentError, 'global options must be a hash' unless contents[:options].nil? or contents[:options].kind_of?(Hash)

      @options = contents[:options].try(:dup) || {}

      # default to home directory
      @path = contents[:path].try(:to_s) || File.expand_path('~')
      # expand from home directory unless absolute
      @path = File.join File.expand_path('~'), @path unless @path.match /^\//
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
scide-0.0.12 lib/scide/global.rb
scide-0.0.11 lib/scide/global.rb
scide-0.0.10 lib/scide/global.rb
scide-0.0.9 lib/scide/global.rb
scide-0.0.8 lib/scide/global.rb