Module: Tetra::ProjectIniter

Includes:
Logging
Included in:
Project
Defined in:
lib/tetra/project_initer.rb

Overview

takes care of intiializing a tetra project

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

TEMPLATE_PATH =

path of the project template files

File.join(File.dirname(__FILE__), "..", "template")

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logging

#log

Class Method Details

.included(base) ⇒ Object

includers get class methods defined in ClassMethods



12
13
14
# File 'lib/tetra/project_initer.rb', line 12

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#commit_source_archive(file, message) ⇒ Object

adds a source archive at the project, both in original and unpacked forms



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/tetra/project_initer.rb', line 69

def commit_source_archive(file, message)
  from_directory do
    result_dir = File.join(packages_dir, name)
    FileUtils.mkdir_p(result_dir)

    result_path = File.join(result_dir, File.basename(file))
    FileUtils.cp(file, result_path)
    @git.commit_file(result_path, "Source archive added")

    unarchiver = if file =~ /\.zip$/
                   Tetra::Unzip.new
                 else
                   Tetra::Tar.new
                 end

    Dir.glob(File.join("src", "*")).each { |f| FileUtils.rm_rf(f) }
    unarchiver.decompress(file, "src")
    commit_sources(message, true)
  end
end

#template_files(include_bundled_software) ⇒ Object

returns a hash that maps filenames that should be copied from TEMPLATE_PATH to the value directory



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/tetra/project_initer.rb', line 50

def template_files(include_bundled_software)
  result = {
    "kit" => ".",
    "packages" => ".",
    "src" => "."
  }

  if include_bundled_software
    Dir.chdir(TEMPLATE_PATH) do
      Dir.glob(File.join("bundled", "*")).each do |file|
        result[file] = "kit"
      end
    end
  end

  result
end