Rakefile in rails_view-2.3.0 vs Rakefile in rails_view-3.0.0

- old
+ new

@@ -2,11 +2,11 @@ This.author = "Ara T. Howard" This.email = "ara.t.howard@gmail.com" This.homepage = "https://github.com/ahoward/#{ This.lib }" task :license do - open('LICENSE', 'w'){|fd| fd.puts "same as ruby's"} + open('LICENSE', 'w'){|fd| fd.puts "Ruby"} end task :default do puts((Rake::Task.tasks.map{|task| task.name.gsub(/::/,':')} - ['default']).sort) end @@ -91,54 +91,66 @@ executables = shiteless[Dir::glob("bin/*")].map{|exe| File.basename(exe)} #has_rdoc = true #File.exist?('doc') test_files = "test/#{ lib }.rb" if File.file?("test/#{ lib }.rb") summary = object.respond_to?(:summary) ? object.summary : "summary: #{ lib } kicks the ass" description = object.respond_to?(:description) ? object.description : "description: #{ lib } kicks the ass" - license = object.respond_to?(:license) ? object.license : "same as ruby's" + license = object.respond_to?(:license) ? object.license : "Ruby" if This.extensions.nil? This.extensions = [] extensions = This.extensions %w( Makefile configure extconf.rb ).each do |ext| extensions << ext if File.exists?(ext) end end extensions = [extensions].flatten.compact + if This.dependencies.nil? + dependencies = [] + else + case This.dependencies + when Hash + dependencies = This.dependencies.values + when Array + dependencies = This.dependencies + end + end + template = if test(?e, 'gemspec.erb') Template{ IO.read('gemspec.erb') } else Template { <<-__ - ## #{ lib }.gemspec + ## <%= lib %>.gemspec # Gem::Specification::new do |spec| - spec.name = #{ lib.inspect } - spec.version = #{ version.inspect } + spec.name = <%= lib.inspect %> + spec.version = <%= version.inspect %> spec.platform = Gem::Platform::RUBY - spec.summary = #{ lib.inspect } - spec.description = #{ description.inspect } - spec.license = #{ license.inspect } + spec.summary = <%= lib.inspect %> + spec.description = <%= description.inspect %> + spec.license = <%= license.inspect %> - spec.files =\n#{ files.sort.pretty_inspect } - spec.executables = #{ executables.inspect } + spec.files =\n<%= files.sort.pretty_inspect %> + spec.executables = <%= executables.inspect %> spec.require_path = "lib" - spec.test_files = #{ test_files.inspect } + spec.test_files = <%= test_files.inspect %> - ### spec.add_dependency 'lib', '>= version' - #### spec.add_dependency 'map' + <% dependencies.each do |lib_version| %> + spec.add_dependency(*<%= Array(lib_version).flatten.inspect %>) + <% end %> - spec.extensions.push(*#{ extensions.inspect }) + spec.extensions.push(*<%= extensions.inspect %>) - spec.rubyforge_project = #{ This.rubyforge_project.inspect } - spec.author = #{ This.author.inspect } - spec.email = #{ This.email.inspect } - spec.homepage = #{ This.homepage.inspect } + spec.rubyforge_project = <%= This.rubyforge_project.inspect %> + spec.author = <%= This.author.inspect %> + spec.email = <%= This.email.inspect %> + spec.homepage = <%= This.homepage.inspect %> end __ } end @@ -178,12 +190,12 @@ cmd = "ruby -e'STDOUT.sync=true; exec %(ruby -I ./lib #{ sample })'" samples << Util.indent(`#{ cmd } 2>&1`, 4) << "\n" end template = - if test(?e, 'readme.erb') - Template{ IO.read('readme.erb') } + if test(?e, 'README.erb') + Template{ IO.read('README.erb') } else Template { <<-__ NAME #{ lib } @@ -247,45 +259,52 @@ # cache a bunch of stuff about this rakefile/environment # This = OpenStruct.new - This.file = File.expand_path(__FILE__) - This.dir = File.dirname(This.file) + This.file = File.expand_path(__FILE__) + This.dir = File.dirname(This.file) This.pkgdir = File.join(This.dir, 'pkg') -# grok lib + This.lib = File.basename(Dir.pwd) + This._lib = "#{ This.dir }/lib/#{ This.lib }/_lib.rb" + +# load meta lib info # - lib = ENV['LIB'] - unless lib - lib = File.basename(Dir.pwd).sub(/[-].*$/, '') + a = Object.constants.dup + require This._lib + b = Object.constants.dup + added = b - a + const = added.first + + if added.size > 1 + STDERR.puts "WARNING: defined multiple constants #{ added.inspect } in #{ _lib }, using #{ const } !!!" end - This.lib = lib -# grok version + This.const = const + This.object = Object.const_get(This.const) + This.name = This.object.name + This.version = This.object.send(:version) + +# see if dependencies are export by the module # - version = ENV['VERSION'] - unless version - require "./lib/#{ This.lib }" - This.name = lib.capitalize - This.object = eval(This.name) - version = This.object.send(:version) + if This.object.respond_to?(:dependencies) + This.dependencies = This.object.dependencies end - This.version = version # we need to know the name of the lib an it's version # abort('no lib') unless This.lib abort('no version') unless This.version # discover full path to this ruby executable # - c = Config::CONFIG - bindir = c["bindir"] || c['BINDIR'] + c = RbConfig::CONFIG + bindir = c["bindir"] || c['BINDIR'] ruby_install_name = c['ruby_install_name'] || c['RUBY_INSTALL_NAME'] || 'ruby' - ruby_ext = c['EXEEXT'] || '' - ruby = File.join(bindir, (ruby_install_name + ruby_ext)) - This.ruby = ruby + ruby_ext = c['EXEEXT'] || '' + ruby = File.join(bindir, (ruby_install_name + ruby_ext)) + This.ruby = ruby # some utils # module Util def indent(s, n = 2)