Class: CemWinSpec::ModuleArchiveBuilder
- Inherits:
-
Object
- Object
- CemWinSpec::ModuleArchiveBuilder
- Includes:
- Logging
- Defined in:
- lib/cem_win_spec/module_archive_builder.rb
Constant Summary collapse
- FILE_EXCLUDELIST =
%w[ .git/**/* data/benchmarks/**/* dev/**/* spec/fixtures/modules/* pkg/**/* Gemfile.lock ].freeze
Constants included from Logging
Instance Attribute Summary collapse
-
#archive ⇒ Object
(also: #path)
readonly
Returns the value of attribute archive.
-
#excludelist ⇒ Object
readonly
Returns the value of attribute excludelist.
-
#module_dir ⇒ Object
readonly
Returns the value of attribute module_dir.
-
#tempdir ⇒ Object
readonly
Returns the value of attribute tempdir.
Instance Method Summary collapse
- #build(remove_when_complete: true) ⇒ Object
-
#initialize(module_dir = Dir.pwd, excludelist: FILE_EXCLUDELIST) ⇒ ModuleArchiveBuilder
constructor
A new instance of ModuleArchiveBuilder.
Methods included from Logging
#current_log_format, current_log_format, current_log_level, #current_log_level, included, log_setup!, #log_setup!, logger, #logger, new_log_formatter, #new_log_formatter, new_log_level, #new_log_level
Constructor Details
#initialize(module_dir = Dir.pwd, excludelist: FILE_EXCLUDELIST) ⇒ ModuleArchiveBuilder
Returns a new instance of ModuleArchiveBuilder.
22 23 24 25 26 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 22 def initialize(module_dir = Dir.pwd, excludelist: FILE_EXCLUDELIST) @module_dir = module_dir @module_name = File.basename(module_dir) @excludelist = excludelist end |
Instance Attribute Details
#archive ⇒ Object (readonly) Also known as: path
Returns the value of attribute archive.
20 21 22 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 20 def archive @archive end |
#excludelist ⇒ Object (readonly)
Returns the value of attribute excludelist.
20 21 22 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 20 def excludelist @excludelist end |
#module_dir ⇒ Object (readonly)
Returns the value of attribute module_dir.
20 21 22 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 20 def module_dir @module_dir end |
#tempdir ⇒ Object (readonly)
Returns the value of attribute tempdir.
20 21 22 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 20 def tempdir @tempdir end |
Instance Method Details
#build(remove_when_complete: true) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/cem_win_spec/module_archive_builder.rb', line 30 def build(remove_when_complete: true) create_tempdir copy_module_to_tempdir remove_unwanted_files create_archive if block_given? begin yield File.join(tempdir, archive) end end ensure FileUtils.rm_rf(tempdir) if remove_when_complete && tempdir && File.exist?(tempdir) end |