bundlegem 0.0.14 → 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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/bundlegem.gemspec +2 -0
  3. data/lib/bundlegem/cli/gem.rb +27 -21
  4. data/lib/bundlegem/templates/cli_gem/#{name}.gemspec.tt +20 -8
  5. data/lib/bundlegem/templates/cli_gem/LICENSE.txt.tt +2 -20
  6. data/lib/bundlegem/templates/cli_gem/README.md.tt +20 -21
  7. data/lib/bundlegem/templates/cli_gem/Rakefile.tt +27 -2
  8. data/lib/bundlegem/templates/cli_gem/exe/#{name}.tt +8 -1
  9. data/lib/bundlegem/templates/cli_gem/gitignore.tt +0 -1
  10. data/lib/bundlegem/templates/cli_gem/lib/#{name}/config.rb.tt +40 -0
  11. data/lib/bundlegem/templates/cli_gem/lib/#{name}/constants.rb.tt +9 -0
  12. data/lib/bundlegem/templates/cli_gem/lib/#{name}.rb.tt +18 -1
  13. data/lib/bundlegem/templates/cli_gem/spec/#{name}/config_spec.rb.tt +25 -0
  14. data/lib/bundlegem/templates/cli_gem/spec/#{name}_int.rb.tt +16 -0
  15. data/lib/bundlegem/templates/cli_gem/spec/#{name}_spec.rb.tt +12 -6
  16. data/lib/bundlegem/templates/cli_gem/spec/data/sample_data.json.tt +1 -0
  17. data/lib/bundlegem/templates/newgem/#{name}.gemspec.tt +8 -2
  18. data/lib/bundlegem/templates/newgem/Gemfile.tt +8 -2
  19. data/lib/bundlegem/templates/newgem/README.md.tt +2 -0
  20. data/lib/bundlegem/templates/test_template/#{name}/keep.tt +0 -0
  21. data/lib/bundlegem/templates/test_template/#{name}.rb.tt +11 -0
  22. data/lib/bundlegem/templates/test_template/#{underscored_name}/keep.tt +0 -0
  23. data/lib/bundlegem/templates/test_template/simple_dir/keep.tt +0 -0
  24. data/lib/bundlegem/version.rb +1 -1
  25. data/spec/bundlegem_spec.rb +32 -0
  26. data/spec/data/variable_manifest_test.rb +11 -0
  27. data/spec/spec_helper.rb +9 -6
  28. metadata +42 -8
  29. data/lib/bundlegem/templates/cli_gem/.travis.yml.tt +0 -3
  30. data/lib/bundlegem/templates/cli_gem/bin/#{name}.tt +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d25b0d1c8d8979da5e2f8354d8ee1ec927c103202a379ef5c02b221ab7f1f8aa
4
- data.tar.gz: 180774ef2a0cebab93940a880921ab59279d1d831f7d31c6daf9c0a8c4a4d4c9
3
+ metadata.gz: 34015a75f77131e223b18e6f07e0bbd28d9b392addc289a05bbd3c3a5e440819
4
+ data.tar.gz: bdbac3955fe9811fe31c1412f95af7f391f763bd18f54dec159ec0352a07dc67
5
5
  SHA512:
6
- metadata.gz: 6d8336a33e61ce573341936dbd8bd89586fd6302299c4d9111d0b50810ecdea01e668a6317344e0202c99fc423cc541db43f96afe5c8fbc351862ea7dbe9b2b1
7
- data.tar.gz: 2ef917281a2f763ef4f78976740e10402591f64c956e4d6c7d921dc05497094cb4b3a923f6cc850ea9b12cbba041dc194a30b61c3929b2e98f9c1f6519871782
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"
@@ -14,9 +14,7 @@ module Bundlegem
14
14
  validate_ext_name if options[:ext]
15
15
  end
16
16
 
17
- def run
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
- ensure_safe_gem_name(name, constant_array)
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(config)
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(config)
125
- #if options["template"].nil? # if it's doing some of the built in template
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
- raise_no_files_in_template_error! if templates.empty?
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
- return templates
139
- #end
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)
@@ -1,7 +1,5 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require '<%=config[:namespaced_path]%>/version'
2
+ require_relative 'lib/<%=config[:namespaced_path]%>/version'
5
3
 
6
4
  Gem::Specification.new do |spec|
7
5
  spec.name = <%=config[:name].inspect%>
@@ -9,12 +7,26 @@ Gem::Specification.new do |spec|
9
7
  spec.authors = [<%=config[:author].inspect%>]
10
8
  spec.email = [<%=config[:email].inspect%>]
11
9
 
12
- spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
13
- # spec.description = %q{TODO: delete this line since you're in a hurry.}
10
+ spec.summary = %q{A gem}
11
+
14
12
  spec.homepage = "https://github.com/<%=config[:author]%>/<%=config[:name]%>"
15
- # spec.license = "MIT" # uncomment and replace with GPLv3, etc.
13
+ spec.required_ruby_version = ">= 3.0.0"
14
+
15
+ spec.metadata["allowed_push_host"] = "https://localhost.com" # prevents unexpected data loss
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://localhost.com"
19
+ spec.metadata["changelog_uri"] = "https://localhost.com"
16
20
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ gemspec = File.basename(__FILE__)
24
+ spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
25
+ ls.readlines("\x0", chomp: true).reject do |f|
26
+ (f == gemspec) ||
27
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .gitlab-ci.yml appveyor Gemfile])
28
+ end
29
+ end
18
30
  spec.bindir = "exe"
19
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
32
  spec.require_paths = ["lib"]
@@ -22,7 +34,7 @@ Gem::Specification.new do |spec|
22
34
  # spec.add_dependency "bundler", "~> <%= config[:bundler_version] %>"
23
35
 
24
36
  spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>"
25
- spec.add_development_dependency "rake", "~> 10.0"
37
+ spec.add_development_dependency "rake", "~> 13.0"
26
38
  spec.add_development_dependency "rspec"
27
39
  spec.add_development_dependency "pry"
28
40
  end
@@ -1,21 +1,3 @@
1
- The MIT License (MIT)
1
+ TODO: Decide license and include here.
2
2
 
3
- Copyright (c) <%=Time.now.year%> <%=config[:author]%>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
3
+ If this message is visible, please open a GH issue and assume Copyright and closed source is the intent of this repo.
@@ -1,39 +1,38 @@
1
1
  # <%=config[:constant_name]%>
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%=config[:namespaced_path]%>`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ TODO: Describe your gem/ CLI tool
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
9
- Add this line to your application's Gemfile:
8
+ To install this from source, just run
10
9
 
11
- ```ruby
12
- gem '<%=config[:name]%>'
13
- ```
10
+ $ rake install
14
11
 
15
- And then execute:
16
12
 
17
- $ bundle
13
+ ## Usage
18
14
 
19
- Or install it yourself as:
15
+ As a cli, run `<%=config[:constant_name].downcase%>`
20
16
 
21
- $ gem install <%=config[:name]%>
22
17
 
23
- ## Usage
18
+ ## Development
24
19
 
25
- TODO: Write usage instructions here
20
+ Install dependencies with...
26
21
 
27
- ## Development
22
+ $ bundle
23
+
24
+ Mark individual tests with `, current: true` and run them with...
25
+
26
+ $ rake c
27
+
28
+ Run the entire unit test suite with...
29
+
30
+ $ rake
28
31
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.<% if config[:bin] %> Run `bundle exec <%= config[:name] %>` to use the code located in this directory, ignoring other installed copies of this gem.<% end %>
32
+ Run the integration test suite with...
30
33
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
34
+ $ rake integration
32
35
 
33
- ## Contributing
36
+ If a CLI is being developed, see `exe/<%=config[:constant_name].downcase%>` and consider adopting Thor or its alternatives if this will be a heavy CLI tool.
34
37
 
35
- 1. Fork it ( https://github.com/[my-github-username]/<%=config[:name]%>/fork )
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create a new Pull Request
38
+ For open source projects, releasing a new version is done with an update to the version number in `version.rb`. Then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). By default you'll need to tweak the gemspec file in root to enable pushes.
@@ -1,6 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "bundler/gem_tasks"
2
4
  require "rspec/core/rake_task"
3
5
 
4
- RSpec::Core::RakeTask.new(:spec)
6
+ RSpec::Core::RakeTask.new(:spec) do |t|
7
+ t.verbose = false
8
+ end
9
+
10
+ RSpec::Core::RakeTask.new(:integration) do |t|
11
+ t.verbose = false
12
+ t.pattern = "spec/**/*_int.rb"
13
+ end
14
+
15
+ # this is for running tests that you've marked current... eg: it 'should work', :current => true do
16
+ # I waffle between this work flow and the one defined in spec_helper.rb which uses focus: true
17
+ # which overrides the entire test suite... not better
18
+ RSpec::Core::RakeTask.new(:current) do |t|
19
+ t.verbose = false
20
+ t.pattern = 'spec/**/*_{spec,int}.rb'
21
+ t.rspec_opts = ['--tag current']
22
+ end
23
+
24
+ # alias for current
25
+ RSpec::Core::RakeTask.new(:c) do |t|
26
+ t.verbose = false
27
+ t.pattern = 'spec/**/*_{spec,int}.rb'
28
+ t.rspec_opts = ['--tag current']
29
+ end
5
30
 
6
- task :default => :spec
31
+ task default: :spec
@@ -2,4 +2,11 @@
2
2
 
3
3
  require "<%= config[:namespaced_path] %>"
4
4
 
5
- puts "I'm still just a stub cli ruby app"
5
+ command = ARGV.count > 0 ? ARGV[0].chomp.strip : ''
6
+
7
+ if command == "help" || command == "--help" || command == "-h"
8
+ puts <%= config[:constant_name] %>.help
9
+ return
10
+ end
11
+
12
+ puts <%= config[:constant_name] %>.main
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -0,0 +1,40 @@
1
+ <%- config[:constant_array].each_with_index do |c,i| -%>
2
+ <%= ' '*i %>module <%= c %>
3
+ <%- end -%>
4
+
5
+ class Config
6
+
7
+ def initialize(c = {})
8
+ @root_folder = c[:root_folder]
9
+ @config_file = c[:config_file]
10
+ @database_url = c[:database_url]
11
+ end
12
+
13
+ def root_folder
14
+ @root_folder ||= gather_parameters('ROOT_FOLDER')
15
+ end
16
+
17
+ def config_file
18
+ @config_file ||= gather_parameters('CONFIG_FILE')
19
+ end
20
+
21
+ def database_url
22
+ @database_url ||= gather_parameters('DATABASE_URL')
23
+ end
24
+
25
+ # private
26
+
27
+ def gather_parameters(param_name)
28
+ ENV["<%=config[:constant_name].upcase%>_#{param_name.upcase}"] || default_constant_or_nil(param_name)
29
+ end
30
+
31
+ def default_constant_or_nil(param_name)
32
+ const_name = 'DEFAULT_' + param_name
33
+ root_module = Module.nesting.last
34
+ root_module.const_get(const_name) if root_module.const_defined?(const_name)
35
+ end
36
+ end
37
+
38
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
39
+ <%= ' '*i %>end
40
+ <%- end -%>
@@ -0,0 +1,9 @@
1
+ <%- config[:constant_array].each_with_index do |c,i| -%>
2
+ <%= ' '*i %>module <%= c %>
3
+ <%- end -%>
4
+ DEFAULT_ROOT_FOLDER = '..'
5
+ DEFAULT_CONFIG_FILE = '../env.yaml'
6
+ DEFAULT_DATABASE_URL = '..'
7
+ <%- (config[:constant_array].size-1).downto(0) do |i| -%>
8
+ <%= ' '*i %>end
9
+ <%- end -%>
@@ -1,9 +1,26 @@
1
1
  require "<%=config[:namespaced_path]%>/version"
2
+ require "<%=config[:namespaced_path]%>/constants"
3
+ require "<%=config[:namespaced_path]%>/config"
4
+
2
5
 
3
6
  <%- config[:constant_array].each_with_index do |c,i| -%>
4
7
  <%= ' '*i %>module <%= c %>
5
8
  <%- end -%>
6
- <%= ' '*config[:constant_array].size %># Your code goes here...
9
+ # Your code goes here...
10
+ def self.main
11
+ "test"
12
+ end
13
+
14
+ def self.help
15
+ msg = <<-EOF
16
+ <%=config[:constant_name].downcase%>
17
+ TODO: Update this to be correct to this tool!
18
+ Commands:
19
+ ls - List things
20
+ run - Run things
21
+ status - Show status
22
+ EOF
23
+ end
7
24
  <%- (config[:constant_array].size-1).downto(0) do |i| -%>
8
25
  <%= ' '*i %>end
9
26
  <%- end -%>
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module <%= config[:constant_name] %>
4
+
5
+ describe Config do
6
+
7
+ before :each do
8
+ ENV['<%= config[:constant_name].upcase %>_ROOT_FOLDER'] = nil
9
+ end
10
+
11
+ after :each do
12
+ ENV['<%= config[:constant_name].upcase %>_ROOT_FOLDER'] = nil
13
+ end
14
+
15
+ it 'returns the ROOT_FOLDER set by the environment variable' do
16
+ ENV['<%= config[:constant_name].upcase %>_ROOT_FOLDER'] = "/tmp/blah"
17
+
18
+ c = Config.new
19
+
20
+ expect(c.root_folder).to eq("/tmp/blah")
21
+ end
22
+
23
+ end
24
+
25
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+
4
+ # This file ends in _int because it's an integration test and can use the file
5
+ # system and network to assert the applications correctness
6
+
7
+ module <%= config[:constant_name] %>
8
+
9
+ describe <%= config[:constant_name] %> do
10
+ it 'does something useful' do
11
+ result = <%= config[:constant_name] %>.main
12
+ expect(result).to eq("test")
13
+ end
14
+ end
15
+
16
+ end
@@ -1,11 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe <%= config[:constant_name] %> do
4
- it 'has a version number' do
5
- expect(<%= config[:constant_name] %>::VERSION).not_to be nil
6
- end
7
3
 
8
- it 'does something useful' do
9
- expect(false).to eq(true)
4
+ module <%= config[:constant_name] %>
5
+
6
+ describe <%= config[:constant_name] %> do
7
+ it 'has a version number' do
8
+ expect(<%= config[:constant_name] %>::VERSION).not_to be nil
9
+ end
10
+
11
+ it 'does something useful', current: true do
12
+ result = <%= config[:constant_name] %>.main
13
+ expect(result).to eq("test")
14
+ end
10
15
  end
16
+
11
17
  end
@@ -0,0 +1 @@
1
+ { "I'm some sample data": "used in a test" }
@@ -9,10 +9,16 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = [<%=config[:author].inspect%>]
10
10
  spec.email = [<%=config[:email].inspect%>]
11
11
 
12
- spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
12
+ spec.summary = %q{Write a short summary, because Rubygems requires one.}
13
13
  # spec.description = %q{TODO: delete this line since you're in a hurry.}
14
14
  spec.homepage = "https://github.com/<%=config[:author]%>/<%=config[:name]%>"
15
- # spec.license = "MIT" # uncomment this line if MIT is the best license for your situation
15
+ spec.required_ruby_version = ">= 3.0.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://localhost.com" # prevents unexpected data loss
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://localhost.com"
21
+ spec.metadata["changelog_uri"] = "https://localhost.com"
16
22
 
17
23
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
24
  spec.bindir = "exe"
@@ -1,4 +1,10 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- # Specify your gem's dependencies in <%=config[:name]%>.gemspec
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in blah.gemspec
4
6
  gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
@@ -1,5 +1,7 @@
1
1
  # <%=config[:constant_name]%>
2
2
 
3
+ NOTE: I'm tempted to deprecate this in favor of `cli_gem`. I'm going to make updates to that exclusively in the meantime.
4
+
3
5
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%=config[:namespaced_path]%>`. To experiment with that code, run `bin/console` for an interactive prompt.
4
6
 
5
7
  TODO: Delete this and the text above, and describe your gem
@@ -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] %>
@@ -1,3 +1,3 @@
1
1
  module Bundlegem
2
- VERSION = "0.0.14"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -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
- auth_settings = 'git config --local user.email "you@example.com" && git config --local user.name "test"'
20
- `cd "#{ENV['HOME']}/arduino.git" && git init && git add . && #{auth_settings} && git commit -m "haxing"`
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.14
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: 2024-04-02 00:00:00.000000000 Z
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
@@ -129,13 +156,11 @@ files:
129
156
  - lib/bundlegem/templates/c_extension_gem/spec/#{name}_spec.rb.tt
130
157
  - lib/bundlegem/templates/c_extension_gem/spec/spec_helper.rb.tt
131
158
  - lib/bundlegem/templates/cli_gem/#{name}.gemspec.tt
132
- - lib/bundlegem/templates/cli_gem/.travis.yml.tt
133
159
  - lib/bundlegem/templates/cli_gem/CODE_OF_CONDUCT.md.tt
134
160
  - lib/bundlegem/templates/cli_gem/Gemfile.tt
135
161
  - lib/bundlegem/templates/cli_gem/LICENSE.txt.tt
136
162
  - lib/bundlegem/templates/cli_gem/README.md.tt
137
163
  - lib/bundlegem/templates/cli_gem/Rakefile.tt
138
- - lib/bundlegem/templates/cli_gem/bin/#{name}.tt
139
164
  - lib/bundlegem/templates/cli_gem/bin/console.tt
140
165
  - lib/bundlegem/templates/cli_gem/changelog.tt
141
166
  - lib/bundlegem/templates/cli_gem/exe/#{name}.tt
@@ -144,9 +169,14 @@ files:
144
169
  - lib/bundlegem/templates/cli_gem/ext/#{name}/extconf.rb.tt
145
170
  - lib/bundlegem/templates/cli_gem/gitignore.tt
146
171
  - lib/bundlegem/templates/cli_gem/lib/#{name}.rb.tt
172
+ - lib/bundlegem/templates/cli_gem/lib/#{name}/config.rb.tt
173
+ - lib/bundlegem/templates/cli_gem/lib/#{name}/constants.rb.tt
147
174
  - lib/bundlegem/templates/cli_gem/lib/#{name}/version.rb.tt
148
175
  - lib/bundlegem/templates/cli_gem/rspec.tt
176
+ - lib/bundlegem/templates/cli_gem/spec/#{name}/config_spec.rb.tt
177
+ - lib/bundlegem/templates/cli_gem/spec/#{name}_int.rb.tt
149
178
  - lib/bundlegem/templates/cli_gem/spec/#{name}_spec.rb.tt
179
+ - lib/bundlegem/templates/cli_gem/spec/data/sample_data.json.tt
150
180
  - lib/bundlegem/templates/cli_gem/spec/spec_helper.rb.tt
151
181
  - lib/bundlegem/templates/newgem/#{name}.gemspec.tt
152
182
  - lib/bundlegem/templates/newgem/.gitignore.tt
@@ -164,14 +194,18 @@ files:
164
194
  - lib/bundlegem/templates/newgem/rspec.tt
165
195
  - lib/bundlegem/templates/newgem/spec/#{name}_spec.rb.tt
166
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
167
201
  - lib/bundlegem/version.rb
168
202
  - spec/bundlegem_spec.rb
203
+ - spec/data/variable_manifest_test.rb
169
204
  - spec/spec_helper.rb
170
205
  homepage: ''
171
206
  licenses:
172
207
  - MIT
173
208
  metadata: {}
174
- post_install_message:
175
209
  rdoc_options: []
176
210
  require_paths:
177
211
  - lib
@@ -186,10 +220,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
220
  - !ruby/object:Gem::Version
187
221
  version: '0'
188
222
  requirements: []
189
- rubygems_version: 3.5.7
190
- signing_key:
223
+ rubygems_version: 3.6.2
191
224
  specification_version: 4
192
225
  summary: this gem makes more gems!
193
226
  test_files:
194
227
  - spec/bundlegem_spec.rb
228
+ - spec/data/variable_manifest_test.rb
195
229
  - spec/spec_helper.rb
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - <%= RUBY_VERSION %>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "<%= config[:namespaced_path] %>"