Class: DeployRubygem::Project

Inherits:
Object
  • Object
show all
Includes:
DeployRubygem, RSpecTesting
Defined in:
lib/deploy_rubygem/project.rb

Overview

Using Project to deploy and manage Project

Direct Known Subclasses

Cookbook, Rubygem

Constant Summary

Constants included from DeployRubygem

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RSpecTesting

#check_current_version, #help_rspec, #install_gem_via_git, #testing_chef, #testing_gem, #testing_inspec, #testing_project, #testing_workstation

Methods included from DeployRubygem

#bootstrap_chef_workstation, #chef_accept_cmd, #chef_env_cmd, deployer, exemple_cookbook, #install_chef_workstation, #no_option_txt, #rubygem_test, #unknown_option_txt

Constructor Details

#initialize(new_project_options) ⇒ Project

Returns a new instance of Project.



16
17
18
19
20
21
22
23
24
25
# File 'lib/deploy_rubygem/project.rb', line 16

def initialize(new_project_options)
  @project_options = new_project_options
  @cookbooks = project_options[:cookbooks]&.map do |cookbook_name, cookbook_options|
    new_cookbook_option = cookbook_options.dup
    new_cookbook_option[:project_name] = cookbook_name
    new_cookbook_option[:chefrepo_path] = chefrepo_path
    Cookbook.new(new_cookbook_option)
  end
  @compliance_profile = InspecTestor.new(project_options[:compliance_profile])
end

Instance Attribute Details

#compliance_profileObject (readonly)

Returns the value of attribute compliance_profile.



14
15
16
# File 'lib/deploy_rubygem/project.rb', line 14

def compliance_profile
  @compliance_profile
end

#cookbooksObject (readonly)

Returns the value of attribute cookbooks.



14
15
16
# File 'lib/deploy_rubygem/project.rb', line 14

def cookbooks
  @cookbooks
end

#project_optionsObject (readonly)

Returns the value of attribute project_options.



14
15
16
# File 'lib/deploy_rubygem/project.rb', line 14

def project_options
  @project_options
end

Instance Method Details

#binariesObject



31
32
33
# File 'lib/deploy_rubygem/project.rb', line 31

def binaries
  project_options[__method__]
end

#change_to_chefrepoObject



73
74
75
# File 'lib/deploy_rubygem/project.rb', line 73

def change_to_chefrepo
  change_to_directory(chefrepo_path, chefrepo_git)
end

#change_to_directory(git_path, git_url) ⇒ Object



63
64
65
66
67
# File 'lib/deploy_rubygem/project.rb', line 63

def change_to_directory(git_path, git_url)
  system("git clone #{git_url}") unless Dir.exist?(chefrepo_path)
  Dir.chdir(git_path)
  git_path
end

#change_to_project_folderObject



69
70
71
# File 'lib/deploy_rubygem/project.rb', line 69

def change_to_project_folder
  change_to_directory(path, git)
end

#chefrepo_gitObject



47
48
49
# File 'lib/deploy_rubygem/project.rb', line 47

def chefrepo_git
  project_options[__method__]
end

#chefrepo_pathObject



51
52
53
# File 'lib/deploy_rubygem/project.rb', line 51

def chefrepo_path
  project_options[__method__]
end

#dependenciesObject



35
36
37
# File 'lib/deploy_rubygem/project.rb', line 35

def dependencies
  project_options[__method__]
end

#deploy_cookbooksObject



55
56
57
# File 'lib/deploy_rubygem/project.rb', line 55

def deploy_cookbooks
  cookbooks.each(&:deploy)
end

#gitObject



43
44
45
# File 'lib/deploy_rubygem/project.rb', line 43

def git
  project_options[__method__]
end

#git_commitObject



83
84
85
86
87
# File 'lib/deploy_rubygem/project.rb', line 83

def git_commit
  system('git add .') || return
  system("git commit -m 'Self validated for version #{GVB.version}'") || return
  system('git push') || abort("Cannot push #{project_name} #{GVB.version}")
end

#pathObject



39
40
41
# File 'lib/deploy_rubygem/project.rb', line 39

def path
  project_options[__method__]
end

#project_nameObject



27
28
29
# File 'lib/deploy_rubygem/project.rb', line 27

def project_name
  project_options[__method__]
end

#release_cookbooksObject



59
60
61
# File 'lib/deploy_rubygem/project.rb', line 59

def release_cookbooks
  project_options[:cookbooks].each(&:release)
end

#test_complianceObject



77
78
79
80
81
# File 'lib/deploy_rubygem/project.rb', line 77

def test_compliance
  change_to_chefrepo
  compliance_profile.update
  compliance_profile.apply
end