class MetaBuild::App
Attributes
compressed_file[R]
create_dir[R]
name[R]
output_dir[R]
replace_files[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/meta_build/app.rb, line 29 def initialize(options = {}) message = MetaBuild::Helper::AppHelper.validate_options options if message raise "[ERROR] #{message}" end @compressed_file = options[:compressed_file] @output_dir = options[:output_dir] @name = MetaBuild::Helper::AppHelper.set_target_name(options[:name], options[:compressed_file]) @replace_files = options[:replace_files] ||= false @create_dir = options[:create_dir] ||= false end
Public Instance Methods
extract_metadata()
click to toggle source
# File lib/meta_build/app.rb, line 42 def extract_metadata _configure_prerequisites hash = MetaBuild::Builder::MetaBuilder.build file: @compressed_file FileUtils.makedirs @output_dir unless File.exist? @output_dir target_file = File.join(@output_dir, @name) if File.exist?(target_file) && (!@replace_files) puts "[ERROR] The file #{target_file} already exist. You might want to call this feature with the parameter [-r, --replace-file]" exit 1 end File.open(target_file, 'w') { |io| io.write hash.to_json } FileUtils.remove_dir MetaBuild::Helper::AppHelper.work_dir, true end
Private Instance Methods
_configure_prerequisites()
click to toggle source
# File lib/meta_build/app.rb, line 61 def _configure_prerequisites _notify_create_dir _notify_truncate_dir end
_notify_create_dir()
click to toggle source
# File lib/meta_build/app.rb, line 66 def _notify_create_dir return unless @create_dir FileUtils.remove_dir @output_dir, true end
_notify_truncate_dir()
click to toggle source
# File lib/meta_build/app.rb, line 71 def _notify_truncate_dir return unless @replace_files FileUtils.remove Dir.glob("#{@output_dir}/**/*") end