Sha256: 438c675736d3e15ac684611d57b5d5b2d9eef7b028953545089c607f555e81d4
Contents?: true
Size: 876 Bytes
Versions: 3
Compression:
Stored size: 876 Bytes
Contents
module Quandl module ProjectRoot # Borrowed from https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/ruby_project.rb def self.root @project_root ||= determine_root end def self.determine_root find_first_parent_containing('lib') || '.' end def self.find_first_parent_containing(dir) ascend_until { |path| File.exist?(File.join(path, dir)) } end def self.ascend_until fs = File::SEPARATOR escaped_slash = "\\#{fs}" special = '_ESCAPED_SLASH_' project_path = File.expand_path('.') parts = project_path.gsub(escaped_slash, special).squeeze(fs).split(fs).map do |x| x.gsub(special, escaped_slash) end until parts.empty? path = parts.join(fs) path = fs if path == '' return path if yield(path) parts.pop end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quandl-config-1.0.0 | lib/quandl/config/project_root.rb |
quandl-config-0.1.0 | lib/quandl/config/project_root.rb |
quandl-config-0.0.4 | lib/quandl/project_root.rb |