foobar_templates 2.0.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.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.beader/.gitignore +6 -0
  3. data/.beader/issues/1-support-flexible-template-topologies.yaml +21 -0
  4. data/.beader/issues/2-add-monorepo-support-for-template-discovery-and-generation.yaml +33 -0
  5. data/.beader/issues/3-implement-monorepo-aware-recursive-template-inventory.yaml +29 -0
  6. data/.beader/issues/4-add-leaf-template-selection-with-ambiguity-and-not-found-handling.yaml +30 -0
  7. data/.beader/issues/5-integrate-leaf-template-resolution-into-generation-flow.yaml +30 -0
  8. data/.beader/issues/6-add-monorepo-discovery-and-generation-test-coverage.yaml +31 -0
  9. data/.beader/issues/7-document-monorepo-template-configuration-and-selection.yaml +30 -0
  10. data/.beader/meta.yaml +1 -0
  11. data/.gitignore +16 -0
  12. data/.rspec +2 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE.txt +22 -0
  15. data/README.md +154 -0
  16. data/Rakefile +55 -0
  17. data/bin/foobar_templates +72 -0
  18. data/changelog +107 -0
  19. data/config/config +8 -0
  20. data/foobar_templates.gemspec +33 -0
  21. data/lib/foobar_templates/cli/cheat_sheet.rb +12 -0
  22. data/lib/foobar_templates/cli/cli.rb +3 -0
  23. data/lib/foobar_templates/cli/dir_to_template.rb +120 -0
  24. data/lib/foobar_templates/cli/setup_personal_templates_repo.rb +135 -0
  25. data/lib/foobar_templates/cli/template_generator.rb +462 -0
  26. data/lib/foobar_templates/configurator.rb +99 -0
  27. data/lib/foobar_templates/core/core.rb +9 -0
  28. data/lib/foobar_templates/core/dir_to_template.rb +114 -0
  29. data/lib/foobar_templates/strings.rb +23 -0
  30. data/lib/foobar_templates/template_manager.rb +119 -0
  31. data/lib/foobar_templates/templates/template-test/.vscode/launch.json +0 -0
  32. data/lib/foobar_templates/templates/template-test/foo-bar/keep +0 -0
  33. data/lib/foobar_templates/templates/template-test/foo-bar.rb +16 -0
  34. data/lib/foobar_templates/templates/template-test/foo_bar/keep +0 -0
  35. data/lib/foobar_templates/templates/template-test/foobar.yml +2 -0
  36. data/lib/foobar_templates/templates/template-test/simple_dir/keep +0 -0
  37. data/lib/foobar_templates/templates/template-test/test_confirmed +0 -0
  38. data/lib/foobar_templates/templates/test_template/foo-bar/keep +0 -0
  39. data/lib/foobar_templates/templates/test_template/foo-bar.rb +21 -0
  40. data/lib/foobar_templates/templates/test_template/foo_bar/keep +0 -0
  41. data/lib/foobar_templates/templates/test_template/foobar.yml +2 -0
  42. data/lib/foobar_templates/templates/test_template/simple_dir/keep +0 -0
  43. data/lib/foobar_templates/version.rb +3 -0
  44. data/lib/foobar_templates.rb +151 -0
  45. data/spec/data/variable_manifest_test.rb +21 -0
  46. data/spec/foobar_templates/cli/dir_to_template_spec.rb +153 -0
  47. data/spec/foobar_templates/core/dir_to_template_spec.rb +104 -0
  48. data/spec/foobar_templates_spec.rb +573 -0
  49. data/spec/spec_helper.rb +106 -0
  50. data/spec/template_manager_spec.rb +68 -0
  51. metadata +157 -0
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ module FoobarTemplates
4
+ describe TemplateManager do
5
+
6
+ before :each do
7
+ @template_root = "#{ENV['HOME']}/.foobar/templates"
8
+ FileUtils.rm_rf(ENV['HOME'])
9
+ FileUtils.mkdir_p(@template_root)
10
+ end
11
+
12
+ def write_template_config(path, config_contents)
13
+ FileUtils.mkdir_p(path)
14
+ File.write("#{path}/foobar.yml", config_contents)
15
+ end
16
+
17
+ it '#get_template_src returns the template-test even if prefix is omitted' do
18
+ options = { bin: false, ext: false, coc: false, template: "test" }
19
+
20
+ output = TemplateManager.get_template_src(options)
21
+
22
+ expect(File.basename(output)).to eq "template-test"
23
+ end
24
+
25
+ it 'resolves a unique leaf template inside monorepo templates' do
26
+ write_template_config("#{@template_root}/template-platform", "monorepo: true\n")
27
+ write_template_config("#{@template_root}/template-platform/template-api", "category: services\n")
28
+
29
+ options = { bin: false, ext: false, coc: false, template: "api" }
30
+ output = TemplateManager.get_template_src(options)
31
+
32
+ expect(output).to end_with("template-platform/template-api")
33
+ end
34
+
35
+ it 'raises an ambiguity error for duplicate monorepo leaf names' do
36
+ write_template_config("#{@template_root}/template-platform-a", "monorepo: true\n")
37
+ write_template_config("#{@template_root}/template-platform-a/template-api", "category: services\n")
38
+ write_template_config("#{@template_root}/template-platform-b", "monorepo: true\n")
39
+ write_template_config("#{@template_root}/template-platform-b/template-api", "category: services\n")
40
+
41
+ options = { bin: false, ext: false, coc: false, template: "api" }
42
+
43
+ expect do
44
+ TemplateManager.get_template_src(options)
45
+ end.to raise_error(FoobarTemplates::CLIError, /Ambiguous template name 'api'/)
46
+ end
47
+
48
+ it 'raises a not-found error when monorepo leaf template does not exist' do
49
+ write_template_config("#{@template_root}/template-platform", "monorepo: true\n")
50
+ write_template_config("#{@template_root}/template-platform/template-api", "category: services\n")
51
+
52
+ options = { bin: false, ext: false, coc: false, template: "does-not-exist" }
53
+
54
+ expect do
55
+ TemplateManager.get_template_src(options)
56
+ end.to raise_error(FoobarTemplates::CLIError, /not found in monorepo leaf templates/)
57
+ end
58
+
59
+ it 'raises a CLIError when the template path does not exist' do
60
+ options = { bin: false, ext: false, coc: false, template: "does-not-exist" }
61
+
62
+ expect do
63
+ TemplateManager.get_template_src(options)
64
+ end.to raise_error(FoobarTemplates::CLIError, /could not be found/)
65
+ end
66
+
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foobar_templates
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - TheNotary
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2026-05-09 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '13.2'
19
+ type: :development
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '13.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rdoc
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '7.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.13'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.13'
54
+ - !ruby/object:Gem::Dependency
55
+ name: pry
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.16'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.16'
68
+ description: " This is a gem for making more gems! I know! It's like asking a genie
69
+ for more wishes but it actually works!"
70
+ email:
71
+ - no@mail.plz
72
+ executables:
73
+ - foobar_templates
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".beader/.gitignore"
78
+ - ".beader/issues/1-support-flexible-template-topologies.yaml"
79
+ - ".beader/issues/2-add-monorepo-support-for-template-discovery-and-generation.yaml"
80
+ - ".beader/issues/3-implement-monorepo-aware-recursive-template-inventory.yaml"
81
+ - ".beader/issues/4-add-leaf-template-selection-with-ambiguity-and-not-found-handling.yaml"
82
+ - ".beader/issues/5-integrate-leaf-template-resolution-into-generation-flow.yaml"
83
+ - ".beader/issues/6-add-monorepo-discovery-and-generation-test-coverage.yaml"
84
+ - ".beader/issues/7-document-monorepo-template-configuration-and-selection.yaml"
85
+ - ".beader/meta.yaml"
86
+ - ".gitignore"
87
+ - ".rspec"
88
+ - Gemfile
89
+ - LICENSE.txt
90
+ - README.md
91
+ - Rakefile
92
+ - bin/foobar_templates
93
+ - changelog
94
+ - config/config
95
+ - foobar_templates.gemspec
96
+ - lib/foobar_templates.rb
97
+ - lib/foobar_templates/cli/cheat_sheet.rb
98
+ - lib/foobar_templates/cli/cli.rb
99
+ - lib/foobar_templates/cli/dir_to_template.rb
100
+ - lib/foobar_templates/cli/setup_personal_templates_repo.rb
101
+ - lib/foobar_templates/cli/template_generator.rb
102
+ - lib/foobar_templates/configurator.rb
103
+ - lib/foobar_templates/core/core.rb
104
+ - lib/foobar_templates/core/dir_to_template.rb
105
+ - lib/foobar_templates/strings.rb
106
+ - lib/foobar_templates/template_manager.rb
107
+ - lib/foobar_templates/templates/template-test/.vscode/launch.json
108
+ - lib/foobar_templates/templates/template-test/foo-bar.rb
109
+ - lib/foobar_templates/templates/template-test/foo-bar/keep
110
+ - lib/foobar_templates/templates/template-test/foo_bar/keep
111
+ - lib/foobar_templates/templates/template-test/foobar.yml
112
+ - lib/foobar_templates/templates/template-test/simple_dir/keep
113
+ - lib/foobar_templates/templates/template-test/test_confirmed
114
+ - lib/foobar_templates/templates/test_template/foo-bar.rb
115
+ - lib/foobar_templates/templates/test_template/foo-bar/keep
116
+ - lib/foobar_templates/templates/test_template/foo_bar/keep
117
+ - lib/foobar_templates/templates/test_template/foobar.yml
118
+ - lib/foobar_templates/templates/test_template/simple_dir/keep
119
+ - lib/foobar_templates/version.rb
120
+ - spec/data/variable_manifest_test.rb
121
+ - spec/foobar_templates/cli/dir_to_template_spec.rb
122
+ - spec/foobar_templates/core/dir_to_template_spec.rb
123
+ - spec/foobar_templates_spec.rb
124
+ - spec/spec_helper.rb
125
+ - spec/template_manager_spec.rb
126
+ homepage: https://github.com/thenotary/foobar_templates
127
+ licenses:
128
+ - MIT
129
+ metadata:
130
+ bug_tracker_uri: https://github.com/TheNotary/foobar_templates/issues
131
+ changelog_uri: https://github.com/TheNotary/foobar_templates/releases/tag/v2.0.0
132
+ documentation_uri: https://github.com/TheNotary/foobar_templates
133
+ source_code_uri: https://github.com/TheNotary/foobar_templates/tree/v2.0.0
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '3.0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubygems_version: 3.6.2
149
+ specification_version: 4
150
+ summary: This gem makes more gems!
151
+ test_files:
152
+ - spec/data/variable_manifest_test.rb
153
+ - spec/foobar_templates/cli/dir_to_template_spec.rb
154
+ - spec/foobar_templates/core/dir_to_template_spec.rb
155
+ - spec/foobar_templates_spec.rb
156
+ - spec/spec_helper.rb
157
+ - spec/template_manager_spec.rb