Class: IRPack::Specification

Inherits:
Object
  • Object
show all
Defined in:
lib/irpack/specification.rb

Defined Under Namespace

Classes: RuntimeOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Specification

Returns a new instance of Specification.

Yields:

  • (_self)

Yield Parameters:



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/irpack/specification.rb', line 124

def initialize
  @output_file = nil
  @entry_file  = nil
  @module_name = nil
  @files       = []
  @base_paths  = []
  @compress    = false
  @target      = :exe
  @embed_assemblies = true
  @embed_stdlibs    = false
  @runtime_options = RuntimeOptions.new
  yield self if block_given?
end

Instance Attribute Details

#base_pathsObject

Base paths stripped from files and entry_file.



35
36
37
# File 'lib/irpack/specification.rb', line 35

def base_paths
  @base_paths
end

#compressObject

True if compress embeded files (default is false).



39
40
41
# File 'lib/irpack/specification.rb', line 39

def compress
  @compress
end

#embed_assembliesObject

True if embed IronRuby assemblies (default is true).



41
42
43
# File 'lib/irpack/specification.rb', line 41

def embed_assemblies
  @embed_assemblies
end

#embed_stdlibsObject Also known as: complete

True if embed standard libraries (default is true).



43
44
45
# File 'lib/irpack/specification.rb', line 43

def embed_stdlibs
  @embed_stdlibs
end

#entry_fileObject

Path of entry script.



31
32
33
# File 'lib/irpack/specification.rb', line 31

def entry_file
  @entry_file
end

#filesObject

Array of files to embed, or Hash maps runtime paths to real files.



33
34
35
# File 'lib/irpack/specification.rb', line 33

def files
  @files
end

#module_nameObject

Namespace of entry point.



47
48
49
# File 'lib/irpack/specification.rb', line 47

def module_name
  @module_name
end

#output_fileObject

Generated exe file path (default is entry_file replaced extention by ‘.exe’).



29
30
31
# File 'lib/irpack/specification.rb', line 29

def output_file
  @output_file
end

#runtime_optionsObject (readonly)

RuntimeOptions passed to script engine.



49
50
51
# File 'lib/irpack/specification.rb', line 49

def runtime_options
  @runtime_options
end

#targetObject

Type of generated executable. :exe for console app, :winexe for window app (default is :exe).



37
38
39
# File 'lib/irpack/specification.rb', line 37

def target
  @target
end

Instance Method Details

#map_entryObject

Return entry file path at runtime.

Raises:

  • (ArgumentError)


139
140
141
142
143
# File 'lib/irpack/specification.rb', line 139

def map_entry
  raise ArgumentError, "No entry file specified" unless @entry_file
  base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }
  (strip_path(base_paths, @entry_file) || @entry_file).to_s
end

#map_filesObject

Map runtime file path to real files.



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/irpack/specification.rb', line 146

def map_files
  file_map = {}
  entry_file = Pathname.new(map_entry)
  entry_found = false
  case @files
  when Hash
    @files.each do |path, file|
      file_map[path.to_s] = File.expand_path(file.to_s)
      entry_found = true if path.to_s==entry_file.to_s
    end
  else
    base_paths = @base_paths.collect {|path| Pathname.new(path).expand_path }
    @files.each do |fn|
      next unless fn
      relpath = strip_path(base_paths, fn) || fn
      file_map[relpath.to_s] = File.expand_path(fn.to_s)
      entry_found = true if relpath==entry_file
    end
  end
  file_map[entry_file.to_s] = File.expand_path(@entry_file.to_s) unless entry_found
  file_map
end