Rakefile in trinidad_daemon_extension-0.3.1 vs Rakefile in trinidad_daemon_extension-0.4.0
- old
+ new
@@ -1,107 +1,22 @@
-require 'rubygems'
-require 'rake'
-require 'date'
-
-#############################################################################
-#
-# Helper functions
-#
-#############################################################################
-
-def name
- @name ||= Dir['*.gemspec'].first.split('.').first
+begin
+ require 'bundler/setup'
+rescue LoadError => e
+ require('rubygems') && retry
+ raise e
end
-def version
- line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
-end
-
-def gemspec_file
- "#{name}.gemspec"
-end
-
-def gem_file
- "#{name}-#{version}.gem"
-end
-
-#############################################################################
-#
-# Standard tasks
-#
-#############################################################################
-
task :default => :spec
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.rspec_opts = ['--color', "--format documentation"]
end
-desc "Generate RCov test coverage and open in your browser"
-task :coverage do
- require 'rcov'
- sh "rm -fr coverage"
- sh "rcov test/test_*.rb"
- sh "open coverage/index.html"
-end
+require 'bundler/gem_tasks'
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "#{name} #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
+desc "Clear out all built (pkg/* and *.gem) artifacts"
+task :clear do
+ rm Dir["*.gem"]
+ rm_r Dir["pkg/*"] if File.exist?("pkg")
end
-
-desc "Open an irb session preloaded with this library"
-task :console do
- sh "irb -rubygems -r ./lib/#{name}.rb"
-end
-
-#############################################################################
-#
-# Custom tasks (add your own tasks here)
-#
-#############################################################################
-
-
-
-#############################################################################
-#
-# Packaging tasks
-#
-#############################################################################
-
-task :release => :build do
- unless `git branch` =~ /^\* master$/
- puts "You must be on the master branch to release!"
- exit!
- end
- sh "git commit --allow-empty -a -m 'Release #{version}'"
- sh "git tag v#{version}"
- sh "git push origin master --tags"
- sh "gem push pkg/#{name}-#{version}.gem"
-end
-
-task :build => :validate do
- sh "mkdir -p pkg"
- sh "gem build #{gemspec_file}"
- sh "mv #{gem_file} pkg"
-end
-
-task :install => :build do
- sh "gem install pkg/#{name}-#{version}.gem"
-end
-
-task :validate do
- libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
- unless libfiles.empty?
- puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
- exit!
- end
- unless Dir['VERSION*'].empty?
- puts "A `VERSION` file at root level violates Gem best practices."
- exit!
- end
-end
+task :clean => :clear