Class: Teapot::Build::Component

Inherits:
Object
  • Object
show all
Defined in:
lib/teapot/build/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root, name, environment) ⇒ Component

Returns a new instance of Component.



26
27
28
29
30
31
32
# File 'lib/teapot/build/component.rb', line 26

def initialize(root, name, environment)
	@root = root
	@name = name
	@environment = environment
		
	@parts = [@name]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



35
36
37
# File 'lib/teapot/build/component.rb', line 35

def name
  @name
end

#partsObject (readonly)

Returns the value of attribute parts.



36
37
38
# File 'lib/teapot/build/component.rb', line 36

def parts
  @parts
end

#rootObject (readonly)

Returns the value of attribute root.



34
35
36
# File 'lib/teapot/build/component.rb', line 34

def root
  @root
end

Instance Method Details

#add(path) ⇒ Object



38
39
40
# File 'lib/teapot/build/component.rb', line 38

def add(path)
	@parts << path
end

#destination_pathObject



46
47
48
# File 'lib/teapot/build/component.rb', line 46

def destination_path
	@environment[:build_prefix] + "source"
end

#prepare!Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/teapot/build/component.rb', line 50

def prepare!
	source_path = destination_path + @name
		
	if source_path.exist?
		source_path.rmtree
	end
		
	source_path.mkpath
		
	@parts.each do |path|
		full_path = @root + path

		FileUtils.cp_r(full_path.children, source_path.to_s)
	end
		
	return source_path
end

#variantObject



42
43
44
# File 'lib/teapot/build/component.rb', line 42

def variant
	@environment[:variant]
end