script/setup in roll-1.1.0 vs script/setup in roll-1.2.0
- old
+ new
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
#
-# Setup.rb, 2010-02-07 08:33:15
+# Setup.rb, 2010-06-01 10:27:20
#
# This is a stand-alone bundle of the setup.rb application.
# You can place it in your projects script/ directory, or
# rename it to 'setup.rb' and place it in your project's
# root directory (just like old times).
@@ -27,11 +27,12 @@
end
end
module Setup
META_EXTENSION_DIR = '.setup'
FILETYPES = %w( bin lib ext data etc man doc )
- INSTALL_RECORD = 'SetupReceipt' #'.cache/setup/installedfiles'
+ INSTALL_RECORD = 'SetupReceipt'
+ CONFIG_FILE = 'SetupConfig'
end
module Setup
class Project
ROOT_MARKER = '{setup.rb,script/setup,meta/,MANIFEST,lib/}'
def rootdir
@@ -107,11 +108,10 @@
end
def compile?
configuration.compile? && project.compiles?
end
def all
- config
if compile?
make
end
if configuration.test?
ok = test
@@ -121,27 +121,22 @@
if configuration.ri?
document
end
end
def config
- log_header('Configure')
- if configuration.save_config
- io.puts "Configuration saved." unless quiet?
- else
- io.puts "Configuration current." unless quiet?
- end
+ log_header('Custom Configuration')
+ configuration.save_config
+ io.puts "Edit #{CONFIG_FILE} to customize configuration." unless quiet?
puts configuration if trace? && !quiet?
compiler.configure if compile? #compiler.compiles?
end
def make
- abort "must run 'setup config' first" unless configuration.exist?
log_header('Compile')
compiler.compile
end
alias_method :setup, :make
def install
- abort "must run 'setup config' first" unless configuration.exist?
log_header('Install')
installer.install
end
def test
return true unless tester.testable?
@@ -329,11 +324,10 @@
require 'yaml'
require 'shellwords'
module Setup
class Configuration
RBCONFIG = ::Config::CONFIG
- CONFIG_FILE = 'SetupConfig' # '.cache/setup/config'
META_CONFIG_FILE = META_EXTENSION_DIR + '/configuration.rb'
def self.options
@@options ||= []
end
def self.option(name, *args) #type, description)
@@ -391,13 +385,13 @@
end
def initialize(values={})
initialize_metaconfig
initialize_defaults
initialize_environment
- initialize_configfile
+ initialize_configfile unless values[:reset]
values.each{ |k,v| __send__("#{k}=", v) }
- yeild(self) if block_given?
+ yield(self) if block_given?
end
def initialize_metaconfig
if File.exist?(META_CONFIG_FILE)
script = File.read(META_CONFIG_FILE)
(class << self; self; end).class_eval(script)
@@ -405,22 +399,22 @@
end
def initialize_defaults
self.type = 'site'
self.no_ri = true
self.no_test = true
- self.no_doc = false
+ self.no_doc = true
self.no_ext = false
end
def initialize_environment
options.each do |name, *args|
if value = ENV["RUBYSETUP_#{name.to_s.upcase}"]
__send__("#{name}=", value)
end
end
end
def initialize_configfile
- if File.exist?(CONFIG_FILE)
+ if exist?
erb = ERB.new(File.read(CONFIG_FILE))
txt = erb.result(binding)
dat = YAML.load(txt)
dat.each do |k, v|
next if 'type' == k
@@ -434,10 +428,11 @@
if dat['installdirs']
self.installdirs = dat['installdirs']
end
end
end
+ attr_accessor :reset
def base_bindir
@base_bindir ||= subprefix('bindir')
end
def base_libdir
@base_libdir ||= subprefix('libdir')
@@ -922,11 +917,11 @@
end
def install_doc
return unless config.doc?
return unless directory?('doc')
return unless project.name
- dir = File.join(config.docdir, "ruby-{project.name}")
+ dir = File.join(config.docdir, "ruby-#{project.name}")
report_transfer('doc', dir)
files = files('doc')
install_files('doc', files, dir, 0644)
end
private
@@ -1285,10 +1280,11 @@
parser.on(*opts) do |val|
configuration.__send__("#{name}=", val)
end
end
else
- opts = shortcut ? ["-#{shortcut}", "--#{optname} #{type.to_s.upcase}", desc] : ["--#{optname} #{type.to_s.upcase}", desc]
+ opts = shortcut ? ["-#{shortcut}", "--#{optname} #{type.to_s.upcase}", desc] :
+ ["--#{optname} #{type.to_s.upcase}", desc]
parser.on(*opts) do |val|
configuration.__send__("#{name}=", val)
end
end
end