Sha256: 75476780ad97221f4a77a6dc877c3ee0f75ef14561f11ed88fb4e7bfacd1a6fd
Contents?: true
Size: 1.51 KB
Versions: 3
Compression:
Stored size: 1.51 KB
Contents
# encoding: UTF-8 require 'active_support/all' require 'pathname' module GoodData module Helpers class << self def home_directory running_on_windows? ? ENV['USERPROFILE'] : ENV['HOME'] end def running_on_windows? RUBY_PLATFORM =~ /mswin32|mingw32/ end def running_on_a_mac? RUBY_PLATFORM =~ /-darwin\d/ end def error(msg) STDERR.puts(msg) exit 1 end # FIXME: Windows incompatible def find_goodfile(pwd = `pwd`.strip!, options = {}) root = Pathname(options[:root] || '/') pwd = Pathname(pwd).expand_path loop do gf = pwd + 'Goodfile' return gf if gf.exist? pwd = pwd.parent break unless root == pwd end nil end def 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 # TODO: Implement without using ActiveSupport def sanitize_string(str, filter = /[^a-z_]/, replacement = '') str = ActiveSupport::Inflector.transliterate(str).downcase str.gsub(filter, replacement) end # TODO: Implement without using ActiveSupport def humanize(str) ActiveSupport::Inflector.humanize(str) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gooddata-0.6.4 | lib/gooddata/helpers/global_helpers.rb |
gooddata-0.6.3 | lib/gooddata/helpers.rb |
gooddata-0.6.2 | lib/gooddata/helpers.rb |