Class: IronWorkerNG::Code::Base
Constant Summary
collapse
- @@registered_types =
[]
- @@registered_features =
[]
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included, #merge_dir
included, #merge_file
#guess_name_for_path, #initialize_code
Constructor Details
#initialize(*args, &block) ⇒ Base
Returns a new instance of Base.
42
43
44
45
46
47
48
|
# File 'lib/iron_worker_ng/code/base.rb', line 42
def initialize(*args, &block)
@features = []
@base_dir = ''
@dest_dir = ''
initialize_code(*args, &block)
end
|
Instance Attribute Details
#base_dir ⇒ Object
Returns the value of attribute base_dir.
12
13
14
|
# File 'lib/iron_worker_ng/code/base.rb', line 12
def base_dir
@base_dir
end
|
#dest_dir ⇒ Object
Returns the value of attribute dest_dir.
13
14
15
|
# File 'lib/iron_worker_ng/code/base.rb', line 13
def dest_dir
@dest_dir
end
|
#features ⇒ Object
Returns the value of attribute features.
11
12
13
|
# File 'lib/iron_worker_ng/code/base.rb', line 11
def features
@features
end
|
Class Method Details
.register_feature(feature) ⇒ Object
31
32
33
34
35
|
# File 'lib/iron_worker_ng/code/base.rb', line 31
def self.register_feature(feature)
return if feature[:for_klass].to_s == 'IronWorkerNG::Code::Builder'
@@registered_features << feature
end
|
.register_type(type) ⇒ Object
21
22
23
|
# File 'lib/iron_worker_ng/code/base.rb', line 21
def self.register_type(type)
@@registered_types << type
end
|
.registered_features ⇒ Object
27
28
29
|
# File 'lib/iron_worker_ng/code/base.rb', line 27
def self.registered_features
@@registered_features
end
|
.registered_types ⇒ Object
17
18
19
|
# File 'lib/iron_worker_ng/code/base.rb', line 17
def self.registered_types
@@registered_types
end
|
Instance Method Details
#bundle(zip) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/iron_worker_ng/code/base.rb', line 90
def bundle(zip)
@features.each do |feature|
feature.bundle(zip)
end
unless self.class == IronWorkerNG::Code::Base
zip.get_output_stream(@dest_dir + '__runner__.sh') do |runner|
runner.write <<RUNNER
#!/bin/sh
# iron_worker_ng-#{IronWorkerNG.full_version}
root() {
while [ $# -gt 1 ]; do
if [ "$1" = "-d" ]; then
printf "%s" "$2"
break
fi
shift
done
}
cd "$(root "$@")"
#{run_code}
RUNNER
end
end
end
|
#create_zip ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/iron_worker_ng/code/base.rb', line 120
def create_zip
unless self.class == IronWorkerNG::Code::Base
unless @exec
IronCore::Logger.error 'IronWorkerNG', 'No exec specified'
raise IronCore::IronError.new('No exec specified')
end
if @name.nil?
@name = guess_name_for_path(@exec.path)
end
end
fixate
zip_name = Dir.tmpdir + '/' + Dir::Tmpname.make_tmpname("iron-worker-ng-", "code.zip")
IronCore::Logger.debug 'IronWorkerNG', "Creating code zip '#{zip_name}'"
if @remote_build_command
@dest_dir = '__build__/'
end
Zip::ZipFile.open(zip_name, Zip::ZipFile::CREATE) do |zip|
bundle(zip)
if @remote_build_command
IronCore::Logger.info 'IronWorkerNG', 'Creating builder'
builder = IronWorkerNG::Code::Builder.new
builder.remote_build_command = @remote_build_command
builder.gem('iron_worker_ng')
builder.fixate
builder.bundle(zip)
end
end
zip_name
end
|
#hash_string ⇒ Object
84
85
86
87
88
|
# File 'lib/iron_worker_ng/code/base.rb', line 84
def hash_string
fixate
Digest::MD5.hexdigest(@features.map { |f| f.hash_string }.join)
end
|
#name(name = nil) ⇒ Object
50
51
52
53
54
|
# File 'lib/iron_worker_ng/code/base.rb', line 50
def name(name = nil)
@name = name if name
@name
end
|
#name=(name) ⇒ Object
56
57
58
|
# File 'lib/iron_worker_ng/code/base.rb', line 56
def name=(name)
@name = name
end
|
#remote_build_command(remote_build_command = nil) ⇒ Object
60
61
62
63
64
|
# File 'lib/iron_worker_ng/code/base.rb', line 60
def remote_build_command(remote_build_command = nil)
@remote_build_command = remote_build_command if remote_build_command
@remote_build_command
end
|
#remote_build_command=(remote_build_command) ⇒ Object
66
67
68
|
# File 'lib/iron_worker_ng/code/base.rb', line 66
def remote_build_command=(remote_build_command)
@remote_build_command = remote_build_command
end
|
#run_code ⇒ Object
162
163
164
|
# File 'lib/iron_worker_ng/code/base.rb', line 162
def run_code
''
end
|
#runtime(*args) ⇒ Object
70
71
|
# File 'lib/iron_worker_ng/code/base.rb', line 70
def runtime(*args)
end
|
#runtime=(runtime) ⇒ Object
73
74
|
# File 'lib/iron_worker_ng/code/base.rb', line 73
def runtime=(runtime)
end
|