setup 5.0.1 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/Assembly +46 -0
  2. data/Gemfile +2 -0
  3. data/{HISTORY → HISTORY.rdoc} +21 -0
  4. data/LICENSE.txt +28 -0
  5. data/{COPYING → NOTICE.txt} +11 -4
  6. data/README.rdoc +28 -40
  7. data/SetupReceipt +405 -0
  8. data/bin/setup.rb +1302 -3
  9. data/lib/setup.rb +4 -3
  10. data/lib/setup/base.rb +1 -1
  11. data/lib/setup/command.rb +41 -18
  12. data/lib/setup/configuration.rb +21 -16
  13. data/lib/setup/constants.rb +4 -1
  14. data/lib/setup/documentor.rb +47 -41
  15. data/lib/setup/installer.rb +2 -2
  16. data/lib/setup/project.rb +85 -35
  17. data/lib/setup/session.rb +44 -31
  18. data/lib/setup/version.rb +4 -0
  19. data/meta/authors +4 -2
  20. data/meta/copyrights +4 -0
  21. data/meta/description +1 -1
  22. data/meta/organization +1 -0
  23. data/meta/repositories +2 -0
  24. data/meta/requirements +4 -0
  25. data/meta/resources +6 -0
  26. data/meta/version +1 -1
  27. data/script/{bstrap → bootstrap} +0 -0
  28. data/script/bundle +23 -6
  29. data/script/setup +122 -164
  30. data/test/features/{make.feature → compile.feature} +5 -6
  31. data/test/features/config.feature +1 -1
  32. data/test/features/install.feature +5 -5
  33. data/test/features/step_definitions/compile_steps.rb +26 -0
  34. data/test/features/step_definitions/config_steps.rb +2 -2
  35. data/test/features/step_definitions/install_steps.rb +11 -5
  36. data/test/features/uninstall.feature +1 -1
  37. data/test/fixtures/faux-project/.setup/metaconfig.rb +6 -0
  38. metadata +99 -60
  39. data/MANIFEST +0 -65
  40. data/Syckfile +0 -77
  41. data/meta/collection +0 -1
  42. data/meta/contact +0 -1
  43. data/meta/homepage +0 -1
  44. data/meta/released +0 -1
  45. data/meta/repository +0 -1
  46. data/meta/ruby +0 -3
  47. data/test/features/document.feature +0 -2
  48. data/test/features/step_definitions/setup_steps.rb +0 -30
@@ -1,3 +1,4 @@
1
- module Setup
2
- VERSION = '5.0.1'
3
- end
1
+ require 'yaml'
2
+ require 'setup/version'
3
+ require 'setup/session'
4
+
@@ -44,7 +44,7 @@ module Setup
44
44
  # according to the name of the class. For instance to
45
45
  # augment the behavior of the Installer, use:
46
46
  #
47
- # script/.setup/installer.rb
47
+ # .setup/installer.rb
48
48
  #
49
49
  def initialize_hooks
50
50
  file = META_EXTENSION_DIR + "/#{self.class.name.downcase}.rb"
@@ -32,16 +32,15 @@ module Setup
32
32
  order << name
33
33
  end
34
34
 
35
- task 'all' , "config, setup, test, install"
36
- task 'config' , "saves your configuration"
37
35
  task 'show' , "show current configuration"
38
- task 'make' , "compile ruby extentions"
36
+ task 'all' , "config, compile and install"
37
+ task 'config' , "save/customize configuration settings"
38
+ task 'compile' , "compile ruby extentions"
39
39
  task 'test' , "run test suite"
40
- task 'doc' , "generate ri documentation"
41
40
  task 'install' , "install project files"
42
- task 'uninstall', "uninstall previously installed files"
43
41
  task 'clean' , "does `make clean' for each extention"
44
42
  task 'distclean', "does `make distclean' for each extention"
43
+ task 'uninstall', "uninstall previously installed files"
45
44
 
46
45
  # Run command.
47
46
 
@@ -54,6 +53,8 @@ module Setup
54
53
  task = ARGV.find{ |a| a !~ /^[-]/ }
55
54
  task = 'all' unless task
56
55
 
56
+ #task = 'doc' if task == 'document'
57
+
57
58
  unless task_names.include?(task)
58
59
  $stderr.puts "Not a valid task -- #{task}"
59
60
  exit 1
@@ -66,12 +67,14 @@ module Setup
66
67
 
67
68
  optparse_header(parser, options)
68
69
  case task
69
- when 'all'
70
- optparse_all(parser, options)
71
70
  when 'config'
72
71
  optparse_config(parser, options)
72
+ when 'compile'
73
+ optparse_compile(parser, options)
73
74
  when 'install'
74
75
  optparse_install(parser, options)
76
+ when 'all'
77
+ optparse_all(parser, options)
75
78
  end
76
79
  optparse_common(parser, options)
77
80
 
@@ -87,6 +90,12 @@ module Setup
87
90
 
88
91
  print_header
89
92
 
93
+ begin
94
+ $stderr.puts "(#{RUBY_ENGINE} #{RUBY_VERSION} #{RUBY_PLATFORM})"
95
+ rescue
96
+ $stderr.puts "(#{RUBY_VERSION} #{RUBY_PLATFORM})"
97
+ end
98
+
90
99
  begin
91
100
  session.__send__(task)
92
101
  rescue Error => err
@@ -120,14 +129,12 @@ module Setup
120
129
 
121
130
  def optparse_all(parser, options)
122
131
  optparse_config(parser, options)
123
- #optparse_install(parser, options)
124
- #parser.on("-t", "--[no-]test", "run tests") do |val|
132
+ optparse_compile(parser, options)
133
+ optparse_install(parser, options) # TODO: why was this remarked out ?
134
+ #parser.on("-t", "--[no-]test", "run tests (default is --no-test)") do |val|
125
135
  # configuration.no_test = val
126
136
  #end
127
- #parser.on("--[no-]ri", "generate ri documentation") do |val|
128
- # configuration.no_doc = val
129
- #end
130
- #parser.on("--[no-]doc", "do not install documentation") do |val|
137
+ #parser.on("--[no-]doc", "generate ri/yri documentation (default is --doc)") do |val|
131
138
  # configuration.no_doc = val
132
139
  #end
133
140
  end
@@ -137,6 +144,9 @@ module Setup
137
144
  def optparse_config(parser, options)
138
145
  parser.separator ""
139
146
  parser.separator "Configuration options:"
147
+ #parser.on('--reset', 'reset configuration to default settings') do
148
+ # session.reset = true
149
+ #end
140
150
  configuration.options.each do |args|
141
151
  args = args.dup
142
152
  desc = args.pop
@@ -160,7 +170,8 @@ module Setup
160
170
  end
161
171
  end
162
172
  else
163
- opts = shortcut ? ["-#{shortcut}", "--#{optname} #{type.to_s.upcase}", desc] : ["--#{optname} #{type.to_s.upcase}", desc]
173
+ opts = shortcut ? ["-#{shortcut}", "--#{optname} #{type.to_s.upcase}", desc] :
174
+ ["--#{optname} #{type.to_s.upcase}", desc]
164
175
  parser.on(*opts) do |val|
165
176
  configuration.__send__("#{name}=", val)
166
177
  end
@@ -168,15 +179,27 @@ module Setup
168
179
  end
169
180
  end
170
181
 
182
+ #
183
+ def optparse_compile(parser, options)
184
+ end
185
+
171
186
  # Setup options for +install+ task.
172
187
 
173
188
  def optparse_install(parser, options)
174
- parser.separator ""
175
- parser.separator "Install options:"
176
- parser.on("--prefix PATH", "Installation prefix") do |val|
177
- #session.options[:install_prefix] = val
189
+ parser.separator ''
190
+ parser.separator 'Install options:'
191
+ # install prefix overrides target prefix when installing
192
+ parser.on('--prefix PATH', 'install to alternate root location') do |val|
178
193
  configuration.install_prefix = val
179
194
  end
195
+ # type can override config
196
+ parser.on('--type TYPE', "install location mode (site,std,home)") do |val|
197
+ configuration.type = val
198
+ end
199
+ # test can be override config
200
+ parser.on('-t', '--[no-]test', "run pre-installation tests") do |bool|
201
+ configuration.test = bool
202
+ end
180
203
  end
181
204
 
182
205
  # Setup options for +test+ task.
@@ -15,11 +15,11 @@ module Setup
15
15
  # Ruby System Configuration
16
16
  RBCONFIG = ::Config::CONFIG
17
17
 
18
- # Confgiuration file
19
- CONFIG_FILE = 'SetupConfig' # '.cache/setup/config'
18
+ ## Confgiuration file
19
+ #CONFIG_FILE = 'SetupConfig' # '.cache/setup/config'
20
20
 
21
21
  # Custom configuration file.
22
- META_CONFIG_FILE = META_EXTENSION_DIR + '/configuration.rb'
22
+ META_CONFIG_FILE = META_EXTENSION_DIR + '/metaconfig.rb'
23
23
 
24
24
  #
25
25
  def self.options
@@ -59,7 +59,8 @@ module Setup
59
59
  option :shebang , :pick, 'shebang line (#!) editing mode (all,ruby,never)'
60
60
 
61
61
  option :no_test, :t , :bool, 'run pre-installation tests'
62
- option :no_ri, :d , :bool, 'generate ri documentation'
62
+ # TODO: remove no_ri option in future version
63
+ #option :no_ri, :d , :bool, 'generate ri documentation (deprecated and ignored)'
63
64
  option :no_doc , :bool, 'install doc/ directory'
64
65
  option :no_ext , :bool, 'compile/install ruby extentions'
65
66
 
@@ -110,9 +111,10 @@ module Setup
110
111
  initialize_metaconfig
111
112
  initialize_defaults
112
113
  initialize_environment
113
- initialize_configfile
114
+ initialize_configfile unless values[:reset]
115
+
114
116
  values.each{ |k,v| __send__("#{k}=", v) }
115
- yeild(self) if block_given?
117
+ yield(self) if block_given?
116
118
  end
117
119
 
118
120
  #
@@ -130,7 +132,7 @@ module Setup
130
132
  self.type = 'site'
131
133
  self.no_ri = true
132
134
  self.no_test = true
133
- self.no_doc = false
135
+ self.no_doc = true
134
136
  self.no_ext = false
135
137
  #@rbdir = siterubyver #'$siterubyver'
136
138
  #@sodir = siterubyverarch #'$siterubyverarch'
@@ -147,7 +149,7 @@ module Setup
147
149
 
148
150
  # Load configuration.
149
151
  def initialize_configfile
150
- if File.exist?(CONFIG_FILE)
152
+ if exist?
151
153
  erb = ERB.new(File.read(CONFIG_FILE))
152
154
  txt = erb.result(binding)
153
155
  dat = YAML.load(txt)
@@ -181,6 +183,8 @@ module Setup
181
183
  # end
182
184
  #end
183
185
 
186
+ attr_accessor :reset
187
+
184
188
  # # B A S E D I R E C T O R I E S # #
185
189
 
186
190
  #
@@ -266,13 +270,12 @@ module Setup
266
270
  end
267
271
  end
268
272
 
269
- #
273
+ # Alias for `#type`.
270
274
  alias_method :installdirs, :type
271
275
 
272
- #
276
+ # Alias for `#type=`.
273
277
  alias_method :installdirs=, :type=
274
278
 
275
-
276
279
  #
277
280
  alias_method :install_prefix, :root
278
281
 
@@ -529,16 +532,18 @@ module Setup
529
532
  @no_doc = boolean(val)
530
533
  end
531
534
 
532
- #
535
+
536
+ # @deprecated Will be remove in future version. Currently ignored.
533
537
  def no_ri
534
538
  @no_ri
535
539
  end
536
540
 
537
- #
541
+ # @deprecated Will be remove in future version. Currently ignored.
538
542
  def no_ri=(val)
539
543
  @no_ri = boolean(val)
540
544
  end
541
545
 
546
+
542
547
  #def rdoc = 'no'
543
548
  #def rdoctemplate = nil
544
549
  #def testrunner = 'auto' # needed?
@@ -554,9 +559,9 @@ module Setup
554
559
  end
555
560
 
556
561
  # Generate ri documentation?
557
- def ri?
558
- !no_ri
559
- end
562
+ #def ri?
563
+ # !no_ri
564
+ #end
560
565
 
561
566
  # Install doc directory?
562
567
  def doc?
@@ -7,6 +7,9 @@ module Setup
7
7
  FILETYPES = %w( bin lib ext data etc man doc )
8
8
 
9
9
  #
10
- INSTALL_RECORD = 'InstalledFiles' #'.cache/setup/installedfiles'
10
+ INSTALL_RECORD = 'SetupReceipt'
11
+
12
+ #
13
+ CONFIG_FILE = 'SetupConfig'
11
14
 
12
15
  end
@@ -2,57 +2,68 @@ require 'setup/base'
2
2
 
3
3
  module Setup
4
4
 
5
+ # As of v0.5.1 Setup.rb no longer support the document phase at all. The
6
+ # document phase would generate *ri* documentation for a project, adding in
7
+ # with the rest of ri documentation. After careful consideration, it has
8
+ # become clear that it is better for documentation to be left up to dedicated
9
+ # tools. For example, you could easily document your Ruby install site
10
+ # location yourself with
11
+ #
12
+ # $ rdoc --ri-site /usr/local/lib/site_ruby
13
+ #
14
+ # Using of course, whichever path is appropriate to your system.
15
+ #
16
+ # This descision also allows setup.rb to be less Ruby-specific, and useful
17
+ # as a more general install tool.
18
+ #
19
+ # @deprecated Setup.rb no longer generate ri documentation, ever.
5
20
  #
6
21
  class Documentor < Base
7
22
 
8
23
  #
9
24
  def document
10
25
  return if config.no_doc
11
- exec_ri
12
26
 
13
- #if file = DOCSCRIPT
14
- # ruby(file)
15
- #else
16
- # exec_rdoc
17
- #end
27
+ exec_ri
28
+ exec_yri
18
29
  end
19
30
 
20
31
  # Generate ri documentation.
21
- #++
22
- # TODO: call rdoc programmatically.
23
- #--
32
+ #
33
+ # @todo Should we run rdoc programmatically instead of shelling out?
34
+ #
24
35
  def exec_ri
25
36
  case config.type #installdirs
26
- when 'std', 'ruby'
27
- #output = "--ri-system" # no longer supported?
28
- output = "--ri-site"
29
- when 'site'
30
- output = "--ri-site"
31
37
  when 'home'
32
38
  output = "--ri"
39
+ when 'site'
40
+ output = "--ri-site"
41
+ when 'std', 'ruby'
42
+ output = "--ri-site"
33
43
  else
34
44
  abort "bad config: should not be possible -- type=#{config.type}"
35
45
  end
36
46
 
37
- if File.exist?('.document')
38
- files = File.read('.document').split("\n")
39
- files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ }
40
- files.collect!{ |f| f.strip }
41
- #elsif File.exist?('meta/loadpath')
42
- else
43
- files = []
44
- files << 'lib' if File.directory?('lib')
45
- files << 'ext' if File.directory?('ext')
46
- end
47
-
48
47
  opt = []
49
48
  opt << "-U"
50
49
  opt << "-q" #if quiet?
51
50
  #opt << "-D" #if $DEBUG
52
51
  opt << output
53
- opt << files
54
52
 
55
- opt = opt.flatten
53
+ unless project.document
54
+ files = []
55
+ files << 'lib' if project.find('lib')
56
+ files << 'ext' if project.find('ext')
57
+ else
58
+ files = []
59
+ #files = File.read('.document').split("\n")
60
+ #files.reject!{ |l| l =~ /^\s*[#]/ || l !~ /\S/ }
61
+ #files.collect!{ |f| f.strip }
62
+ end
63
+
64
+ opt.concat(files)
65
+
66
+ opt.flatten!
56
67
 
57
68
  cmd = "rdoc " + opt.join(' ')
58
69
 
@@ -70,24 +81,20 @@ module Setup
70
81
  $stderr.puts "command was: '#{cmd}'"
71
82
  #$stderr.puts "proceeding with install..."
72
83
  end
73
-
74
- # Now in local directory
75
- #opt = []
76
- #opt << "-U"
77
- #opt << "--ri --op 'doc/ri'"
78
- #opt << files
79
- #opt = opt.flatten
80
- #::RDoc::RDoc.new.document(opt)
81
84
  end
82
85
  end
83
86
 
84
- # Generate rdocs.
85
87
  #
86
- # Needs <tt>meta/name</tt> or <tt>.meta/name</tt>.
88
+ # Generate YARD Ruby Index documention.
87
89
  #
88
- # NOTE: This is not being used. It's here in case we decide
89
- # to add this feature, though it is quite possible that
90
- # we may never do so.
90
+ def exec_yri
91
+
92
+ end
93
+
94
+ # Generate rdocs. Needs project <tt>name</tt>.
95
+ #
96
+ # @deprecated This is not being used. It's here in case we decide
97
+ # to add the feature back in the future.
91
98
  #
92
99
  def exec_rdoc
93
100
  main = Dir.glob("README{,.*}", File::FNM_CASEFOLD).first
@@ -146,4 +153,3 @@ module Setup
146
153
  end
147
154
 
148
155
  end
149
-
@@ -96,7 +96,7 @@ module Setup
96
96
  return unless config.doc?
97
97
  return unless directory?('doc')
98
98
  return unless project.name
99
- dir = File.join(config.docdir, "ruby-{project.name}")
99
+ dir = File.join(config.docdir, "ruby-#{project.name}")
100
100
  report_transfer('doc', dir)
101
101
  #io.puts "* doc -> #{dir}" unless quiet?
102
102
  files = files('doc')
@@ -136,7 +136,7 @@ module Setup
136
136
  File.extname(file) == ".#{dllext}"
137
137
  end
138
138
  if ents.empty? && !files.empty?
139
- raise Error, "ruby extention not compiled: 'setup.rb make' first"
139
+ raise Error, "ruby extention not compiled: 'setup.rb compile' first"
140
140
  end
141
141
  ents
142
142
  end
@@ -1,53 +1,83 @@
1
1
  module Setup
2
2
 
3
- # The Project class encapsulates information
4
- # about the project/package setup is effecting.
5
-
3
+ # The Project class encapsulates information about the project/package
4
+ # setup is handling.
5
+ #
6
+ # To inform Setup.rb of the project's name, version and
7
+ # load path --information it can use to provide additional
8
+ # features, create a file in you project's root directory
9
+ # called `.ruby`. This is a YAML file with at minimum the
10
+ # entries:
11
+ #
12
+ # ---
13
+ # name: foo
14
+ # version: 1.0.0
15
+ # load_path: [lib]
16
+ #
17
+ # As of v5.1.0, Setup.rb no longer recognizes the VERSION file
18
+ # or the `.setup/name`, `.setup/version` and `.setup/loadpath` files.
19
+ # The `.ruby` file better serves this purpose and is a more widely
20
+ # recognized standard.
21
+ #
6
22
  class Project
7
23
 
8
24
  # Match used to determine the root dir of a project.
9
- ROOT_MARKER = '{setup.rb,script/setup,meta/,MANIFEST,lib/}'
25
+ ROOT_MARKER = '{.ruby,setup.rb,.setup,lib/}'
10
26
 
11
- # TODO: locate project root via some marker
12
- def rootdir
13
- @rootdir ||= (
14
- root = Dir[File.join(Dir.pwd, ROOT_MARKER)].first
15
- if !root
16
- raise Error, "not a project directory"
17
- else
18
- Dir.pwd
27
+ #
28
+ def initialize
29
+ @dotruby_file = find('.ruby')
30
+
31
+ @dotruby = YAML.load_file(@dotruby_file) if @dotruby_file
32
+
33
+ @name = nil
34
+ @version = nil
35
+ @loadpath = ['lib']
36
+
37
+ if @dotruby
38
+ @name = @dotruby['name']
39
+ @version = @dotruby['version']
40
+ @loadpath = @dotruby['load_path']
41
+ else
42
+ if file = find('.setup/name')
43
+ @name = File.read(file).strip
19
44
  end
20
- )
45
+ if file = find('.setup/version')
46
+ @version = File.read(file).strip
47
+ end
48
+ if file = find('.setup/loadpath')
49
+ @loadpath = File.read(file).strip
50
+ end
51
+ end
21
52
  end
22
53
 
54
+ attr :dotruby
55
+
23
56
  # The name of the package, used to install docs in system doc/ruby-{name}/ location.
24
- # The information must be provided in a file called meta/package.
25
- def name
26
- @name = (
27
- if file = Dir["{script/setup,meta,.meta}/name"].first
28
- File.read(file).strip
29
- else
30
- nil
31
- end
32
- )
33
- end
57
+ attr :name
34
58
 
35
- # This is needed if a project has loadpaths other than the standard lib/.
36
- # Note the routine is designed to handle YAML arrays or line by line list.
37
- def loadpath
38
- @loadpath ||= (
39
- if file = Dir.glob('{script/setup,meta,.meta}/loadpath').first
40
- raw = File.read(file).strip.chomp(']')
41
- raw.split(/[\n,]/).map do |e|
42
- e.strip.sub(/^[\[-]\s*/,'')
43
- end
59
+ # Current version number of project.
60
+ attr :version
61
+
62
+ #
63
+ attr :loadpath
64
+
65
+ alias load_path loadpath
66
+
67
+ # Locate project root.
68
+ def rootdir
69
+ @rootdir ||= (
70
+ root = Dir.glob(File.join(Dir.pwd, ROOT_MARKER), File::FNM_CASEFOLD).first
71
+ if !root
72
+ raise Error, "not a project directory"
44
73
  else
45
- nil
74
+ Dir.pwd
46
75
  end
47
76
  )
48
77
  end
49
78
 
50
- #
79
+ # Setup.rb uses `ext/**/extconf.rb` as convention for the location of
80
+ # compiled scripts.
51
81
  def extconfs
52
82
  @extconfs ||= Dir['ext/**/extconf.rb']
53
83
  end
@@ -62,7 +92,27 @@ module Setup
62
92
  !extensions.empty?
63
93
  end
64
94
 
95
+ #
96
+ def yardopts
97
+ Dir.glob(File.join(rootdir, '.yardopts')).first
98
+ end
99
+
100
+ #
101
+ def document
102
+ Dir.glob(File.join(rootdir, '.document')).first
103
+ end
104
+
105
+ # Find a file relative to project's root directory.
106
+ def find(glob, flags=0)
107
+ case flags
108
+ when :casefold
109
+ flags = File::FNM_CASEFOLD
110
+ else
111
+ flags = flags.to_i
112
+ end
113
+ Dir.glob(File.join(rootdir, glob), flags).first
114
+ end
115
+
65
116
  end
66
117
 
67
118
  end
68
-