bundlegem 0.0.15 → 0.1.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/bundlegem.gemspec +2 -0
- data/lib/bundlegem/cli/gem.rb +27 -21
- data/lib/bundlegem/templates/cli_gem/gitignore.tt +0 -1
- data/lib/bundlegem/templates/test_template/#{name}/keep.tt +0 -0
- data/lib/bundlegem/templates/test_template/#{name}.rb.tt +11 -0
- data/lib/bundlegem/templates/test_template/#{underscored_name}/keep.tt +0 -0
- data/lib/bundlegem/templates/test_template/simple_dir/keep.tt +0 -0
- data/lib/bundlegem/version.rb +1 -1
- data/spec/bundlegem_spec.rb +32 -0
- data/spec/data/variable_manifest_test.rb +11 -0
- data/spec/spec_helper.rb +9 -6
- metadata +37 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34015a75f77131e223b18e6f07e0bbd28d9b392addc289a05bbd3c3a5e440819
|
4
|
+
data.tar.gz: bdbac3955fe9811fe31c1412f95af7f391f763bd18f54dec159ec0352a07dc67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1cadeb6514c5ddec9959c32750ad7a07e111e89d8938eb2d2e62ff65a86a3245d68ed4e0f3a11bfc4621cf6a5bb95a8582af27869d500aee842e880a4655e6c
|
7
|
+
data.tar.gz: 821f53f4046b19a3758723dc117f755be40a9d6d352713734803838ef3c150f6ad0a7a0eaf1574ff9fb2f7390dc003b8582fd355a68125c6ca45d701c5ed1536
|
data/bundlegem.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "thor", "0.19.1"
|
22
22
|
spec.add_dependency "bundler", "~> 2.5"
|
23
|
+
spec.add_dependency "ostruct"
|
24
|
+
spec.add_dependency "reline"
|
23
25
|
|
24
26
|
#spec.add_development_dependency "bundler"#, "~> 1.8"
|
25
27
|
spec.add_development_dependency "rake", "~> 13.2"
|
data/lib/bundlegem/cli/gem.rb
CHANGED
@@ -14,9 +14,7 @@ module Bundlegem
|
|
14
14
|
validate_ext_name if options[:ext]
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
raise_project_with_that_name_already_exists! if File.exist?(target)
|
19
|
-
|
17
|
+
def build_interpolation_config
|
20
18
|
underscored_name = name.tr('-', '_')
|
21
19
|
namespaced_path = name.tr('-', '/')
|
22
20
|
constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] unless p.empty?}.join
|
@@ -41,11 +39,20 @@ module Bundlegem
|
|
41
39
|
:bin => options[:bin],
|
42
40
|
:bundler_version => bundler_dependency_version
|
43
41
|
}
|
44
|
-
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
@config ||= build_interpolation_config
|
46
|
+
end
|
47
|
+
|
48
|
+
def run
|
49
|
+
raise_project_with_that_name_already_exists! if File.exist?(target)
|
50
|
+
|
51
|
+
ensure_safe_gem_name(name, config[:constant_array])
|
45
52
|
|
46
53
|
template_src = match_template_src
|
47
54
|
template_directories = dynamically_generate_template_directories
|
48
|
-
templates = dynamically_generate_templates
|
55
|
+
templates = dynamically_generate_templates
|
49
56
|
|
50
57
|
puts "Creating new project folder '#{name}'\n\n"
|
51
58
|
create_template_directories(template_directories, target)
|
@@ -54,7 +61,6 @@ module Bundlegem
|
|
54
61
|
template("#{template_src}/#{src}", target.join(dst), config)
|
55
62
|
end
|
56
63
|
|
57
|
-
|
58
64
|
# Bundler.ui.info "Initializing git repo in #{target}"
|
59
65
|
Dir.chdir(target) { `git init`; `git add .` }
|
60
66
|
|
@@ -70,8 +76,8 @@ module Bundlegem
|
|
70
76
|
|
71
77
|
private
|
72
78
|
|
79
|
+
# Returns a hash of source directory names and their destination mappings
|
73
80
|
def dynamically_generate_template_directories
|
74
|
-
# return nil if options["template"].nil?
|
75
81
|
template_src = TemplateManager.get_template_src(options)
|
76
82
|
|
77
83
|
template_dirs = {}
|
@@ -121,22 +127,22 @@ module Bundlegem
|
|
121
127
|
|
122
128
|
# Figures out the translation between all the .tt file to their
|
123
129
|
# destination names
|
124
|
-
def dynamically_generate_templates
|
125
|
-
|
126
|
-
# return generate_templates_for_built_in_gems(config)
|
127
|
-
#else
|
128
|
-
template_src = TemplateManager.get_template_src(options)
|
129
|
-
|
130
|
-
templates = {}
|
131
|
-
Dir.glob("#{template_src}/**/{*,.*}.tt").each do |f|
|
132
|
-
base_path = f[template_src.length+1..-1]
|
133
|
-
templates.merge!(base_path => base_path.gsub(/\.tt$/, "").gsub('#{name}', "#{name}") )
|
134
|
-
end
|
130
|
+
def dynamically_generate_templates
|
131
|
+
template_src = TemplateManager.get_template_src(options)
|
135
132
|
|
136
|
-
|
133
|
+
templates = {}
|
134
|
+
Dir.glob("#{template_src}/**/{*,.*}.tt").each do |f|
|
135
|
+
base_path = f[template_src.length+1..-1]
|
136
|
+
templates.merge!(base_path => base_path
|
137
|
+
.gsub(/\.tt$/, "")
|
138
|
+
.gsub('#{name}', "#{name}")
|
139
|
+
.gsub('#{underscored_name}', config[:underscored_name])
|
140
|
+
)
|
141
|
+
end
|
137
142
|
|
138
|
-
|
139
|
-
|
143
|
+
raise_no_files_in_template_error! if templates.empty?
|
144
|
+
|
145
|
+
return templates
|
140
146
|
end
|
141
147
|
|
142
148
|
def create_template_directories(template_directories, target)
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
This file shows all the variables in one place!
|
2
|
+
|
3
|
+
config[:name]: <%= config[:name] %>
|
4
|
+
config[:underscored_name]: <%= config[:underscored_name] %>
|
5
|
+
config[:namespaced_path]: <%= config[:namespaced_path] %>
|
6
|
+
config[:makefile_path]: <%= config[:makefile_path] %>
|
7
|
+
config[:constant_name]: <%= config[:constant_name] %>
|
8
|
+
config[:constant_array]: <%= config[:constant_array] %>
|
9
|
+
config[:author]: <%= config[:author] %>
|
10
|
+
config[:email]: <%= config[:email] %>
|
11
|
+
config[:git_repo_url]: <%= config[:git_repo_url] %>
|
File without changes
|
File without changes
|
data/lib/bundlegem/version.rb
CHANGED
data/spec/bundlegem_spec.rb
CHANGED
@@ -49,6 +49,38 @@ describe Bundlegem do
|
|
49
49
|
expect(File.exist?("#{@dst_dir}/#{gem_name}/ext/tmp_gem/#{gem_name}.c")).to be_truthy
|
50
50
|
end
|
51
51
|
|
52
|
+
it "has a useful dynamically_generate_templates metho" do
|
53
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
54
|
+
gem_name = "good-dog"
|
55
|
+
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
56
|
+
|
57
|
+
src_dst_map = my_gem.send('dynamically_generate_template_directories')
|
58
|
+
|
59
|
+
expect(src_dst_map['#{name}']).to eq "good-dog"
|
60
|
+
expect(src_dst_map['#{underscored_name}']).to eq '#{underscored_name}'
|
61
|
+
expect(src_dst_map['simple_dir']).to eq 'simple_dir'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "has a useful dynamically_generate_templates method" do
|
65
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
66
|
+
gem_name = "good-dog"
|
67
|
+
my_gem = Bundlegem::CLI::Gem.new(options, gem_name)
|
68
|
+
|
69
|
+
src_dst_map = my_gem.send('dynamically_generate_templates')
|
70
|
+
|
71
|
+
expect(src_dst_map['#{name}/keep.tt']).to eq "good-dog/keep"
|
72
|
+
expect(src_dst_map['#{name}.rb.tt']).to eq 'good-dog.rb'
|
73
|
+
expect(src_dst_map['#{underscored_name}/keep.tt']).to eq 'good_dog/keep'
|
74
|
+
expect(src_dst_map['simple_dir/keep.tt']).to eq 'simple_dir/keep'
|
75
|
+
end
|
76
|
+
|
77
|
+
it "has a test proving every interpolation in one file" do
|
78
|
+
options = { "bin"=>false, "ext"=>false, :coc=> false, "template" => "test_template" }
|
79
|
+
gem_name = "good-dog"
|
80
|
+
|
81
|
+
capture_stdout { Bundlegem.gem(options, gem_name) }
|
82
|
+
expect(File.read("#{@dst_dir}/#{gem_name}/#{gem_name}.rb")).to eq File.read("#{ENV['SPEC_DATA_DIR']}/variable_manifest_test.rb")
|
83
|
+
end
|
52
84
|
|
53
85
|
describe "install best templates" do
|
54
86
|
|
@@ -0,0 +1,11 @@
|
|
1
|
+
This file shows all the variables in one place!
|
2
|
+
|
3
|
+
config[:name]: good-dog
|
4
|
+
config[:underscored_name]: good_dog
|
5
|
+
config[:namespaced_path]: good/dog
|
6
|
+
config[:makefile_path]: good_dog/good_dog
|
7
|
+
config[:constant_name]: Good::Dog
|
8
|
+
config[:constant_array]: ["Good", "Dog"]
|
9
|
+
config[:author]: test
|
10
|
+
config[:email]: you@example.com
|
11
|
+
config[:git_repo_url]: https://github.com/test/good_dog
|
data/spec/spec_helper.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
2
|
$test_env = true
|
3
3
|
require 'bundlegem'
|
4
|
+
require 'bundlegem/cli'
|
5
|
+
require 'bundlegem/cli/gem'
|
4
6
|
require 'fileutils'
|
5
7
|
require 'pry'
|
6
8
|
|
7
9
|
# Mock our home directory
|
8
|
-
|
9
10
|
ENV['HOME'] = "/tmp/bundlegem_mock_home"
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
ENV['SPEC_DATA_DIR'] = File.expand_path("./spec/data") # I fell into this from sloppy chdir handling, bad CLI/ API isolation.
|
13
12
|
|
14
13
|
|
15
14
|
def setup_mock_web_template
|
16
15
|
ENV['best_templates'] = "#{ENV['HOME']}/arduino.git"
|
17
16
|
FileUtils.mkdir("#{ENV['HOME']}/arduino.git")
|
18
17
|
FileUtils.touch("#{ENV['HOME']}/arduino.git/README.md")
|
19
|
-
|
20
|
-
`cd "#{ENV['HOME']}/arduino.git" && git init &&
|
18
|
+
|
19
|
+
`cd "#{ENV['HOME']}/arduino.git" && git init && git add . && git commit -m "haxing"`
|
21
20
|
end
|
22
21
|
|
23
22
|
def remove_mock_web_template
|
@@ -43,6 +42,10 @@ def reset_test_env
|
|
43
42
|
|
44
43
|
FileUtils.mkdir_p @dst_dir
|
45
44
|
FileUtils.mkdir_p @template_root
|
45
|
+
FileUtils.cd @dst_dir
|
46
|
+
auth_settings = 'git config --global user.email "you@example.com" && git config --global user.name "test"'
|
47
|
+
|
48
|
+
`git config --global init.defaultBranch main && #{auth_settings}`
|
46
49
|
end
|
47
50
|
|
48
51
|
# squelch stdout
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundlegem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TheNotary
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date: 2025-
|
10
|
+
date: 2025-03-18 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: thor
|
@@ -38,6 +37,34 @@ dependencies:
|
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
39
|
version: '2.5'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: ostruct
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: reline
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
type: :runtime
|
62
|
+
prerelease: false
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
41
68
|
- !ruby/object:Gem::Dependency
|
42
69
|
name: rake
|
43
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,14 +194,18 @@ files:
|
|
167
194
|
- lib/bundlegem/templates/newgem/rspec.tt
|
168
195
|
- lib/bundlegem/templates/newgem/spec/#{name}_spec.rb.tt
|
169
196
|
- lib/bundlegem/templates/newgem/spec/spec_helper.rb.tt
|
197
|
+
- lib/bundlegem/templates/test_template/#{name}.rb.tt
|
198
|
+
- lib/bundlegem/templates/test_template/#{name}/keep.tt
|
199
|
+
- lib/bundlegem/templates/test_template/#{underscored_name}/keep.tt
|
200
|
+
- lib/bundlegem/templates/test_template/simple_dir/keep.tt
|
170
201
|
- lib/bundlegem/version.rb
|
171
202
|
- spec/bundlegem_spec.rb
|
203
|
+
- spec/data/variable_manifest_test.rb
|
172
204
|
- spec/spec_helper.rb
|
173
205
|
homepage: ''
|
174
206
|
licenses:
|
175
207
|
- MIT
|
176
208
|
metadata: {}
|
177
|
-
post_install_message:
|
178
209
|
rdoc_options: []
|
179
210
|
require_paths:
|
180
211
|
- lib
|
@@ -189,10 +220,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
220
|
- !ruby/object:Gem::Version
|
190
221
|
version: '0'
|
191
222
|
requirements: []
|
192
|
-
rubygems_version: 3.
|
193
|
-
signing_key:
|
223
|
+
rubygems_version: 3.6.2
|
194
224
|
specification_version: 4
|
195
225
|
summary: this gem makes more gems!
|
196
226
|
test_files:
|
197
227
|
- spec/bundlegem_spec.rb
|
228
|
+
- spec/data/variable_manifest_test.rb
|
198
229
|
- spec/spec_helper.rb
|