Class: Setup::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/setup/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Session

New Session



20
21
22
23
# File 'lib/setup/session.rb', line 20

def initialize(options={})
  @options = options
  self.io ||= StringIO.new  # log instead ?
end

Instance Attribute Details

#optionsObject (readonly)

Session options.



17
18
19
# File 'lib/setup/session.rb', line 17

def options
  @options
end

Instance Method Details

#allObject

Run all tasks in sequence.

  • config

  • make

  • test (optional)

  • install



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/setup/session.rb', line 94

def all
  #if compile?
    config
    compile
  #end
  if configuration.test?
    ok = test
    exit 1 unless ok
  end
  install
  #if configuration.ri?
  #  document
  #end
end

#cleanObject



160
161
162
163
# File 'lib/setup/session.rb', line 160

def clean
  log_header('Clean')
  compiler.clean
end

#compileObject Also known as: make



125
126
127
128
129
130
131
132
# File 'lib/setup/session.rb', line 125

def compile
  if compile?
    log_header('Compile')
    compiler.configure
    #abort "must run 'setup config' first" unless configuration.exist?
    compiler.compile
  end
end

#compile?Boolean

Returns:

  • (Boolean)


81
82
83
# File 'lib/setup/session.rb', line 81

def compile?
  configuration.compile? && project.compiles?
end

#compilerObject



199
200
201
# File 'lib/setup/session.rb', line 199

def compiler
  @compiler ||= Compiler.new(project, configuration, options)
end

#configObject



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/setup/session.rb', line 110

def config
  log_header('Preconfig')
  #if reset?
  #  @configuration = Configuration.new(:reset=>true)
  #end
  if configuration.save_config
    io.print "#{CONFIG_FILE} was saved. " unless quiet?
  else
    io.print "#{CONFIG_FILE} is current. " unless quiet?
  end
  io.puts "Edit to customize configuration." unless quiet?
  puts configuration if trace? && !quiet?
end

#configurationObject



195
196
197
# File 'lib/setup/session.rb', line 195

def configuration
  @configuration ||= Configuration.new
end

#distcleanObject



166
167
168
169
# File 'lib/setup/session.rb', line 166

def distclean
  log_header('Distclean')
  compiler.distclean
end

#force=(val) ⇒ Object



76
77
78
# File 'lib/setup/session.rb', line 76

def force=(val)
  @options[:force] = val
end

#force?Boolean

Returns:

  • (Boolean)


73
# File 'lib/setup/session.rb', line 73

def force?; @options[:force]; end

#installObject



139
140
141
142
143
# File 'lib/setup/session.rb', line 139

def install
  #abort "must run 'setup config' first" unless configuration.exist?
  log_header('Install')
  installer.install
end

#installerObject



203
204
205
# File 'lib/setup/session.rb', line 203

def installer
  @installer ||= Installer.new(project, configuration, options)
end

#ioObject



37
38
39
# File 'lib/setup/session.rb', line 37

def io
  @options[:io]
end

#io=(anyio) ⇒ Object



42
43
44
# File 'lib/setup/session.rb', line 42

def io=(anyio)
  @options[:io] = anyio
end

#log_header(phase) ⇒ Object



222
223
224
225
226
227
228
229
230
231
232
# File 'lib/setup/session.rb', line 222

def log_header(phase)
  return if quiet?
  if trial?
    str = "#{phase.upcase} (trail run)"
  else
    str = "#{phase.upcase}"
  end
  line = "- " * 35
  line[0..str.size+3] = str
  io.puts("\n- - #{line}\n\n")
end

#projectObject



191
192
193
# File 'lib/setup/session.rb', line 191

def project
  @project ||= Project.new
end

#quiet=(val) ⇒ Object



68
69
70
# File 'lib/setup/session.rb', line 68

def quiet=(val)
  @options[:quiet] = val
end

#quiet?Boolean

Returns:

  • (Boolean)


65
# File 'lib/setup/session.rb', line 65

def quiet?; @options[:quiet]; end

#showObject



183
184
185
186
# File 'lib/setup/session.rb', line 183

def show
  #configuration.show
  puts configuration
end

#testObject



146
147
148
149
150
# File 'lib/setup/session.rb', line 146

def test
  return true unless tester.testable?
  log_header('Test')
  tester.test
end

#testerObject



207
208
209
# File 'lib/setup/session.rb', line 207

def tester
  @tester ||= Tester.new(project, configuration, options)
end

#trace=(val) ⇒ Object



50
51
52
# File 'lib/setup/session.rb', line 50

def trace=(val)
  @options[:trace] = val
end

#trace?Boolean

Returns:

  • (Boolean)


47
# File 'lib/setup/session.rb', line 47

def trace?; @options[:trace]; end

#trial=(val) ⇒ Object Also known as: dryrun=



59
60
61
# File 'lib/setup/session.rb', line 59

def trial=(val)
  @options[:trial] = val
end

#trial?Boolean Also known as: dryrun?

Returns:

  • (Boolean)


55
# File 'lib/setup/session.rb', line 55

def trial?; @options[:trial]; end

#uninstallObject



172
173
174
175
176
177
178
179
180
# File 'lib/setup/session.rb', line 172

def uninstall
  if !File.exist?(INSTALL_RECORD)
    io.puts "Nothing is installed."
    return
  end
  log_header('Uninstall')
  uninstaller.uninstall
  io.puts('Ok.')
end

#uninstallerObject

def documentor

@documentor ||= Documentor.new(project, configuration, options)

end



215
216
217
# File 'lib/setup/session.rb', line 215

def uninstaller
  @uninstaller ||= Uninstaller.new(project, configuration, options)
end