summaryrefslogtreecommitdiff
path: root/Rakefile
diff options
context:
space:
mode:
Diffstat (limited to 'Rakefile')
-rw-r--r--Rakefile31
1 files changed, 15 insertions, 16 deletions
diff --git a/Rakefile b/Rakefile
index 3a207d5..576e54c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,17 +1,17 @@
-#require "bundler/gem_tasks"
+# require "bundler/gem_tasks"
-require "rubygems"
-require "pty"
-require "fileutils"
-require "rake/testtask"
+require 'rubygems'
+require 'pty'
+require 'fileutils'
+require 'rake/testtask'
##
## TESTING
##
Rake::TestTask.new do |t|
- t.pattern = "test/**/*_test.rb"
- t.libs << "test"
+ t.pattern = 'test/**/*_test.rb'
+ t.libs << 'test'
t.verbose = true
end
task default: :test
@@ -28,9 +28,7 @@ $gem_path = File.join($base_dir, 'pkg', "#{$spec.name}-#{$spec.version}.gem")
def run(cmd)
PTY.spawn(cmd) do |output, _input, _pid|
begin
- while line = output.gets do
- puts line
- end
+ output.each { |line| puts line }
rescue Errno::EIO
end
end
@@ -38,13 +36,14 @@ rescue PTY::ChildExited
end
def built_gem_path
- Dir[File.join($base_dir, "#{$spec.name}-*.gem")].sort_by{|f| File.mtime(f)}.last
+ Dir[File.join($base_dir, "#{$spec.name}-*.gem")]
+ .max_by { |f| File.mtime(f) }
end
desc "Build #{$spec.name}-#{$spec.version}.gem into the pkg directory"
task 'build' do
FileUtils.mkdir_p(File.join($base_dir, 'pkg'))
- FileUtils.rm($gem_path) if File.exists?($gem_path)
+ FileUtils.rm($gem_path) if File.exist?($gem_path)
run "gem build -V '#{$spec_path}'"
file_name = File.basename(built_gem_path)
FileUtils.mv(built_gem_path, 'pkg')
@@ -53,11 +52,11 @@ end
desc "Install #{$spec.name}-#{$spec.version}.gem into either system-wide or user gems"
task 'install' do
- if !File.exists?($gem_path)
+ if !File.exist?($gem_path)
puts("Could not file #{$gem_path}. Try running 'rake build'")
else
options = '--verbose --conservative --no-rdoc --no-ri'
- if ENV["USER"] == "root"
+ if ENV['USER'] == 'root'
run "gem install #{options} '#{$gem_path}'"
else
home_gem_path = Gem.path.grep(/home/).first
@@ -67,7 +66,7 @@ task 'install' do
if input =~ /[yY]/
run "gem install #{$gem_path} #{options} --install-dir '#{home_gem_path}' "
else
- puts "bailing out."
+ puts 'bailing out.'
end
end
end
@@ -75,7 +74,7 @@ end
desc "Uninstall #{$spec.name}-#{$spec.version}.gem from either system-wide or user gems"
task 'uninstall' do
- if ENV["USER"] == "root"
+ if ENV['USER'] == 'root'
puts "Removing #{$spec.name}-#{$spec.version}.gem from system-wide gems"
run "gem uninstall '#{$spec.name}' --version #{$spec.version} --verbose -x -I"
else