Rakefile in revenc-0.1.3 vs Rakefile in revenc-0.2.1

- old
+ new

@@ -1,29 +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 +# 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' -require 'rubygems' -require 'bundler/setup' - -Bundler::GemHelper.install_tasks - -def gemspec - @gemspec ||= begin - file = File.expand_path('../revenc.gemspec', __FILE__) - eval(File.read(file), binding, file) - 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 -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 @@ -31,25 +21,25 @@ desc "Run specs and features" task :test => [:spec, :features] task :default => :test -namespace :doc do - project_root = File.expand_path(File.dirname(__FILE__)) - doc_destination = File.join(project_root, 'rdoc') +# put the gemfiles task in the :build dependency chain +task :build => [:gemfiles] - require 'yard' - require 'yard/rake/yardoc_task' +desc "Generate .gemfiles via 'git ls-files'" +task :gemfiles do + files = `git ls-files` - YARD::Rake::YardocTask.new(:generate) do |yt| - yt.options = ['--markup-provider', 'rdiscount', - '--output-dir', doc_destination - ] + - gemspec.rdoc_options - ['--line-numbers', '--inline-source'] - end + filename = File.join(File.dirname(__FILE__), '.gemfiles') + cached_files = File.exists?(filename) ? File.open(filename, "r") {|f| f.read} : nil - desc "Remove generated documenation" - task :clean do - rm_r doc_destination if File.exists?(doc_destination) + # maintain EOL + files.gsub!(/\n/, "\r\n") if cached_files && cached_files.match("\r\n") + + if cached_files != files + puts "Updating .gemfiles" + File.open(filename, 'wb') {|f| f.write(files)} end + raise "unable to process gemfiles" unless files end