nugem 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +8 -6
- data/CHANGELOG.md +34 -0
- data/Gemfile +26 -0
- data/README.md +49 -27
- data/exe/nugem +3 -3
- data/lib/nugem/cli/cli_gem.rb +15 -15
- data/lib/nugem/cli/cli_jekyll.rb +38 -34
- data/lib/nugem/cli/cli_rails.rb +7 -7
- data/lib/nugem/cli.rb +65 -44
- data/lib/nugem/git.rb +62 -59
- data/lib/nugem/repository.rb +4 -3
- data/lib/nugem/version.rb +1 -1
- data/lib/nugem.rb +10 -23
- data/lib/util.rb +27 -0
- data/nugem.gemspec +33 -12
- data/spec/spec_helper.rb +1 -4
- data/templates/common/executable_scaffold/exe/%gem_name%.tt +2 -2
- data/templates/common/executable_scaffold/lib/%gem_name%/cli.rb.tt +17 -9
- data/templates/common/executable_scaffold/lib/%gem_name%/options.rb.tt +31 -0
- data/templates/common/gem_scaffold/%gem_name%.gemspec.tt +4 -4
- data/templates/common/gem_scaffold/.bundle/config +2 -0
- data/templates/common/gem_scaffold/.gitignore.tt +27 -0
- data/templates/common/gem_scaffold/.markdownlint.json +8 -0
- data/templates/common/gem_scaffold/.rspec +2 -0
- data/templates/common/gem_scaffold/.rubocop.yml.tt +78 -0
- data/templates/common/gem_scaffold/.shellcheckrc +5 -0
- data/templates/common/gem_scaffold/.vscode/%gem_name%.json.code-snippets.tt +19 -0
- data/templates/common/gem_scaffold/.vscode/extensions.json +22 -0
- data/templates/common/gem_scaffold/.vscode/launch.json +68 -0
- data/templates/common/gem_scaffold/.vscode/settings.json +5 -0
- data/templates/common/gem_scaffold/CHANGELOG.md.tt +4 -1
- data/templates/common/gem_scaffold/Gemfile.tt +16 -26
- data/templates/common/gem_scaffold/README.md.tt +53 -13
- data/templates/common/gem_scaffold/bin/attach +2 -1
- data/templates/common/gem_scaffold/bin/build +7 -0
- data/templates/common/gem_scaffold/bin/reset +4 -0
- data/templates/common/gem_scaffold/bin/setup.tt +6 -3
- data/templates/common/gem_scaffold/lib/%gem_name%.rb.tt +2 -0
- data/templates/common/gem_scaffold/test/test_helper.rb.tt +3 -3
- data/templates/jekyll/block_no_arg_scaffold/lib/%block_name%.rb.tt +1 -1
- data/templates/jekyll/block_scaffold/lib/%block_name%.rb.tt +32 -10
- data/templates/jekyll/common_scaffold/spec/spec_helper.rb +1 -1
- data/templates/jekyll/demo/demo/Gemfile.tt +6 -5
- data/templates/jekyll/demo/demo/_bin/debug +7 -16
- data/templates/jekyll/demo/demo/_layouts/default.html.tt +1 -1
- data/templates/jekyll/hooks_scaffold/lib/dumpers.rb +1 -1
- data/templates/jekyll/tag_no_arg_scaffold/lib/%tag_name%.rb.tt +1 -1
- data/templates/jekyll/tag_scaffold/lib/%tag_name%.rb.tt +38 -11
- data/templates/rails/engine_scaffold/app/assets/images/%gem_name%/.keep +0 -0
- data/templates/rails/engine_scaffold/app/assets/javascripts/%gem_name%/.keep +0 -0
- data/templates/rails/engine_scaffold/app/assets/stylesheets/%gem_name%/.keep +0 -0
- data/templates/rails/engine_scaffold/app/controllers/.keep +0 -0
- data/templates/rails/engine_scaffold/app/helpers/.keep +0 -0
- data/templates/rails/engine_scaffold/app/mailers/.keep +0 -0
- data/templates/rails/engine_scaffold/app/models/.keep +0 -0
- data/templates/rails/engine_scaffold/app/views/.keep +0 -0
- data/templates/rails/plugin_scaffold/.envrc +1 -0
- data/templates/rails/plugin_scaffold/.simplecov.tt +18 -0
- data/templates/rails/plugin_scaffold/.travis.yml +4 -0
- data/templates/rails/plugin_scaffold/test/dummy/.envrc +1 -0
- data/templates/rails/plugin_scaffold/test/dummy/app/assets/images/.keep +0 -0
- data/templates/rails/plugin_scaffold/test/dummy/app/controllers/concerns/.keep +0 -0
- data/templates/rails/plugin_scaffold/test/dummy/app/models/.keep +0 -0
- data/templates/rails/plugin_scaffold/test/dummy/app/models/concerns/.keep +0 -0
- data/templates/rails/plugin_scaffold/test/dummy/bin/setup +1 -1
- data/templates/rails/plugin_scaffold/test/dummy/lib/assets/.keep +0 -0
- data/templates/rails/plugin_scaffold/test/dummy/log/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/.envrc +1 -0
- data/templates/rails/rails_scaffold/test/dummy/app/assets/images/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/app/controllers/concerns/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/app/models/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/app/models/concerns/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/bin/setup +1 -1
- data/templates/rails/rails_scaffold/test/dummy/lib/assets/.keep +0 -0
- data/templates/rails/rails_scaffold/test/dummy/log/.keep +0 -0
- metadata +62 -7
data/lib/nugem/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'rugged'
|
3
|
-
require_relative '
|
3
|
+
require_relative 'git'
|
4
|
+
require_relative 'cli/cli_gem'
|
4
5
|
|
5
6
|
# Nugem::Cli is a Thor class that is invoked when a user runs a nugem executable.
|
6
7
|
# This file defines the common aspects of the Thor class.
|
@@ -8,32 +9,43 @@ require_relative '../nugem'
|
|
8
9
|
module Nugem
|
9
10
|
class Cli < Thor
|
10
11
|
include Thor::Actions
|
11
|
-
|
12
|
+
|
13
|
+
# These declarations make the class instance variable values available as an accessor,
|
14
|
+
# which is necessary to name template files that are named '%variable_name%.extension'.
|
15
|
+
# See https://www.rubydoc.info/gems/thor/Thor/Actions#directory-instance_method
|
16
|
+
attr_reader :block_name, :filter_name, :generator_name, :tag_name, :test_framework
|
17
|
+
|
18
|
+
package_name 'Nugem'
|
19
|
+
|
20
|
+
check_unknown_options!
|
21
|
+
|
22
|
+
class_option :out_dir, type: :string, default: 'generated',
|
23
|
+
desc: 'Output directory for the gem.', aliases: :o
|
12
24
|
|
13
25
|
class_option :executable, type: :boolean, default: false,
|
14
|
-
|
26
|
+
desc: 'Include an executable for the gem.', aliases: :e
|
15
27
|
|
16
28
|
class_option :host, type: :string, default: 'github',
|
17
|
-
|
29
|
+
enum: %w[bitbucket github], desc: 'Repository host.', aliases: :h
|
18
30
|
|
19
31
|
class_option :private, type: :boolean, default: false,
|
20
|
-
|
32
|
+
desc: 'Publish the gem on a private repository.'
|
21
33
|
|
22
34
|
class_option :quiet, type: :boolean, default: true,
|
23
|
-
|
35
|
+
desc: 'Suppress detailed messages.', group: :runtime, aliases: :q
|
24
36
|
|
25
37
|
class_option :todos, type: :boolean, default: true,
|
26
|
-
|
38
|
+
desc: 'Generate TODO: messages in generated code.', group: :runtime, aliases: :t
|
39
|
+
|
40
|
+
class_option :yes, type: :boolean, default: false,
|
41
|
+
desc: 'Answer yes to all questions.', aliases: :y
|
27
42
|
|
28
43
|
# Surround gem_name with percent symbols when using the property to name files
|
29
44
|
# within the template directory
|
30
45
|
# For example: "generated/%gem_name%"
|
31
46
|
attr_accessor :gem_name
|
32
47
|
|
33
|
-
|
34
|
-
require_relative 'cli/cli_jekyll'
|
35
|
-
require_relative 'cli/cli_rails'
|
36
|
-
|
48
|
+
# Return a non-zero status code on error. See https://github.com/rails/thor/issues/244
|
37
49
|
def self.exit_on_failure?
|
38
50
|
true
|
39
51
|
end
|
@@ -43,48 +55,57 @@ module Nugem
|
|
43
55
|
File.expand_path '../../templates', __dir__
|
44
56
|
end
|
45
57
|
|
58
|
+
def self.test_option(default_value)
|
59
|
+
method_option :test_framework, type: :string, default: default_value,
|
60
|
+
enum: %w[minitest rspec],
|
61
|
+
desc: "Use rspec or minitest for the test framework (default is #{default_value})."
|
62
|
+
end
|
63
|
+
|
46
64
|
def self.todo
|
47
65
|
'TODO: ' if @todos
|
48
66
|
end
|
49
67
|
|
50
|
-
|
51
|
-
|
52
|
-
def count_todos(filename)
|
53
|
-
filename_fq = "#{Nugem.dest_root gem_name}/#{filename}"
|
54
|
-
content = File.read filename_fq
|
55
|
-
content.scan('TODO').length
|
56
|
-
end
|
68
|
+
require_relative 'cli/cli_jekyll'
|
69
|
+
require_relative 'cli/cli_rails'
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
create_local_git_repository
|
64
|
-
FileUtils.rm_f 'Gemfile.lock'
|
65
|
-
# say "Running 'bundle install'", :green
|
66
|
-
# run 'bundle', abort_on_failure: false
|
67
|
-
say 'Creating remote repository', :green
|
68
|
-
create_remote_git_repository @repository \
|
69
|
-
if yes? "Do you want to create a repository on #{@repository.host.camel_case} named #{gem_name}? (y/N)"
|
71
|
+
no_tasks do # rubocop:disable Metrics/BlockLength
|
72
|
+
def count_todos(filename)
|
73
|
+
filename_fq = "#{Nugem.dest_root @out_dir, gem_name}/#{filename}"
|
74
|
+
content = File.read filename_fq
|
75
|
+
content.scan('TODO').length
|
70
76
|
end
|
71
|
-
say "The #{gem_name} gem was successfully created.", :green
|
72
|
-
report_todos gem_name
|
73
|
-
end
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
def initialize_repository(gem_name)
|
79
|
+
Dir.chdir Nugem.dest_root(@out_dir, gem_name) do
|
80
|
+
# puts set_color("Working in #{Dir.pwd}", :green)
|
81
|
+
run 'chmod +x bin/*'
|
82
|
+
run 'chmod +x exe/*' if @executable
|
83
|
+
create_local_git_repository
|
84
|
+
FileUtils.rm_f 'Gemfile.lock'
|
85
|
+
# puts set_color("Running 'bundle'", :green)
|
86
|
+
# run 'bundle', abort_on_failure: false
|
87
|
+
create_repo = @yes || yes?(set_color("Do you want to create a repository on #{@repository.host.camel_case} named #{gem_name}? (y/N)",
|
88
|
+
:green))
|
89
|
+
create_remote_git_repository @repository if create_repo
|
90
|
+
end
|
91
|
+
puts set_color("The #{gem_name} gem was successfully created.", :green)
|
92
|
+
report_todos gem_name
|
81
93
|
end
|
82
94
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
95
|
+
def report_todos(gem_name)
|
96
|
+
gemspec_todos = count_todos "#{gem_name}.gemspec"
|
97
|
+
readme_todos = count_todos 'README.md'
|
98
|
+
if readme_todos.zero? && gemspec_todos.zero?
|
99
|
+
puts set_color("There are no TODOs. You can run 'bundle' from within your new gem project now.", :blue)
|
100
|
+
return
|
101
|
+
end
|
102
|
+
|
103
|
+
msg = 'Please complete'
|
104
|
+
msg << " the #{gemspec_todos} TODOs in #{gem_name}.gemspec" if gemspec_todos.positive?
|
105
|
+
msg << ' and' if gemspec_todos.positive? && readme_todos.positive?
|
106
|
+
msg << " the #{readme_todos} TODOs in README.md." if readme_todos.positive?
|
107
|
+
puts set_color(msg, :yellow)
|
108
|
+
end
|
88
109
|
end
|
89
110
|
end
|
90
111
|
end
|
data/lib/nugem/git.rb
CHANGED
@@ -2,79 +2,82 @@ require 'thor'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
module Nugem
|
5
|
-
|
5
|
+
class Cli < Thor
|
6
6
|
include Thor::Actions
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
no_tasks do # rubocop:disable Metrics/BlockLength
|
9
|
+
def create_local_git_repository
|
10
|
+
puts set_color('Creating the local git repository', :green)
|
11
|
+
run 'git init'
|
12
|
+
run 'git add .'
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
# See https://github.com/rails/thor/blob/v1.2.2/lib/thor/actions.rb#L236-L278
|
15
|
+
run "git commit -aqm 'Initial commit'", abort_on_failure: false
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
def github_config
|
19
|
+
gh_hosts_file = Nugem.expand_env('$HOME/.config/gh/hosts.yml')
|
20
|
+
return nil unless File.exist? gh_hosts_file
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
YAML.safe_load_file(gh_hosts_file)
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
def create_remote_git_repository(repository)
|
26
|
+
puts set_color("Creating a remote #{repository.host} repository", :green)
|
27
|
+
if repository.github?
|
28
|
+
gh_config = github_config
|
29
|
+
token = gh_config&.dig('github.com', 'oauth_token')
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
--
|
43
|
-
|
44
|
-
|
45
|
-
|
31
|
+
token ||= ask('What is your Github personal access token', echo: false)
|
32
|
+
curl_command = <<~END_CURL
|
33
|
+
curl --request POST \
|
34
|
+
--user '#{repository.user}:#{token}' \
|
35
|
+
https://api.github.com/user/repos \
|
36
|
+
-d '{"name":"#{repository.name}", "private":#{repository.private?}}'
|
37
|
+
END_CURL
|
38
|
+
run(curl_command, capture: true)
|
39
|
+
else # BitBucket
|
40
|
+
password = ask('Please enter your Bitbucket password', echo: false)
|
41
|
+
fork_policy = repository.public? ? 'allow_forks' : 'no_public_forks'
|
42
|
+
run <<~END_BITBUCKET
|
43
|
+
curl --request POST \
|
44
|
+
--user #{repository.user}:#{password} \
|
45
|
+
https://api.bitbucket.org/2.0/repositories/#{repository.user}/#{repository.name} \
|
46
|
+
-d '{"scm":"git", "fork_policy":"#{fork_policy}", "is_private":"#{repository.private?}"}'
|
47
|
+
END_BITBUCKET
|
48
|
+
end
|
49
|
+
run "git remote add origin #{repository.origin}"
|
50
|
+
puts set_color("Pushing initial commit to remote #{repository.host} repository", :green)
|
51
|
+
run 'git push -u origin master'
|
46
52
|
end
|
47
|
-
run "git remote add origin #{repository.origin}"
|
48
|
-
say "Pushing initial commit to remote #{repository.host} repository", :green
|
49
|
-
run 'git push -u origin master'
|
50
|
-
end
|
51
53
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def git_repository_user_name(host)
|
55
|
+
global_config = Rugged::Config.global
|
56
|
+
git_config_key = "nugem.#{host}user"
|
57
|
+
user = global_config[git_config_key]
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
+
gh_config = github_config
|
60
|
+
user ||= gh_config&.dig('github.com', 'user')
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
user = ask "What is your #{host} user name?" if user.to_s.empty?
|
63
|
+
global_config[git_config_key] = user if user != global_config[git_config_key]
|
64
|
+
user
|
65
|
+
end
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
def gem_server_url(private_)
|
68
|
+
if private_ && Nugem::FEATURE_GEMINABOX
|
69
|
+
global_config = Rugged::Config.global
|
70
|
+
git_config_key = 'nugem.gemserver'
|
71
|
+
url = global_config[git_config_key]
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
if url.to_s.strip.empty?
|
74
|
+
url = ask('What is the url of your Geminabox server?')
|
75
|
+
global_config[git_config_key] = url unless url.to_s.strip.empty?
|
76
|
+
end
|
77
|
+
url
|
78
|
+
else
|
79
|
+
'https://rubygems.org'
|
74
80
|
end
|
75
|
-
url
|
76
|
-
else
|
77
|
-
'https://rubygems.org'
|
78
81
|
end
|
79
82
|
end
|
80
83
|
end
|
data/lib/nugem/repository.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Nugem::Repository contains informations about the git repository and the git user
|
2
2
|
module Nugem
|
3
3
|
class Repository
|
4
|
-
attr_reader :gem_server_url, :global_config, :host, :name, :private, :user, :user_name, :user_email
|
4
|
+
attr_reader :gem_server_url, :global_config, :host, :name, :out_dir, :private, :user, :user_name, :user_email
|
5
5
|
|
6
6
|
Host = Struct.new(:domain, :camel_case, :id, keyword_init: true)
|
7
7
|
HOSTS = [
|
@@ -12,8 +12,9 @@ module Nugem
|
|
12
12
|
def initialize(options)
|
13
13
|
@host = HOSTS.find { |host| host.id == options[:host] }
|
14
14
|
@private = options[:private]
|
15
|
-
@name
|
16
|
-
@user
|
15
|
+
@name = options[:name]
|
16
|
+
@user = options[:user]
|
17
|
+
|
17
18
|
@global_config = Rugged::Config.global
|
18
19
|
abort 'Git global config not found' if @global_config.nil?
|
19
20
|
|
data/lib/nugem/version.rb
CHANGED
data/lib/nugem.rb
CHANGED
@@ -1,31 +1,18 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require_relative 'nugem/git'
|
3
|
-
require_relative 'nugem/repository'
|
4
|
-
require_relative 'nugem/version'
|
5
2
|
require_relative 'util'
|
6
3
|
|
4
|
+
Signal.trap('INT') { exit }
|
5
|
+
|
7
6
|
module Nugem
|
8
7
|
# @return Path to the generated gem
|
9
|
-
def self.dest_root(gem_name)
|
10
|
-
File.expand_path "
|
8
|
+
def self.dest_root(out_dir, gem_name)
|
9
|
+
File.expand_path "#{out_dir}/#{gem_name}"
|
11
10
|
end
|
12
11
|
|
13
|
-
|
14
|
-
include Thor::Actions
|
15
|
-
|
16
|
-
package_name 'Nugem'
|
17
|
-
|
18
|
-
# These declarations make the class instance variable values available as an accessor,
|
19
|
-
# which is necessary to name template files that are named '%variable_name%.extension'.
|
20
|
-
# See https://www.rubydoc.info/gems/thor/Thor/Actions#directory-instance_method
|
21
|
-
attr_reader :block_name, :filter_name, :generator_name, :tag_name, :test_framework
|
22
|
-
|
23
|
-
class << self
|
24
|
-
def test_option(default_value)
|
25
|
-
method_option :test_framework, type: :string, default: default_value,
|
26
|
-
enum: %w[minitest rspec],
|
27
|
-
desc: "Use rspec or minitest for the test framework (default is #{default_value})."
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
12
|
+
FEATURE_GEMINABOX = false
|
31
13
|
end
|
14
|
+
|
15
|
+
require_relative 'nugem/git'
|
16
|
+
require_relative 'nugem/cli'
|
17
|
+
require_relative 'nugem/repository'
|
18
|
+
require_relative 'nugem/version'
|
data/lib/util.rb
CHANGED
@@ -8,4 +8,31 @@ module Nugem
|
|
8
8
|
ENV.fetch(Regexp.last_match(1), nil)
|
9
9
|
end
|
10
10
|
end
|
11
|
+
|
12
|
+
# The following methods are not required at present ... but they might be needed one day, so not deleting yet
|
13
|
+
|
14
|
+
# @param file must be a fully qualified file name
|
15
|
+
# @return Gem::Specification of gem that file points into, or nil if not called from a gem
|
16
|
+
def self.current_spec(file)
|
17
|
+
return nil unless File.file?(file)
|
18
|
+
|
19
|
+
searcher = if Gem::Specification.respond_to?(:find)
|
20
|
+
Gem::Specification
|
21
|
+
elsif Gem.respond_to?(:searcher)
|
22
|
+
Gem.searcher.init_gemspecs
|
23
|
+
end
|
24
|
+
|
25
|
+
searcher&.find do |spec|
|
26
|
+
file.start_with? spec.full_gem_path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.gem_path(file)
|
31
|
+
spec = current_spec(file)
|
32
|
+
spec&.full_gem_path
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.template_directory
|
36
|
+
File.join gem_path(__FILE__), 'templates'
|
37
|
+
end
|
11
38
|
end
|
data/nugem.gemspec
CHANGED
@@ -1,23 +1,44 @@
|
|
1
1
|
require_relative 'lib/nugem/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
|
-
|
5
|
-
|
6
|
-
spec.
|
7
|
-
spec.
|
8
|
-
spec.
|
9
|
-
spec.description = <<~END_DESC
|
4
|
+
host = 'https://github.com/mslinn/nugem'
|
5
|
+
|
6
|
+
spec.authors = ['Igor Jancev', 'Mike Slinn']
|
7
|
+
spec.bindir = 'exe'
|
8
|
+
spec.description = <<~END_DESC
|
10
9
|
Nugem creates a scaffold project for new gems. You can choose between Github and Bitbucket,
|
11
10
|
Rubygems or Geminabox, with or without an executable, etc.
|
12
11
|
END_DESC
|
13
|
-
spec.
|
14
|
-
spec.
|
15
|
-
spec.
|
16
|
-
|
12
|
+
spec.email = ['igor@masterybits.com', 'mslinn@mslinn.com']
|
13
|
+
spec.executables = %w[nugem]
|
14
|
+
spec.files = Dir[
|
15
|
+
'.rubocop.yml',
|
16
|
+
'Gemfile',
|
17
|
+
'LICENSE.*',
|
18
|
+
'Rakefile',
|
19
|
+
'{lib,spec,templates}/**/*',
|
20
|
+
'templates/**/.*',
|
21
|
+
'templates/**/.*/*',
|
22
|
+
'*.gemspec',
|
23
|
+
'*.md'
|
24
|
+
]
|
25
|
+
spec.homepage = 'https://github.com/mslinn/nugem'
|
26
|
+
spec.license = 'MIT'
|
27
|
+
spec.metadata = {
|
28
|
+
'allowed_push_host' => 'https://rubygems.org',
|
29
|
+
'bug_tracker_uri' => "#{host}/issues",
|
30
|
+
'changelog_uri' => "#{host}/CHANGELOG.md",
|
31
|
+
'homepage_uri' => spec.homepage,
|
32
|
+
'source_code_uri' => host,
|
33
|
+
}
|
34
|
+
spec.name = 'nugem'
|
35
|
+
spec.platform = Gem::Platform::RUBY
|
36
|
+
spec.require_paths = ['lib']
|
17
37
|
spec.required_ruby_version = '>= 3.1.0'
|
18
|
-
spec.summary
|
19
|
-
spec.version
|
38
|
+
spec.summary = 'Nugem creates a scaffold project for new gems.'
|
39
|
+
spec.version = Nugem::VERSION
|
20
40
|
|
41
|
+
spec.add_dependency 'jekyll'
|
21
42
|
spec.add_dependency 'rugged'
|
22
43
|
spec.add_dependency 'thor'
|
23
44
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,9 @@
|
|
1
1
|
require_relative '../lib/nugem'
|
2
2
|
|
3
3
|
RSpec.configure do |config|
|
4
|
-
config.
|
4
|
+
config.filter_run_when_matching focus: true
|
5
5
|
# config.order = "random"
|
6
|
-
config.run_all_when_everything_filtered = true
|
7
6
|
|
8
7
|
# See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
|
9
8
|
config.example_status_persistence_file_path = '../spec/status_persistence.txt'
|
10
|
-
|
11
|
-
config.filter_run_when_matching focus: true
|
12
9
|
end
|
@@ -1,13 +1,21 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
1
|
+
require 'colorator'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
def require_subdirectory(dir)
|
6
|
+
Dir[File.join(dir, '*.rb')].each do |file|
|
7
|
+
require file unless file == __FILE__
|
8
|
+
end
|
9
|
+
end
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
11
|
+
require_subdirectory File.realpath(__dir__) # Require all Ruby files in 'lib/', except this file
|
12
|
+
Pathname(__dir__).children.select(&:directory?).each do |directory|
|
13
|
+
require_subdirectory directory.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
module <%= @class_name %>
|
17
|
+
def self.main
|
18
|
+
@options = parse_options
|
19
|
+
puts "TODO: write main implementation in lib/<%= @class_name %>/cli.rb".yellow
|
12
20
|
end
|
13
21
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'colorator'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
def help(msg = nil)
|
5
|
+
printf "Error: #{msg}\n\n".yellow unless msg.nil?
|
6
|
+
msg = <<~END_HELP
|
7
|
+
<%= @gem_name %>: Describe this executable.
|
8
|
+
|
9
|
+
Syntax: <%= @gem_name %> [Options]
|
10
|
+
|
11
|
+
Options:
|
12
|
+
-h Show this help message
|
13
|
+
END_HELP
|
14
|
+
printf msg.cyan
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_options
|
19
|
+
options = { bpm: 120, overwrite: false }
|
20
|
+
OptionParser.new do |parser|
|
21
|
+
parser.program_name = File.basename __FILE__
|
22
|
+
@parser = parser
|
23
|
+
|
24
|
+
# parser.on('-b', '--bpm BPM', OptionParser::DecimalInteger, 'Specify BPM (default is 120 bpm)')
|
25
|
+
# parser.on('-f', '--overwrite', 'Overwrite output MIDI file if present') {% endcomment %}
|
26
|
+
parser.on_tail('-h', '--help', 'Show this message') do
|
27
|
+
help
|
28
|
+
end
|
29
|
+
end.order!(into: options)
|
30
|
+
options
|
31
|
+
end
|
@@ -41,18 +41,18 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.required_ruby_version = '>= 3.1.0'
|
42
42
|
spec.summary = '<%= @todo %>Write summary of what the gem is for'
|
43
43
|
spec.version = <%= @class_name %>::VERSION
|
44
|
-
|
45
44
|
<%- if @geminabox -%>
|
46
45
|
spec.add_dependency 'geminabox', '>= 2.2.1'
|
47
46
|
<%- end -%>
|
48
47
|
<%- if @jekyll -%>
|
49
48
|
spec.add_dependency 'jekyll', '>= 3.5.0'
|
50
|
-
spec.add_dependency 'jekyll_plugin_support', '>= 0.
|
49
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 1.0.3'
|
51
50
|
<%- end -%>
|
52
|
-
<%- if @
|
51
|
+
<%- if @rails -%>
|
53
52
|
spec.add_dependency 'rails', '~> 7.0.5'
|
54
53
|
<%- end -%>
|
55
54
|
<%- if @executable -%>
|
56
|
-
spec.add_dependency '
|
55
|
+
spec.add_dependency 'colorator'
|
56
|
+
spec.add_dependency 'optparse'
|
57
57
|
<%- end -%>
|
58
58
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/binstub/
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/test/coverage/
|
8
|
+
/test/reports/
|
9
|
+
/doc/
|
10
|
+
/pkg/
|
11
|
+
/tmp/
|
12
|
+
<%- if @rails -%>
|
13
|
+
test/dummy/db/*.sqlite3
|
14
|
+
test/dummy/db/*.sqlite3-journal
|
15
|
+
test/dummy/log/*.log
|
16
|
+
test/dummy/tmp/
|
17
|
+
test/dummy/.sass-cache
|
18
|
+
<%- end -%>
|
19
|
+
<%- if @jekyll -%>
|
20
|
+
spec/status_persistence.txt
|
21
|
+
.jekyll-cache/
|
22
|
+
.jekyll-metadata
|
23
|
+
_site/
|
24
|
+
demo/_site/
|
25
|
+
demo/.jekyll-cache/
|
26
|
+
demo/.jekyll-metadata
|
27
|
+
<%- end -%>
|