Rakefile in win32-autogui-0.4.3 vs Rakefile in win32-autogui-0.5.0

- old
+ new

@@ -1,39 +1,19 @@ # encoding: utf-8 -# bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must -# be listed as a development dependency in the gemspec - -require 'rubygems' +# Bundler is managing $LOAD_PATH, any gem needed by this Rakefile must be +# listed as a development dependency in the gemspec require 'bundler/setup' +require 'bundler/gem_tasks' -# TODO: remove this once issue corrected -# Bundler broken up to 1.0.7 on Windows -module Bundler - class GemHelper - def self.install_tasks(opts = nil) - dir = caller.find{|c| /Rakefile:/}[/^(.*?)\/Rakefile:/, 1] - self.new(dir, opts && opts[:name]).install - end - end +require 'rspec/core/rake_task' +desc "Run RSpec" +RSpec::Core::RakeTask.new do |spec| + spec.pattern = 'spec/**/*_spec.rb' + spec.rspec_opts = ['--color', '--format nested'] end -Bundler::GemHelper.install_tasks -def gemspec - @gemspec ||= begin - file = File.expand_path('../win32-autogui.gemspec', __FILE__) - eval(File.read(file), binding, file) - end -end - -require 'spec' -require 'spec/rake/spectask' -Spec::Rake::SpecTask.new(:spec) do |spec| - spec.libs << 'lib' << 'spec' - spec.spec_files = FileList['spec/**/*_spec.rb'] -end - require 'cucumber' require 'cucumber/rake/task' Cucumber::Rake::Task.new(:features) do |task| task.cucumber_opts = ["features"] end @@ -42,20 +22,22 @@ task :test => [:spec, :features] task :default => :test namespace :doc do + + doc_version = File.open(File.join(File.dirname(__FILE__), 'VERSION'), "r") { |f| f.read } project_root = File.expand_path(File.dirname(__FILE__)) doc_destination = File.join(project_root, 'rdoc') require 'yard' - require 'yard/rake/yardoc_task' YARD::Rake::YardocTask.new(:generate) do |yt| - yt.options = ['--output-dir', doc_destination - ] + - gemspec.rdoc_options - ['--line-numbers', '--inline-source'] + yt.options = ['--output-dir', doc_destination, + '--title', "Win32-AutoGUI #{doc_version} Documentation", + '--main', "README.markdown" + ] end desc "Remove generated documenation" task :clean do rm_r doc_destination if File.exists?(doc_destination) @@ -64,6 +46,35 @@ desc "List undocumented objects" task :undocumented do system('yard stats --list-undoc') end +end + +# put the gemfiles task in the :build dependency chain +task :build => [:gemfiles] + +desc "Generate .gemfiles via 'git ls-files'" +task :gemfiles do + files = `git ls-files` + + filename = File.join(File.dirname(__FILE__), '.gemfiles') + cached_files = nil + if File.exists?(filename) + puts ".gemfiles exists, reading..." + cached_files = File.open(filename, "rb") {|f| f.read} + end + + if cached_files && cached_files.match("\r\n") + puts ".gemfiles using DOS EOL" + files.gsub!(/\n/, "\r\n") + end + + if cached_files != files + puts ".gemfiles updating" + File.open(filename, 'wb') {|f| f.write(files)} + else + puts ".gemfiles update not required" + end + + raise "unable to process .gemfiles" unless files end