Sha256: 436a46a1e769ff782e94086d14ebc66ee8af73be1edeb1ce14dd476f8ac80ab7

Contents?: true

Size: 1.5 KB

Versions: 23

Compression:

Stored size: 1.5 KB

Contents

module Hobo
  class << self
    attr_accessor :project_path

    def config_path
      File.join(ENV['HOME'], '.hobo')
    end

    def seed_cache_path
      File.join(config_path, 'seeds')
    end

    def project_path
      return @project_path unless @project_path.nil?
      return @project_path = Dir.pwd if File.exists? "Hobofile"

      dir = Dir.pwd.split('/').reverse
      min_length = Gem.win_platform? ? 1 : 0
      Hobo::Logging.logger.debug("paths.project: Searching backwards from #{Dir.pwd}")

      while dir.length > min_length
        test_dir = dir.reverse.join('/')
        Hobo::Logging.logger.debug("paths.project: Testing #{test_dir}")

        match = [
          File.exists?(File.join(test_dir, 'Hobofile')),
          File.exists?(File.join(test_dir, 'tools', 'hobo')),
          File.exists?(File.join(test_dir, 'tools', 'vagrant', 'Vagrantfile'))
        ] - [false]

        return @project_path = test_dir if match.length > 0

        dir.shift
      end
      return @project_path = nil
    end

    def project_bin_path
      return nil if !project_path
      File.join(project_path, 'bin')
    end

    def hobofile_path
      return nil if !project_path
      File.join(project_path, 'Hobofile')
    end

    def project_config_file
      return nil if !project_path
      File.join(project_path, 'tools', 'hobo', 'config.yaml')
    end

    def user_config_file
      File.join(config_path, 'config.yaml')
    end

    def user_hobofile_path
      File.join(config_path, 'Hobofile')
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.15 lib/hobo/paths.rb
hobo-inviqa-0.0.14 lib/hobo/paths.rb
hobo-inviqa-0.0.13 lib/hobo/paths.rb
hobo-inviqa-0.0.11 lib/hobo/paths.rb
hobo-inviqa-0.0.10 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc11 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc10 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc9 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc8 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc7 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc6 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc4 lib/hobo/paths.rb
hobo-inviqa-0.0.10.pre.rc2 lib/hobo/paths.rb
hobo-inviqa-0.0.9 lib/hobo/paths.rb
hobo-inviqa-0.0.9.pre.rc2 lib/hobo/paths.rb
hobo-inviqa-0.0.9.pre.rc1 lib/hobo/paths.rb
hobo-inviqa-0.0.9.pre.alpha lib/hobo/paths.rb
hobo-inviqa-0.0.8 lib/hobo/paths.rb
hobo-inviqa-0.0.7.pre.rc3 lib/hobo/paths.rb
hobo-inviqa-0.0.7.pre.rc2 lib/hobo/paths.rb