Class: Idlc::Workspace
- Inherits:
-
Object
show all
- Includes:
- Helpers
- Defined in:
- lib/iapi-idlc-sdk-core/workspace.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
debug, err, msg, stderr, stdout, system_command
Constructor Details
Returns a new instance of Workspace.
14
15
16
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 14
def initialize
@tmp_dir = Dir.mktmpdir('ws-temp')
end
|
Instance Attribute Details
#tmp_dir ⇒ Object
Returns the value of attribute tmp_dir.
12
13
14
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 12
def tmp_dir
@tmp_dir
end
|
Class Method Details
.zip_folder(src, out) ⇒ Object
6
7
8
9
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 6
def zip_folder(src, out)
zf = ZipFileGenerator.new(src, out)
zf.write
end
|
Instance Method Details
#add(path) ⇒ Object
40
41
42
43
44
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 40
def add(path)
parent_dir = path.split('/')[0..-2].join('/')
FileUtils.mkdir_p("#{@tmp_dir}/#{parent_dir}")
FileUtils.cp_r(path, "#{@tmp_dir}/#{path}")
end
|
#cleanup ⇒ Object
22
23
24
25
26
27
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 22
def cleanup
debug("keeping directory: #{@tmp_dir} for dubugging")
return if ENV['DEBUG']
FileUtils.rm_rf(@tmp_dir)
end
|
#empty? ⇒ Boolean
18
19
20
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 18
def empty?
!Dir.exist? @tmp_dir
end
|
#flatten(base_path, file_ext) ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/iapi-idlc-sdk-core/workspace.rb', line 29
def flatten(base_path, file_ext)
Dir["#{base_path}/**/*.#{file_ext}"].each do |file|
filename = file.tr('/', '-')
debug("copying #{file} to #{@tmp_dir}/#{filename} ...")
FileUtils.cp(file, "#{@tmp_dir}/#{filename}")
end
end
|