bundlegem 0.1.1 → 1.0.1.pre.rc.1
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/README.md +53 -21
- data/bin/bundlegem +4 -5
- data/changelog +2 -22
- data/config/config +2 -2
- data/lib/bundlegem/cli/cli.rb +5 -0
- data/lib/bundlegem/cli/dir_to_template.rb +24 -0
- data/lib/bundlegem/cli/gem.rb +76 -38
- data/lib/bundlegem/cli.rb +1 -1
- data/lib/bundlegem/configurator.rb +9 -18
- data/lib/bundlegem/core/core.rb +9 -0
- data/lib/bundlegem/core/dir_to_template.rb +59 -0
- data/lib/bundlegem/strings.rb +6 -6
- data/lib/bundlegem/template_manager.rb +31 -25
- data/lib/bundlegem/templates/cli_gem/#{name}.gemspec.tt +23 -21
- data/lib/bundlegem/templates/template-test/#{name}/keep.tt +0 -0
- data/lib/bundlegem/templates/template-test/#{name}.rb.tt +19 -0
- data/lib/bundlegem/templates/template-test/#{underscored_name}/keep.tt +0 -0
- data/lib/bundlegem/templates/template-test/.vscode/launch.json.tt +0 -0
- data/lib/bundlegem/templates/template-test/bundlegem.yml +2 -0
- data/lib/bundlegem/templates/template-test/simple_dir/keep.tt +0 -0
- data/lib/bundlegem/templates/template-test/test_confirmed.tt +0 -0
- data/lib/bundlegem/templates/test_template/#{name}.rb.tt +8 -0
- data/lib/bundlegem/templates/test_template/bundlegem.yml +2 -0
- data/lib/bundlegem/version.rb +1 -1
- data/lib/bundlegem.rb +9 -27
- data/spec/bundlegem/core/dir_to_template_spec.rb +22 -0
- data/spec/bundlegem_spec.rb +57 -14
- data/spec/data/variable_manifest_test.rb +10 -2
- data/spec/spec_helper.rb +7 -5
- data/spec/template_manager_spec.rb +17 -0
- metadata +21 -5
data/lib/bundlegem/strings.rb
CHANGED
@@ -17,13 +17,13 @@ Usage Examples:
|
|
17
17
|
# Download all my template files (configured in ~/.bundlegem/config)
|
18
18
|
$ bundlegem --install-best-templates
|
19
19
|
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
20
|
+
# Convert the current directory which represents a working project into a
|
21
|
+
# template meaning all files will be renamed to *.tt unless a *.tt of that
|
22
|
+
# name already exists
|
23
|
+
$ bundlegem --to-template
|
23
24
|
|
24
|
-
|
25
|
+
# shows this message
|
26
|
+
$ bundlegem --help
|
25
27
|
HEREDOC
|
26
28
|
|
27
|
-
|
28
|
-
|
29
29
|
end
|
@@ -6,45 +6,51 @@ module Bundlegem
|
|
6
6
|
# in the user's dir, the gem's builtin templates
|
7
7
|
# (and on the web some day)
|
8
8
|
class TemplateManager
|
9
|
-
|
10
9
|
class << self
|
11
10
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
11
|
+
def internal_template_location() = File.expand_path("#{File.dirname(__FILE__)}/templates")
|
12
|
+
def custom_template_location() = File.expand_path("~/.bundlegem/templates")
|
13
|
+
def default_template_name() = "cli_gem"
|
15
14
|
|
15
|
+
def get_template_src(options)
|
16
|
+
template_name = options["template"] || default_template_name
|
17
|
+
template_location = template_exists_within_repo?(template_name) ?
|
18
|
+
internal_template_location :
|
19
|
+
custom_template_location
|
16
20
|
|
17
|
-
|
18
|
-
"newgem"
|
21
|
+
resolve_template_path(template_location, template_name)
|
19
22
|
end
|
20
23
|
|
21
|
-
def
|
22
|
-
template_name
|
23
|
-
|
24
|
-
if template_exists_within_repo?(template_name)
|
25
|
-
template_location = get_internal_template_location
|
26
|
-
else
|
27
|
-
template_location = File.expand_path("~/.bundlegem/templates")
|
28
|
-
end
|
29
|
-
template_src = "#{template_location}/#{template_name}"
|
24
|
+
def template_exists_within_repo?(template_name)
|
25
|
+
file_in_source?(template_name) || file_in_source?("template-#{template_name}")
|
30
26
|
end
|
31
27
|
|
28
|
+
def resolve_template_path(location, name)
|
29
|
+
basic = "#{location}/#{name}"
|
30
|
+
prefixed = "#{location}/template-#{name}"
|
31
|
+
|
32
|
+
return basic if File.exist?(basic)
|
33
|
+
return prefixed if File.exist?(prefixed)
|
32
34
|
|
33
|
-
|
34
|
-
File.expand_path("#{File.dirname(__FILE__)}/templates")
|
35
|
+
basic # fallback, even if it doesn't exist, will be caught downstream
|
35
36
|
end
|
36
37
|
|
37
|
-
def
|
38
|
-
|
38
|
+
def try_template_src_locations(template_location, template_name)
|
39
|
+
basic_form = "#{template_location}/#{template_name}"
|
40
|
+
prefixed_form = "#{template_location}/template-#{template_name}"
|
41
|
+
|
42
|
+
if File.exist?(basic_form)
|
43
|
+
return basic_form
|
44
|
+
elsif File.exist?(prefixed_form)
|
45
|
+
return prefixed_form
|
46
|
+
else
|
47
|
+
"#{template_location}/#{template_name}"
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
|
-
#
|
42
|
-
# EDIT: Reworked from Thor to not rely on Thor (or do so much unneeded stuff)
|
43
|
-
#
|
44
51
|
def find_in_source_paths(target)
|
45
|
-
|
46
|
-
|
47
|
-
target # failed, hopefully full path to a user specified gem template file
|
52
|
+
path = "#{__dir__}/templates/#{target}"
|
53
|
+
File.exist?(path) ? path : target
|
48
54
|
end
|
49
55
|
|
50
56
|
# Get's path to 'target' from within the gem's "templates" folder
|
@@ -1,40 +1,42 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require_relative 'lib/<%=config[:namespaced_path]%>/version'
|
3
3
|
|
4
|
-
|
5
|
-
spec.name = <%=config[:name].inspect%>
|
6
|
-
spec.version = <%=config[:constant_name]%>::VERSION
|
7
|
-
spec.authors = [<%=config[:author].inspect%>]
|
8
|
-
spec.email = [<%=config[:email].inspect%>]
|
4
|
+
version = <%=config[:constant_name]%>::VERSION
|
9
5
|
|
10
|
-
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = <%=config[:name].inspect%>
|
8
|
+
s.version = version
|
9
|
+
s.authors = [<%=config[:author].inspect%>]
|
10
|
+
s.email = [<%=config[:email].inspect%>]
|
11
11
|
|
12
|
-
|
13
|
-
spec.required_ruby_version = ">= 3.0.0"
|
12
|
+
s.summary = %q{A gem}
|
14
13
|
|
15
|
-
|
14
|
+
s.homepage = "https://github.com/<%=config[:author]%>/<%=config[:name]%>"
|
15
|
+
s.required_ruby_version = ">= 3.0.0"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
s.metadata["allowed_push_host"] = "https://localhost.com" # prevents accidental gem pushes for private projects
|
18
|
+
|
19
|
+
s.metadata["homepage_uri"] = s.homepage
|
20
|
+
s.metadata["source_code_uri"] = s.homepage
|
21
|
+
s.metadata["changelog_uri"] = s.homepage
|
20
22
|
|
21
23
|
# Specify which files should be added to the gem when it is released.
|
22
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
25
|
gemspec = File.basename(__FILE__)
|
24
|
-
|
26
|
+
s.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
|
25
27
|
ls.readlines("\x0", chomp: true).reject do |f|
|
26
28
|
(f == gemspec) ||
|
27
29
|
f.start_with?(*%w[bin/ test/ spec/ features/ .git .gitlab-ci.yml appveyor Gemfile])
|
28
30
|
end
|
29
31
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
s.bindir = "exe"
|
33
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
s.require_paths = ["lib"]
|
33
35
|
|
34
|
-
#
|
36
|
+
# s.add_dependency "bundler", "~> <%= config[:bundler_version] %>"
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
s.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>"
|
39
|
+
s.add_development_dependency "rake", "~> 13.0"
|
40
|
+
s.add_development_dependency "rspec"
|
41
|
+
s.add_development_dependency "pry"
|
40
42
|
end
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
This file shows all the variables in one place!
|
2
|
+
See "lib/bundlegem/templates/test_template/#{name}.rb.tt"
|
3
|
+
|
4
|
+
config[:name]: <%= config[:name] %>
|
5
|
+
config[:unprefixed_name]: <%= config[:unprefixed_name] %>
|
6
|
+
config[:unprefixed_pascal]:<%= config[:unprefixed_pascal] %>
|
7
|
+
config[:underscored_name]: <%= config[:underscored_name] %>
|
8
|
+
config[:pascal_name]: <%= config[:pascal_name] %>
|
9
|
+
config[:camel_name]: <%= config[:camel_name] %>
|
10
|
+
config[:screamcase_name]: <%= config[:screamcase_name] %>
|
11
|
+
config[:namespaced_path]: <%= config[:namespaced_path] %>
|
12
|
+
config[:makefile_path]: <%= config[:makefile_path] %>
|
13
|
+
config[:constant_name]: <%= config[:constant_name] %>
|
14
|
+
config[:constant_array]: <%= config[:constant_array] %>
|
15
|
+
config[:author]: <%= config[:author] %>
|
16
|
+
config[:email]: <%= config[:email] %>
|
17
|
+
config[:git_repo_domain]: <%= config[:git_repo_domain] %>
|
18
|
+
config[:git_repo_url]: <%= config[:git_repo_url] %>
|
19
|
+
config[:git_repo_path]: <%= config[:git_repo_path] %>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,11 +1,19 @@
|
|
1
1
|
This file shows all the variables in one place!
|
2
|
+
See "lib/bundlegem/templates/test_template/#{name}.rb.tt"
|
2
3
|
|
3
4
|
config[:name]: <%= config[:name] %>
|
5
|
+
config[:unprefixed_name]: <%= config[:unprefixed_name] %>
|
6
|
+
config[:unprefixed_pascal]:<%= config[:unprefixed_pascal] %>
|
4
7
|
config[:underscored_name]: <%= config[:underscored_name] %>
|
8
|
+
config[:pascal_name]: <%= config[:pascal_name] %>
|
9
|
+
config[:camel_name]: <%= config[:camel_name] %>
|
10
|
+
config[:screamcase_name]: <%= config[:screamcase_name] %>
|
5
11
|
config[:namespaced_path]: <%= config[:namespaced_path] %>
|
6
12
|
config[:makefile_path]: <%= config[:makefile_path] %>
|
7
13
|
config[:constant_name]: <%= config[:constant_name] %>
|
8
14
|
config[:constant_array]: <%= config[:constant_array] %>
|
9
15
|
config[:author]: <%= config[:author] %>
|
10
16
|
config[:email]: <%= config[:email] %>
|
17
|
+
config[:git_repo_domain]: <%= config[:git_repo_domain] %>
|
11
18
|
config[:git_repo_url]: <%= config[:git_repo_url] %>
|
19
|
+
config[:git_repo_path]: <%= config[:git_repo_path] %>
|
data/lib/bundlegem/version.rb
CHANGED
data/lib/bundlegem.rb
CHANGED
@@ -3,12 +3,14 @@ require "bundlegem/strings"
|
|
3
3
|
require 'bundlegem/configurator'
|
4
4
|
require 'bundlegem/template_manager'
|
5
5
|
|
6
|
+
require 'bundlegem/core/core'
|
7
|
+
require 'bundlegem/cli/cli'
|
8
|
+
|
6
9
|
require 'bundlegem/cli'
|
7
10
|
|
8
11
|
SOURCE_ROOT = File.expand_path("#{File.dirname(__FILE__)}/..")
|
9
12
|
|
10
13
|
module Bundlegem
|
11
|
-
|
12
14
|
class << self
|
13
15
|
|
14
16
|
def version
|
@@ -18,16 +20,7 @@ module Bundlegem
|
|
18
20
|
# lists available templates
|
19
21
|
def list
|
20
22
|
configurator = Configurator.new
|
21
|
-
|
22
|
-
available_templates = [ { "predefined" => "newgem" },
|
23
|
-
{ "predefined" => "c_extension_gem" },
|
24
|
-
{ "predefined" => "cli_gem" }]
|
25
|
-
|
26
|
-
# search through user downloaded
|
27
|
-
available_templates += configurator.user_downloaded_templates
|
28
|
-
|
29
|
-
# search through user defined
|
30
|
-
available_templates += configurator.user_defined_templates
|
23
|
+
available_templates = configurator.collect_user_defined_templates
|
31
24
|
|
32
25
|
available_templates = group_hashes_by_key(available_templates)
|
33
26
|
output_string = convert_grouped_hashes_to_output(available_templates)
|
@@ -47,12 +40,15 @@ module Bundlegem
|
|
47
40
|
cmd += " 2> /dev/null" if $test_env
|
48
41
|
`#{cmd}`
|
49
42
|
else
|
50
|
-
|
51
|
-
# Prompt to update the repo if they have a clean working state.
|
43
|
+
puts "Warning: Skipping, template already exists #{ENV['HOME']}/.bundlegem/templates/#{template_folder_name}"
|
52
44
|
end
|
53
45
|
end
|
54
46
|
end
|
55
47
|
|
48
|
+
def dir_to_template
|
49
|
+
puts Cli::DirToTemplate.go
|
50
|
+
end
|
51
|
+
|
56
52
|
def gem(options, gem_name)
|
57
53
|
require 'bundlegem/cli'
|
58
54
|
require 'bundlegem/cli/gem'
|
@@ -60,19 +56,6 @@ module Bundlegem
|
|
60
56
|
Bundlegem::CLI::Gem.new(options, gem_name).run
|
61
57
|
end
|
62
58
|
|
63
|
-
def new_template(args)
|
64
|
-
template_name = args[1]
|
65
|
-
template_name = prompt_for_template_name if template_name.nil?
|
66
|
-
|
67
|
-
# Copy newgem from within the repo to ~/.bundlegem/templates/#{template_name}
|
68
|
-
TemplateManager.create_new_template(template_name)
|
69
|
-
end
|
70
|
-
|
71
|
-
def prompt_for_template_name
|
72
|
-
puts "Please specify a name for your template: "
|
73
|
-
template_name = STDIN.gets.chomp.strip.gsub(" ", "_")
|
74
|
-
end
|
75
|
-
|
76
59
|
# input: [ { "predefined" => "default" },
|
77
60
|
# { "MISC" => "my_thing" },
|
78
61
|
# { "prdefined" => "service" }
|
@@ -134,5 +117,4 @@ module Bundlegem
|
|
134
117
|
end
|
135
118
|
|
136
119
|
end
|
137
|
-
|
138
120
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'find'
|
3
|
+
|
4
|
+
module Bundlegem::Core
|
5
|
+
describe DirToTemplate do
|
6
|
+
before :each do
|
7
|
+
@mocked_home = "/tmp/bundlegem_mock_home"
|
8
|
+
@template_root = "#{@mocked_home}/.bundlegem/templates"
|
9
|
+
@dst_dir = "/tmp/bundle_gem_dst_dir"
|
10
|
+
|
11
|
+
reset_test_env
|
12
|
+
FileUtils.chdir(@dst_dir)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'is there' do
|
16
|
+
create_user_defined_template(category: "wizardly_tools")
|
17
|
+
files_changed = DirToTemplate.🧙🪄! Find.find('/tmp/temp/.'), dry_run: true
|
18
|
+
|
19
|
+
expect(files_changed.first).to eq "Renamed: /tmp/temp/./README.md -> /tmp/temp/./README.md.tt"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/spec/bundlegem_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Bundlegem do
|
4
|
-
|
5
4
|
before :each do
|
6
5
|
@mocked_home = "/tmp/bundlegem_mock_home"
|
7
6
|
@template_root = "#{@mocked_home}/.bundlegem/templates"
|
@@ -20,8 +19,8 @@ describe Bundlegem do
|
|
20
19
|
|
21
20
|
list_output = Bundlegem.list
|
22
21
|
|
23
|
-
expect(list_output).to eq "
|
24
|
-
expect(File.exist
|
22
|
+
expect(list_output).to eq " MISC:\n empty_template\n\n"
|
23
|
+
expect(File).to exist("#{ENV['HOME']}/.bundlegem")
|
25
24
|
end
|
26
25
|
|
27
26
|
it "lists with good categories" do
|
@@ -29,7 +28,18 @@ describe Bundlegem do
|
|
29
28
|
create_user_defined_template(category)
|
30
29
|
|
31
30
|
list_output = Bundlegem.list
|
32
|
-
expect(list_output
|
31
|
+
expect(list_output).to include category
|
32
|
+
end
|
33
|
+
|
34
|
+
it "lists omit the prefix 'template-' if present in repo" do
|
35
|
+
category = "ANYTHING"
|
36
|
+
full_template_name = "template-happy-burger"
|
37
|
+
create_user_defined_template(category, "template-happy-burger")
|
38
|
+
|
39
|
+
list_output = Bundlegem.list
|
40
|
+
# expect(list_output.include?(full_template_name)).to be false
|
41
|
+
expect(list_output).not_to include full_template_name
|
42
|
+
expect(list_output).to include "happy-burger"
|
33
43
|
end
|
34
44
|
|
35
45
|
# This bulids the default gem template
|
@@ -38,7 +48,7 @@ describe Bundlegem do
|
|
38
48
|
gem_name = "tmp_gem"
|
39
49
|
|
40
50
|
capture_stdout { Bundlegem.gem(options, gem_name) }
|
41
|
-
expect(File.exist
|
51
|
+
expect(File).to exist("#{@dst_dir}/#{gem_name}/README.md")
|
42
52
|
end
|
43
53
|
|
44
54
|
it "can generate the c_ext gem fine" do
|
@@ -46,10 +56,21 @@ describe Bundlegem do
|
|
46
56
|
gem_name = "tmp_gem"
|
47
57
|
|
48
58
|
capture_stdout { Bundlegem.gem(options, gem_name) }
|
49
|
-
expect(File.exist
|
59
|
+
expect(File).to exist("#{@dst_dir}/#{gem_name}/ext/tmp_gem/#{gem_name}.c")
|
50
60
|
end
|
51
61
|
|
52
|
-
|
62
|
+
|
63
|
+
it "finds the template-test template even if the template- prefix was omitted" do
|
64
|
+
options = {"bin"=>false, "ext"=>false, :coc=> false, "template" => "test"}
|
65
|
+
gem_name = "tmp_gem"
|
66
|
+
|
67
|
+
capture_stdout { Bundlegem.gem(options, gem_name) }
|
68
|
+
expect(File).to exist("#{@dst_dir}/#{gem_name}/test_confirmed")
|
69
|
+
expect(File).to exist("#{@dst_dir}/#{gem_name}/.vscode/launch.json")
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
it "has a useful dynamically_generate_template_directories method" do
|
53
74
|
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
54
75
|
gem_name = "good-dog"
|
55
76
|
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
@@ -57,16 +78,31 @@ describe Bundlegem do
|
|
57
78
|
src_dst_map = my_gem.send('dynamically_generate_template_directories')
|
58
79
|
|
59
80
|
expect(src_dst_map['#{name}']).to eq "good-dog"
|
60
|
-
expect(src_dst_map['#{underscored_name}']).to eq
|
81
|
+
expect(src_dst_map['#{underscored_name}']).to eq "good_dog"
|
61
82
|
expect(src_dst_map['simple_dir']).to eq 'simple_dir'
|
62
83
|
end
|
63
84
|
|
64
|
-
it "
|
85
|
+
it "returns the expected interpolated string when substitute_template_values is called" do
|
65
86
|
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
66
87
|
gem_name = "good-dog"
|
67
88
|
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
68
89
|
|
69
|
-
|
90
|
+
short_path = '#{name}'
|
91
|
+
long_path = 'hello/#{name}/blah/#{name}'
|
92
|
+
|
93
|
+
short_interpolated_string = my_gem.send('substitute_template_values', short_path)
|
94
|
+
expect(short_interpolated_string).to eq gem_name
|
95
|
+
|
96
|
+
long_interpolated_string = my_gem.send('substitute_template_values', long_path)
|
97
|
+
expect(long_interpolated_string).to eq "hello/good-dog/blah/good-dog"
|
98
|
+
end
|
99
|
+
|
100
|
+
it "has a useful dynamically_generate_templates_files method" do
|
101
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
102
|
+
gem_name = "good-dog"
|
103
|
+
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
104
|
+
|
105
|
+
src_dst_map = my_gem.send('dynamically_generate_templates_files')
|
70
106
|
|
71
107
|
expect(src_dst_map['#{name}/keep.tt']).to eq "good-dog/keep"
|
72
108
|
expect(src_dst_map['#{name}.rb.tt']).to eq 'good-dog.rb'
|
@@ -82,21 +118,28 @@ describe Bundlegem do
|
|
82
118
|
expect(File.read("#{@dst_dir}/#{gem_name}/#{gem_name}.rb")).to eq File.read("#{ENV['SPEC_DATA_DIR']}/variable_manifest_test.rb")
|
83
119
|
end
|
84
120
|
|
85
|
-
|
121
|
+
it "has config[:unprefixed_name] removing purpose-tool- from name" do
|
122
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
123
|
+
gem_name = "tool-go-good-dog"
|
124
|
+
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
125
|
+
|
126
|
+
config = my_gem.build_interpolation_config
|
127
|
+
|
128
|
+
expect(config[:unprefixed_name]).to eq "good-dog"
|
129
|
+
end
|
86
130
|
|
131
|
+
describe "install best templates" do
|
87
132
|
before :each do
|
88
133
|
setup_mock_web_template
|
89
134
|
end
|
90
|
-
|
91
135
|
after :each do
|
92
136
|
remove_mock_web_template
|
93
137
|
end
|
94
138
|
|
95
139
|
it "can download best templates from the web" do
|
96
140
|
capture_stdout { Bundlegem.install_best_templates }
|
97
|
-
expect(File.exist
|
141
|
+
expect(File).to exist("#{ENV['HOME']}/.bundlegem/templates/template-arduino/README.md")
|
98
142
|
end
|
99
|
-
|
100
143
|
end
|
101
144
|
|
102
145
|
end
|
@@ -1,11 +1,19 @@
|
|
1
1
|
This file shows all the variables in one place!
|
2
|
+
See "lib/bundlegem/templates/test_template/#{name}.rb.tt"
|
2
3
|
|
3
4
|
config[:name]: good-dog
|
5
|
+
config[:unprefixed_name]: good-dog
|
6
|
+
config[:unprefixed_pascal]:GoodDog
|
4
7
|
config[:underscored_name]: good_dog
|
8
|
+
config[:pascal_name]: GoodDog
|
9
|
+
config[:camel_name]: goodDog
|
10
|
+
config[:screamcase_name]: GOOD_DOG
|
5
11
|
config[:namespaced_path]: good/dog
|
6
12
|
config[:makefile_path]: good_dog/good_dog
|
7
13
|
config[:constant_name]: Good::Dog
|
8
14
|
config[:constant_array]: ["Good", "Dog"]
|
9
|
-
config[:author]:
|
15
|
+
config[:author]: Test
|
10
16
|
config[:email]: you@example.com
|
11
|
-
config[:
|
17
|
+
config[:git_repo_domain]: github.com
|
18
|
+
config[:git_repo_url]: https://github.com/Test/good-dog
|
19
|
+
config[:git_repo_path]: github.com/test/good-dog
|
data/spec/spec_helper.rb
CHANGED
@@ -23,16 +23,18 @@ def remove_mock_web_template
|
|
23
23
|
FileUtils.rm_rf("#{ENV['HOME']}/arduino.git")
|
24
24
|
end
|
25
25
|
|
26
|
-
def create_user_defined_template(category = nil)
|
27
|
-
|
26
|
+
def create_user_defined_template(category = nil, template_name = "empty_template")
|
27
|
+
new_template_dir = "#{@template_root}/#{template_name}"
|
28
28
|
|
29
29
|
# Creates the gem template (empty folder)
|
30
|
-
FileUtils.mkdir_p
|
30
|
+
FileUtils.mkdir_p new_template_dir
|
31
31
|
|
32
32
|
# Writes the category
|
33
|
-
File.open("#{
|
33
|
+
File.open("#{new_template_dir}/.bundlegem", "w+") do |f|
|
34
34
|
f.puts "category: #{category}" unless category.nil?
|
35
35
|
end
|
36
|
+
|
37
|
+
new_template_dir
|
36
38
|
end
|
37
39
|
|
38
40
|
|
@@ -43,7 +45,7 @@ def reset_test_env
|
|
43
45
|
FileUtils.mkdir_p @dst_dir
|
44
46
|
FileUtils.mkdir_p @template_root
|
45
47
|
FileUtils.cd @dst_dir
|
46
|
-
auth_settings = 'git config --global user.email "you@example.com" && git config --global user.name "
|
48
|
+
auth_settings = 'git config --global user.email "you@example.com" && git config --global user.name "Test"'
|
47
49
|
|
48
50
|
`git config --global init.defaultBranch main && #{auth_settings}`
|
49
51
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Bundlegem
|
4
|
+
describe TemplateManager do
|
5
|
+
|
6
|
+
it '#get_template_src returns the template-test even if prefix is omitted' do
|
7
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test" }
|
8
|
+
|
9
|
+
output = TemplateManager.get_template_src(options)
|
10
|
+
|
11
|
+
# binding.pry
|
12
|
+
|
13
|
+
expect(File.basename(output)).to eq "template-test"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundlegem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
4
|
+
version: 1.0.1.pre.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TheNotary
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-05-11 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: thor
|
@@ -129,8 +129,12 @@ files:
|
|
129
129
|
- config/config
|
130
130
|
- lib/bundlegem.rb
|
131
131
|
- lib/bundlegem/cli.rb
|
132
|
+
- lib/bundlegem/cli/cli.rb
|
133
|
+
- lib/bundlegem/cli/dir_to_template.rb
|
132
134
|
- lib/bundlegem/cli/gem.rb
|
133
135
|
- lib/bundlegem/configurator.rb
|
136
|
+
- lib/bundlegem/core/core.rb
|
137
|
+
- lib/bundlegem/core/dir_to_template.rb
|
134
138
|
- lib/bundlegem/friendly_errors.rb
|
135
139
|
- lib/bundlegem/strings.rb
|
136
140
|
- lib/bundlegem/template_manager.rb
|
@@ -195,22 +199,32 @@ files:
|
|
195
199
|
- lib/bundlegem/templates/newgem/rspec.tt
|
196
200
|
- lib/bundlegem/templates/newgem/spec/#{name}_spec.rb.tt
|
197
201
|
- lib/bundlegem/templates/newgem/spec/spec_helper.rb.tt
|
202
|
+
- lib/bundlegem/templates/template-test/#{name}.rb.tt
|
203
|
+
- lib/bundlegem/templates/template-test/#{name}/keep.tt
|
204
|
+
- lib/bundlegem/templates/template-test/#{underscored_name}/keep.tt
|
205
|
+
- lib/bundlegem/templates/template-test/.vscode/launch.json.tt
|
206
|
+
- lib/bundlegem/templates/template-test/bundlegem.yml
|
207
|
+
- lib/bundlegem/templates/template-test/simple_dir/keep.tt
|
208
|
+
- lib/bundlegem/templates/template-test/test_confirmed.tt
|
198
209
|
- lib/bundlegem/templates/test_template/#{name}.rb.tt
|
199
210
|
- lib/bundlegem/templates/test_template/#{name}/keep.tt
|
200
211
|
- lib/bundlegem/templates/test_template/#{underscored_name}/keep.tt
|
212
|
+
- lib/bundlegem/templates/test_template/bundlegem.yml
|
201
213
|
- lib/bundlegem/templates/test_template/simple_dir/keep.tt
|
202
214
|
- lib/bundlegem/version.rb
|
215
|
+
- spec/bundlegem/core/dir_to_template_spec.rb
|
203
216
|
- spec/bundlegem_spec.rb
|
204
217
|
- spec/data/variable_manifest_test.rb
|
205
218
|
- spec/spec_helper.rb
|
219
|
+
- spec/template_manager_spec.rb
|
206
220
|
homepage: https://github.com/thenotary/bundlegem
|
207
221
|
licenses:
|
208
222
|
- MIT
|
209
223
|
metadata:
|
210
224
|
bug_tracker_uri: https://github.com/TheNotary/bundlegem/issues
|
211
|
-
changelog_uri: https://github.com/TheNotary/bundlegem/releases/tag/
|
212
|
-
documentation_uri: https://api.rubyonrails.org/
|
213
|
-
source_code_uri: https://github.com/TheNotary/bundlegem/tree/
|
225
|
+
changelog_uri: https://github.com/TheNotary/bundlegem/releases/tag/v1.0.1-rc.1
|
226
|
+
documentation_uri: https://api.rubyonrails.org/v1.0.1-rc.1/
|
227
|
+
source_code_uri: https://github.com/TheNotary/bundlegem/tree/v1.0.1-rc.1
|
214
228
|
rdoc_options: []
|
215
229
|
require_paths:
|
216
230
|
- lib
|
@@ -229,6 +243,8 @@ rubygems_version: 3.6.2
|
|
229
243
|
specification_version: 4
|
230
244
|
summary: This gem makes more gems!
|
231
245
|
test_files:
|
246
|
+
- spec/bundlegem/core/dir_to_template_spec.rb
|
232
247
|
- spec/bundlegem_spec.rb
|
233
248
|
- spec/data/variable_manifest_test.rb
|
234
249
|
- spec/spec_helper.rb
|
250
|
+
- spec/template_manager_spec.rb
|