Sha256: d21b2d0359f44cfa6b5ae5e994f5b25bfa1406566f41b3b005b7abb85d7d4f3a

Contents?: true

Size: 1.91 KB

Versions: 5

Compression:

Stored size: 1.91 KB

Contents

require "pathname"
require "command/runner"
require "take/project/file"
require "take/project/actionable"
require "take/project/target"
require "take/project/convert"
require "take/project/definition"
require "take/project/requirement"

module Take

  # Handles project information for a specific project.  Tends to
  # represent an entire directory.
  class Project

    # The name of the project.  This is normally guessed from the
    # directory name.
    #
    # @return [String]
    attr_accessor :name

    # Creates a new project with the block, and calls {#call}.
    # Returns the created project.  A name is not required.
    #
    # @param [String?] name the name of the project.  If it is not
    #   given, it is assumed from the directory name.
    # @return [Project]
    # @todo FIX
    def self.create(name = nil, path = nil, &block)
      project = new(name, path, &block)
      project.call
      project
    end

    # Initialize the project.
    def initialize(name = nil, path = nil, &block)
      @block   = block
      @name    = name
      @groups  = {}
      @files   = {}
      @targets = []
      if path
        @_path = Pathname.new(path)
      end
    end

    # Set the project name.
    def project(name)
      @name = name
    end

    # The path to the project.
    #
    # @return [Pathname]
    def path
      @_path ||= Pathname.new("/home/homer/projects/dash")
    end

    def call
      @definition = Definition.new(self)
      @definition.instance_exec(&@block)
      p @definition
      @definition
    end

    # Creates a Makefile syntax-based string of the project.
    #
    # @return [String]
    def to_makefile
      out = ""
      out << @targets.
        map { |target| target.to_makefile(self) }.join("\n\n")
      out
    end

    def file(name)
      index = File.normalize(name, path)
      @files[index] ||= File.new(index)
    end

    def env
      {
        cc: "gcc"
      }
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
take-0.0.15 lib/take/project.rb
take-0.0.14 lib/take/project.rb
take-0.0.13 lib/take/project.rb
take-0.0.12 lib/take/project.rb
take-0.0.11 lib/take/project.rb