-
Notifications
You must be signed in to change notification settings - Fork 99
/
Rakefile
61 lines (55 loc) · 1.96 KB
/
Rakefile
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
require 'rake/testtask'
require 'bundler/gem_tasks'
require 'ci/reporter/rake/minitest'
require 'hammer_cli/i18n/find_task'
require_relative './lib/hammer_cli_foreman/version'
require_relative './lib/hammer_cli_foreman/i18n'
require_relative './lib/hammer_cli_foreman/task_helper'
Rake::TestTask.new do |t|
t.libs.push "lib"
t.test_files = Dir.glob('test/**/*_test.rb')
t.verbose = true
t.warning = ENV.key?('RUBY_WARNINGS')
end
HammerCLI::I18n::FindTask.define(HammerCLIForeman::I18n::LocaleDomain.new, HammerCLIForeman.version)
namespace :pkg do
desc 'Generate package source gem'
task :generate_source => :build
end
namespace :plugin do
desc 'Create a plugin draft interactively'
task :draft do |_t, args|
require 'highline/import'
require 'uri'
options = {}
options[:path] = ask('Directory to create the draft in: ') { |dir| dir.default = '../' }
options[:name] = ask('Plugin name (e.g. my_plugin): ', String) do |name|
name.validate = /\A[a-zA-Z]+([-_][a-zA-Z]+)*\Z/
name.responses[:not_valid] = 'Valid names are: my_plugin, my-plugin, MyPlugin'
end
options[:author] = ask("Plugin's author (e.g. John Doe): ", String) do |author|
author.validate = /\A[a-zA-Z]++(?: [a-zA-Z]++)*\Z/
author.responses[:not_valid] = 'Valid names are: John, John Doe, John Doe S'
end
options[:email] = ask("Plugin's author e-mail (e.g. [email protected]): ", String) do |email|
email.validate = URI::MailTo::EMAIL_REGEXP
email.responses[:not_valid] = 'Valid email is: [email protected]'
end
options[:name] = options[:name].downcase.tr('-', '_')
draft = HammerCLIForeman::TaskHelper::PluginDraft.new(
options[:name], options[:path], author: options[:author], email: options[:email]
)
draft.build
draft.fill do
mk_config
cp_license
mk_readme
mk_gemfile
mk_gemspec
mk_version
mk_root
mk_boilerplate
end
puts "Saved in #{draft.path}."
end
end