Sha256: 5af4a5f37c22ed41d5e834f182af37af35fee52f20775695528ab3aa16dcc9d2

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

module GoodData::Helpers
  def self.home_directory
    running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME']
  end

  def self.running_on_windows?
    RUBY_PLATFORM =~ /mswin32|mingw32/
  end

  def self.running_on_a_mac?
    RUBY_PLATFORM =~ /-darwin\d/
  end

  def self.error(msg)
    STDERR.puts(msg)
    exit 1
  end

  def self.find_goodfile(pwd, options={})
    root = Pathname(options[:root] || '/' )
    pwd = Pathname(pwd).expand_path
    begin
       gf = pwd + "Goodfile"
       if gf.exist?
         return gf
       end
       pwd = pwd.parent
    end until root == pwd
    fail "Goodfile not found in #{pwd.to_s} or any parent up to #{root.to_s}"
  end

  def self.hash_dfs(thing, &block)
    if !thing.is_a?(Hash) && !thing.is_a?(Array)
    elsif thing.is_a?(Array)
      thing.each do |child|
        hash_dfs(child, &block)
      end
    else
      thing.each do |key, val|
        yield(thing, key)
        hash_dfs(val, &block)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gooddata-0.6.0.pre9 lib/gooddata/helpers.rb
gooddata-0.6.0.pre8 lib/gooddata/helpers.rb
gooddata-0.6.0.pre7 lib/gooddata/helpers.rb