Class: SixCore::Nsis

Inherits:
Object
  • Object
show all
Defined in:
lib/sixcore/nsis.rb

Overview

Core Class for the Nullsoft Scriptable Install System

Constant Summary collapse

COMPONENT =
'SixCore::nsis'
@@log =
SixCore.log
@@config =
SixCore::read_config('nsis', 'sixcore/config')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template, output) ⇒ Nsis

template

Name of template to use

output

Name of output file to use



21
22
23
24
25
# File 'lib/sixcore/nsis.rb', line 21

def initialize(template, output)
  @template = template
  @output = output
  @@log.debug SixCore::prep_msg 'Initialize', :component => COMPONENT, :verbose => [template, output]
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



10
11
12
# File 'lib/sixcore/nsis.rb', line 10

def output
  @output
end

#templateObject (readonly)

Returns the value of attribute template.



10
11
12
# File 'lib/sixcore/nsis.rb', line 10

def template
  @template
end

Instance Method Details

#configObject



15
16
17
# File 'lib/sixcore/nsis.rb', line 15

def config
  @@config
end

#create_output(replace = []) ⇒ Object

Creates the NSIS Setup output file

replace

Array, Per Entry: [Search, Replace]



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sixcore/nsis.rb', line 29

def create_output(replace = [])
  @@log.debug SixCore::prep_msg 'Build', :component => COMPONENT, :verbose => replace

  # Read NSIS template file
  nsis = File.open(@template) do |file|
    file.read
  end

  # exchange regex for new strings
  @@log.debug SixCore::prep_msg 'Replacing regex...', :component => COMPONENT, :verbose => [@output, replace]
  nsis = SixCore::gsub_ar(nsis, replace) unless replace.empty?

  # write new nsis file
  @@log.debug SixCore::prep_msg 'Creating new nsis file...', :component => COMPONENT, :verbose => @output
  File.open(@output, 'w') do |file| file.write nsis end

  # compile new nsis file
  @@log.debug SixCore::prep_msg 'Creating output exe...', :component => COMPONENT
  result = SixCore::proc_cmd("\"#{@@config.program}\" \"#{@output}\"")
  result.each do |line|
    if line =~ /Error \- aborting creation process/
      raise 'Failed creating NSIS Installer'
    end
  end

  @output
end