Sha256: 29754e276edb9f318dd02ea35dd4f20ada03959da92f54247a26c4733d54bc8a

Contents?: true

Size: 1.18 KB

Versions: 13

Compression:

Stored size: 1.18 KB

Contents

module Steep
  class Project
    attr_reader :targets
    attr_reader :steepfile_path
    attr_reader :base_dir

    def initialize(steepfile_path:, base_dir: nil)
      @targets = []
      @steepfile_path = steepfile_path
      @base_dir = if base_dir
        base_dir
      elsif steepfile_path
        steepfile_path.parent
      else
        raise ArgumentError, "Project#initialize(base_dir:): neither base_dir nor steepfile_path given"
      end

      if steepfile_path and !steepfile_path.absolute?
        raise ArgumentError, "Project#initialize(steepfile_path:): steepfile_path should be absolute path"
      end
    end

    def relative_path(path)
      path.relative_path_from(base_dir)
    rescue ArgumentError
      path
    end

    def absolute_path(path)
      (base_dir + path).cleanpath
    end

    def target_for_source_path(path)
      targets.find do |target|
        target.possible_source_file?(path)
      end
    end

    def targets_for_path(path)
      if target = target_for_source_path(path)
        target
      else
        ts = targets.select {|target| target.possible_signature_file?(path) }
        unless ts.empty?
          ts
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
steep-1.8.3 lib/steep/project.rb
steep-1.8.2 lib/steep/project.rb
steep-1.8.1 lib/steep/project.rb
steep-1.8.0 lib/steep/project.rb
steep-1.8.0.pre.2 lib/steep/project.rb
steep-1.8.0.pre.1 lib/steep/project.rb
steep-1.8.0.dev.2 lib/steep/project.rb
steep-1.8.0.dev.1 lib/steep/project.rb
steep-1.7.1 lib/steep/project.rb
steep-1.7.0 lib/steep/project.rb
steep-1.7.0.dev.3 lib/steep/project.rb
steep-1.7.0.dev.2 lib/steep/project.rb
steep-1.7.0.dev.1 lib/steep/project.rb