Class: Cejo::Projects::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/cejo/projects/builder.rb

Overview

Build Projects

Constant Summary collapse

BUILD_FOLDER =
Pathname.new File.join(Dir.home, 'Builds')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local, utils, project) ⇒ Builder

Returns a new instance of Builder.



14
15
16
17
18
# File 'lib/cejo/projects/builder.rb', line 14

def initialize(local, utils, project)
  @local_folder = local
  @utils = utils
  @project = project
end

Instance Attribute Details

#cejo_configObject (readonly)

Returns the value of attribute cejo_config.



12
13
14
# File 'lib/cejo/projects/builder.rb', line 12

def cejo_config
  @cejo_config
end

#local_folderObject (readonly)

Returns the value of attribute local_folder.



12
13
14
# File 'lib/cejo/projects/builder.rb', line 12

def local_folder
  @local_folder
end

#projectObject (readonly)

Returns the value of attribute project.



12
13
14
# File 'lib/cejo/projects/builder.rb', line 12

def project
  @project
end

#utilsObject (readonly)

Returns the value of attribute utils.



12
13
14
# File 'lib/cejo/projects/builder.rb', line 12

def utils
  @utils
end

Instance Method Details

#apply_patchesObject

none, or exclusively these ones.



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cejo/projects/builder.rb', line 40

def apply_patches
  tasks = project.patch
  return if tasks == 'none'

  Dir.chdir(project.folder) do
    project.patches.children.each do |patch|
      next unless tasks.include? patch.basename.to_s

      puts "Patched: #{patch.to_path}" # all
      project.repository.apply patch.to_path
    end
  end
end

#checkout_tagObject



24
25
26
27
28
# File 'lib/cejo/projects/builder.rb', line 24

def checkout_tag
  return if project.tag.empty?

  project.repository.checkout project.tag
end

#cleaningObject



54
55
56
57
58
59
60
61
# File 'lib/cejo/projects/builder.rb', line 54

def cleaning
  project.repository.reset_hard
  project.repository.checkout project.main_branch

  Dir.chdir(project.folder) do
    project.purge.each { |command| system command }
  end
end

#grabObject



20
21
22
# File 'lib/cejo/projects/builder.rb', line 20

def grab
  Floss::Grab.new(utils, project.folder, project.url, project.to_s).run
end

#installObject



30
31
32
33
34
35
36
37
# File 'lib/cejo/projects/builder.rb', line 30

def install
  Dir.chdir(project.folder) do
    project.commands.each do |command|
      command.gsub!('{0}', local_folder.to_s)
      system command
    end
  end
end

#runObject



63
64
65
66
67
68
69
# File 'lib/cejo/projects/builder.rb', line 63

def run
  grab
  checkout_tag
  apply_patches
  install # TODO: raise Git::GitExecuteError
  cleaning
end