summaryrefslogtreecommitdiff
path: root/lib/bundler/templates
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2018-03-24 19:19:00 -0700
committerDavid Rodríguez <deivid.rodriguez@riseup.net>2019-10-19 20:27:43 +0200
commitf821c754ba7b4048cb37141992a32daee1cd58e7 (patch)
treef7f9c27b6ee77b1dccaf6b606f08e6aac425b7a9 /lib/bundler/templates
parentc9d16351b4e2a8a41ce9e3a812b7612970b25a78 (diff)
downloadbundler-f821c754ba7b4048cb37141992a32daee1cd58e7.tar.gz
[CLI::Gem] Add a --rubocop optionsegiddins/bundle-gem-rubocop-option
Diffstat (limited to 'lib/bundler/templates')
-rw-r--r--lib/bundler/templates/newgem/Gemfile.tt3
-rw-r--r--lib/bundler/templates/newgem/Rakefile.tt13
2 files changed, 13 insertions, 3 deletions
diff --git a/lib/bundler/templates/newgem/Gemfile.tt b/lib/bundler/templates/newgem/Gemfile.tt
index 83878ec7f8..7b0296068b 100644
--- a/lib/bundler/templates/newgem/Gemfile.tt
+++ b/lib/bundler/templates/newgem/Gemfile.tt
@@ -10,3 +10,6 @@ gem "rake-compiler"
<%- if config[:test] -%>
gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
<%- end -%>
+<%- if config[:rubocop] -%>
+gem "rubocop"
+<%- end -%>
diff --git a/lib/bundler/templates/newgem/Rakefile.tt b/lib/bundler/templates/newgem/Rakefile.tt
index 099da6f3ec..1262457c72 100644
--- a/lib/bundler/templates/newgem/Rakefile.tt
+++ b/lib/bundler/templates/newgem/Rakefile.tt
@@ -1,4 +1,5 @@
require "bundler/gem_tasks"
+<% default_task_names = [config[:test_task]] -%>
<% if config[:test] == "minitest" -%>
require "rake/testtask"
@@ -14,7 +15,15 @@ require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
<% end -%>
+<% if config[:rubocop] -%>
+<% default_task_names << :rubocop -%>
+require "rubocop/rake_task"
+
+RuboCop::RakeTask.new
+
+<% end -%>
<% if config[:ext] -%>
+<% default_task_names.unshift(:clobber, :compile) -%>
require "rake/extensiontask"
task :build => :compile
@@ -23,7 +32,5 @@ Rake::ExtensionTask.new("<%= config[:underscored_name] %>") do |ext|
ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
-task :default => [:clobber, :compile, :<%= config[:test_task] %>]
-<% else -%>
-task :default => :<%= config[:test_task] %>
<% end -%>
+task :default => <%= default_task_names.size == 1 ? default_task_names.first.inspect : default_task_names.inspect %>