Module: FIR::BuildCommon

Included in:
Util::ClassMethods
Defined in:
lib/fir/util/build_common.rb

Instance Method Summary collapse

Instance Method Details

#convert_hash_to_assignment_string(hash) ⇒ Object

convert { “a” => “1”, “b” => “2” } => “a=‘1’ b=‘2’”



61
62
63
# File 'lib/fir/util/build_common.rb', line 61

def convert_hash_to_assignment_string(hash)
  hash.collect { |k, v| "#{k}='#{v}'" }.join(' ')
end

#initialize_build_common_options(args, options) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fir/util/build_common.rb', line 6

def initialize_build_common_options(args, options)
  @build_dir   = initialize_build_dir(args)
  @output_path = initialize_output_path(options)
  @token       = options[:token] || current_token
  @changelog   = options[:changelog].to_s
  @short       = options[:short].to_s
  @proj        = options[:proj].to_s
end

#initialize_build_dir(args) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/fir/util/build_common.rb', line 15

def initialize_build_dir(args)
  if args.first.blank? || !File.exist?(args.first)
    Dir.pwd
  else
    File.absolute_path(args.shift.to_s) # pop the first param
  end
end

#initialize_output_path(options) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/fir/util/build_common.rb', line 23

def initialize_output_path(options)
  if options[:output].blank?
    output_path = "#{@build_dir}/fir_build"
    FileUtils.mkdir_p(output_path) unless File.exist?(output_path)
    output_path
  else
    File.absolute_path(options[:output].to_s)
  end
end

#logger_info_and_run_build_commandObject



40
41
42
43
44
45
46
47
# File 'lib/fir/util/build_common.rb', line 40

def logger_info_and_run_build_command
  puts @build_cmd if $DEBUG

  logger.info 'Building......'
  logger_info_dividing_line

  logger.info `#{@build_cmd}`
end

#publish_build_appObject



33
34
35
36
37
38
# File 'lib/fir/util/build_common.rb', line 33

def publish_build_app
  logger_info_blank_line
  publish @builded_app_path, short:     @short,
                             changelog: @changelog,
                             token:     @token
end

#split_assignment_array_to_hash(arr) ⇒ Object

split [‘a=1’, ‘b=2’] => { ‘a’ => ‘1’, ‘b’ => ‘2’ }



50
51
52
53
54
55
56
57
58
# File 'lib/fir/util/build_common.rb', line 50

def split_assignment_array_to_hash(arr)
  hash = {}
  arr.each do |assignment|
    k, v = assignment.split('=', 2).map(&:strip)
    hash[k] = v
  end

  hash
end