Class: MetaBuild::App

Inherits:
Object
  • Object
show all
Defined in:
lib/meta_build/app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ App

Returns a new instance of App.



29
30
31
32
33
34
35
36
37
38
39
40
# 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

Instance Attribute Details

#compressed_fileObject (readonly)

Returns the value of attribute compressed_file.



27
28
29
# File 'lib/meta_build/app.rb', line 27

def compressed_file
  @compressed_file
end

#create_dirObject (readonly)

Returns the value of attribute create_dir.



27
28
29
# File 'lib/meta_build/app.rb', line 27

def create_dir
  @create_dir
end

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/meta_build/app.rb', line 27

def name
  @name
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



27
28
29
# File 'lib/meta_build/app.rb', line 27

def output_dir
  @output_dir
end

#replace_filesObject (readonly)

Returns the value of attribute replace_files.



27
28
29
# File 'lib/meta_build/app.rb', line 27

def replace_files
  @replace_files
end

Instance Method Details

#extract_metadataObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/meta_build/app.rb', line 42

def 
  _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