Module: Tetra::ProjectIniter
Overview
takes care of initializing a tetra project
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- TEMPLATE_PATH =
path of the project template files
File.join(__dir__, "..", "template")
Class Method Summary collapse
-
.included(base) ⇒ Object
includers get class methods defined in ClassMethods.
Instance Method Summary collapse
-
#commit_source_archive(file, message) ⇒ Object
adds a source archive at the project, both in original and unpacked forms.
-
#template_files(include_bundled_software) ⇒ Object
returns a hash that maps filenames that should be copied from TEMPLATE_PATH to the value directory.
Methods included from Logging
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
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/tetra/project_initer.rb', line 79 def commit_source_archive(file, ) 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 /\.zip$/.match?(file) Tetra::Unzip.new else Tetra::Tar.new end # Glob cleaning is safer than rm_rf with wildcards in shell Dir.glob(File.join("src", "*")).each { |f| FileUtils.rm_rf(f) } unarchiver.decompress(file, "src") commit_sources(, 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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tetra/project_initer.rb', line 60 def template_files(include_bundled_software) result = { "kit" => ".", "packages" => ".", "src" => "." } if include_bundled_software # Use 'base:' argument to avoid unsafe Dir.chdir # This globs files inside TEMPLATE_PATH without changing global state Dir.glob(File.join("bundled", "*"), base: TEMPLATE_PATH).each do |file| result[file] = "kit" end end result end |