Class: Makit::Configuration::RakefileHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/configuration/rakefile_helper.rb

Overview

Helper for Rakefile generation

Class Method Summary collapse

Class Method Details

.generate(project) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/makit/configuration/rakefile_helper.rb', line 7

def self.generate(project)
  rakefile_content = []

  # Add header comment
  rakefile_content << "# Generated Rakefile for #{project.name} v#{project.version}"
  rakefile_content << "# Generated by Makit::Configuration::RakefileHelper"
  rakefile_content << ""

  # Add default task
  if project.steps.any?
    default_tasks = project.steps.map(&:name).join(",")
    rakefile_content << "desc 'Run all project steps'"
    rakefile_content << "task :default => [:#{default_tasks}]"
    rakefile_content << ""
  end

  # Add individual step tasks
  project.steps.each do |step|
    rakefile_content << "desc '#{step.description}'"
    rakefile_content << "task :#{step.name} do"
    step.commands.each do |command|
      rakefile_content << "  sh '#{command}'"
    end
    rakefile_content << "end"
    rakefile_content << ""
  end

  rakefile_content.join("\n")
end

.write(project, path) ⇒ Object



37
38
39
40
# File 'lib/makit/configuration/rakefile_helper.rb', line 37

def self.write(project, path)
  content = generate(project)
  File.write(path, content)
end