summaryrefslogtreecommitdiff
path: root/lib/bundler/templates/newgem/Rakefile.tt
blob: 172183d4b410d848f4e45721f5e5d107d7b0b52b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true

require "bundler/gem_tasks"
<% default_task_names = [config[:test_task]].compact -%>
<% case config[:test] -%>
<% when "minitest" -%>
require "minitest/test_task"

Minitest::TestTask.create

<% when "test-unit" -%>
require "rake/testtask"

Rake::TestTask.new(:test) do |t|
  t.libs << "test"
  t.libs << "lib"
  t.test_files = FileList["test/**/*_test.rb"]
end

<% when "rspec" -%>
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

<% end -%>
<% if config[:linter] == "rubocop" -%>
<% default_task_names << :rubocop -%>
require "rubocop/rake_task"

RuboCop::RakeTask.new

<% elsif config[:linter] == "standard" -%>
<% default_task_names << :standard -%>
require "standard/rake"

<% end -%>
<% if config[:ext] -%>
<% default_task_names.unshift(:compile) -%>
<% default_task_names.unshift(:clobber) unless config[:ext] == 'rust' -%>
<% if config[:ext] == 'rust' -%>
require "rb_sys/extensiontask"

task build: :compile

GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")

RbSys::ExtensionTask.new(<%= config[:name].inspect %>, GEMSPEC) do |ext|
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
<% else -%>
require "rake/extensiontask"

task build: :compile

GEMSPEC = Gem::Specification.load("<%= config[:underscored_name] %>.gemspec")

Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
  ext.lib_dir = "lib/<%= config[:namespaced_path] %>"
end
<% end -%>

<% end -%>
<% if default_task_names.size == 1 -%>
task default: <%= default_task_names.first.inspect %>
<% else -%>
task default: %i[<%= default_task_names.join(" ") %>]
<% end -%>