Class: MetaBuild::Helper::AppHelper

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

Class Method Summary collapse

Class Method Details

.set_target_name(name = '', source_file) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/meta_build/helper/app_helper.rb', line 21

def set_target_name(name = '', source_file)
  name ||= ''

  if name.empty?
    name = source_file.split(File::SEPARATOR).last
    name.sub! /\.\w+\z/, '.json'
  elsif !name.end_with?('.json')
    name << '.json'
  end

  name
end

.validate_options(options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/meta_build/helper/app_helper.rb', line 7

def validate_options(options)
  if options[:compressed_file].to_s.empty?
    return "Parameter [-f, --file] is required."
  elsif !File.exist?(options[:compressed_file])
    return "File denoted by the path '#{options[:compressed_file]}' does not exist."
  end

  if options[:output_dir].to_s.empty?
    return "Parameter [-o, --output-dir] is required."
  elsif (!File.exist?(options[:output_dir])) && (options[:create_dir] != true)
    return "Directory #{options[:output_dir]} does not exist. You might want to call this feature with the parameter [-c, --create-dir]"
  end
end

.work_dirObject



34
35
36
# File 'lib/meta_build/helper/app_helper.rb', line 34

def work_dir
  File.join Dir.tmpdir, 'meta-build'
end