Class: Opsk::Package

Inherits:
Thor::Group
  • Object
show all
Includes:
Thorable, Thor::Actions
Defined in:
lib/opskeleton/package.rb

Instance Method Summary collapse

Methods included from Thorable

included

Instance Method Details

#artifactObject



13
14
15
# File 'lib/opskeleton/package.rb', line 13

def artifact
	"#{name}-#{meta.version}"
end

#artifact_pathObject



17
18
19
# File 'lib/opskeleton/package.rb', line 17

def artifact_path
	"pkg/#{name}-#{meta.version}"
end

#create_buildObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/opskeleton/package.rb', line 21

def create_build
	empty_directory(artifact_path)
  path = Dir.getwd
	directory path, artifact_path, :verbose => false
	empty_directory("#{artifact_path}/scripts")
	%w(lookup.rb run.sh).each  do |s|
	  template("templates/scripts/#{s}", "#{artifact_path}/scripts/#{s}")
	  chmod("#{artifact_path}/scripts/#{s}", 0755)
	end
	unless(File.exists?("#{artifact_path}/manifests/site.pp"))
	  template('templates/puppet/site.erb', "#{artifact_path}/manifests/site.pp")
	end
end

#create_pkgObject



35
36
37
# File 'lib/opskeleton/package.rb', line 35

def create_pkg
	empty_directory('pkg')
end

#metaObject



5
6
7
# File 'lib/opskeleton/package.rb', line 5

def meta 
	 OpenStruct.new(YAML.load_file('opsk.yml'))
end

#nameObject



9
10
11
# File 'lib/opskeleton/package.rb', line 9

def name 
 	File.basename(Dir.getwd)
end

#packageObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/opskeleton/package.rb', line 39

def package
	ignored = IO.readlines('.gitignore').map(&:chomp)
	ignored.delete('modules')
	excludes = ignored.map{|f| "'#{f}'"}.join(" --exclude=") << ' --exclude-backups --exclude-vcs --exclude=pkg'
	tar = "#{artifact}.tar.gz"
	input = artifact
	inside('pkg') do
	  run("tar --exclude=#{excludes} -czf #{tar} #{input} >> /dev/null" , :verbose => false) 
	end
end