Sha256: 7c0c04390a7a8566bcde34c1c998c9ecf6d8c45879560b960856477d1ba58327

Contents?: true

Size: 875 Bytes

Versions: 14

Compression:

Stored size: 875 Bytes

Contents

module GlobalHelpers

  def check_disallowed(name)
api.tty "GLOBAL cdis"
    raise DisallowedName(name) if disallowed?(name)
  end

  def check_file_exists(file)
    graceful_error FileNotFound(file) unless File.exist?(file)
  end

  def grab_file(fname)
    File.read(fname)
  end

  def search_upward(file)
    value = nil
    return file if File.exist?(file)

    count = 1
    loop do
      front = "../" * count
      count += 1
      here = Pathname.new(front).expand_path.dirname.to_s
      break if here == "/"
      path = front + file
      value = path if File.exist?(path)
      break if value
    end
    ::STDERR.puts "Cannot find #{file.inspect} from #{Dir.pwd}" unless value
	  return value
  rescue
    ::STDERR.puts "Can't find #{file.inspect} from #{Dir.pwd}"
	  return nil
  end

  def cwd_root?
    File.dirname(File.expand_path(".")) == "/"
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
livetext-0.9.42 lib/livetext/global_helpers.rb
livetext-0.9.41 lib/livetext/global_helpers.rb
livetext-0.9.40 lib/livetext/global_helpers.rb
livetext-0.9.39 lib/livetext/global_helpers.rb
livetext-0.9.38 lib/livetext/global_helpers.rb
livetext-0.9.37 lib/livetext/global_helpers.rb
livetext-0.9.36 lib/livetext/global_helpers.rb
livetext-0.9.35 lib/livetext/global_helpers.rb
livetext-0.9.33 lib/livetext/global_helpers.rb
livetext-0.9.32 lib/livetext/global_helpers.rb
livetext-0.9.31 lib/livetext/global_helpers.rb
livetext-0.9.30 lib/livetext/global_helpers.rb
livetext-0.9.27 lib/livetext/global_helpers.rb
livetext-0.9.26 lib/livetext/global_helpers.rb