Class: Setup::Session
- Inherits:
-
Object
- Object
- Setup::Session
- Defined in:
- lib/setup/session.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Session options.
Instance Method Summary collapse
-
#all ⇒ Object
Run all tasks in sequence.
- #clean ⇒ Object
- #compile ⇒ Object (also: #make)
- #compile? ⇒ Boolean
- #compiler ⇒ Object
- #config ⇒ Object
- #configuration ⇒ Object
- #distclean ⇒ Object
- #force=(val) ⇒ Object
- #force? ⇒ Boolean
-
#initialize(options = {}) ⇒ Session
constructor
New Session.
- #install ⇒ Object
- #installer ⇒ Object
- #io ⇒ Object
- #io=(anyio) ⇒ Object
- #log_header(phase) ⇒ Object
- #project ⇒ Object
- #quiet=(val) ⇒ Object
- #quiet? ⇒ Boolean
- #show ⇒ Object
- #test ⇒ Object
- #tester ⇒ Object
- #trace=(val) ⇒ Object
- #trace? ⇒ Boolean
- #trial=(val) ⇒ Object (also: #dryrun=)
- #trial? ⇒ Boolean (also: #dryrun?)
- #uninstall ⇒ Object
-
#uninstaller ⇒ Object
def documentor @documentor ||= Documentor.new(project, configuration, options) end.
Constructor Details
#initialize(options = {}) ⇒ Session
New Session
20 21 22 23 |
# File 'lib/setup/session.rb', line 20 def initialize(={}) @options = self.io ||= StringIO.new # log instead ? end |
Instance Attribute Details
#options ⇒ Object (readonly)
Session options.
17 18 19 |
# File 'lib/setup/session.rb', line 17 def @options end |
Instance Method Details
#all ⇒ Object
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 |
#clean ⇒ Object
160 161 162 163 |
# File 'lib/setup/session.rb', line 160 def clean log_header('Clean') compiler.clean end |
#compile ⇒ Object 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
81 82 83 |
# File 'lib/setup/session.rb', line 81 def compile? configuration.compile? && project.compiles? end |
#compiler ⇒ Object
199 200 201 |
# File 'lib/setup/session.rb', line 199 def compiler @compiler ||= Compiler.new(project, configuration, ) end |
#config ⇒ Object
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 |
#configuration ⇒ Object
195 196 197 |
# File 'lib/setup/session.rb', line 195 def configuration @configuration ||= Configuration.new end |
#distclean ⇒ Object
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
73 |
# File 'lib/setup/session.rb', line 73 def force?; @options[:force]; end |
#install ⇒ Object
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 |
#installer ⇒ Object
203 204 205 |
# File 'lib/setup/session.rb', line 203 def installer @installer ||= Installer.new(project, configuration, ) end |
#io ⇒ Object
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 |
#project ⇒ Object
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
65 |
# File 'lib/setup/session.rb', line 65 def quiet?; @options[:quiet]; end |
#show ⇒ Object
183 184 185 186 |
# File 'lib/setup/session.rb', line 183 def show #configuration.show puts configuration end |
#test ⇒ Object
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 |
#tester ⇒ Object
207 208 209 |
# File 'lib/setup/session.rb', line 207 def tester @tester ||= Tester.new(project, configuration, ) end |
#trace=(val) ⇒ Object
50 51 52 |
# File 'lib/setup/session.rb', line 50 def trace=(val) @options[:trace] = val end |
#trace? ⇒ 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?
55 |
# File 'lib/setup/session.rb', line 55 def trial?; @options[:trial]; end |
#uninstall ⇒ Object
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 |
#uninstaller ⇒ Object
215 216 217 |
# File 'lib/setup/session.rb', line 215 def uninstaller @uninstaller ||= Uninstaller.new(project, configuration, ) end |