Class: Dopstick::Generator::Gem::Generator
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Dopstick::Generator::Gem::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/dopstick/generator/gem/generator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #bundle_install ⇒ Object
- #copy_active_record_files ⇒ Object
- #copy_binary_files ⇒ Object
- #copy_bins ⇒ Object
- #copy_generic_templates ⇒ Object
- #copy_github_templates ⇒ Object
- #copy_ruby_templates ⇒ Object
- #copy_test_files ⇒ Object
- #create_entry_file ⇒ Object
- #create_version_file ⇒ Object
- #initialize_repo ⇒ Object
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/dopstick/generator/gem/generator.rb', line 12 def @options end |
Class Method Details
.exit_on_failure? ⇒ Boolean
16 17 18 |
# File 'lib/dopstick/generator/gem/generator.rb', line 16 def self.exit_on_failure? true end |
.source_paths ⇒ Object
20 21 22 23 24 25 |
# File 'lib/dopstick/generator/gem/generator.rb', line 20 def self.source_paths [ source_root, File.join(__dir__, "../base/templates") ] end |
.source_root ⇒ Object
27 28 29 |
# File 'lib/dopstick/generator/gem/generator.rb', line 27 def self.source_root File.join(__dir__, "templates") end |
Instance Method Details
#bundle_install ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/dopstick/generator/gem/generator.rb', line 99 def bundle_install return if .skip_install? in_root do run "bundle install" end end |
#copy_active_record_files ⇒ Object
93 94 95 96 97 |
# File 'lib/dopstick/generator/gem/generator.rb', line 93 def copy_active_record_files return unless [:active_record] template "active_record.erb", "test/support/active_record.rb" end |
#copy_binary_files ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/dopstick/generator/gem/generator.rb', line 83 def copy_binary_files return unless .bin? template "cli.erb", "lib/#{.entry_path}/cli.rb" template "generator.erb", "lib/#{.entry_path}/generator.rb" template "bin.erb", "exe/#{.bin}" create_file "lib/#{.entry_path}/templates/.keep" in_root { run "chmod +x exe/*" } end |
#copy_bins ⇒ Object
60 61 62 63 64 |
# File 'lib/dopstick/generator/gem/generator.rb', line 60 def copy_bins template "console.erb", "bin/console" template "setup.erb", "bin/setup" in_root { run "chmod +x bin/*" } end |
#copy_generic_templates ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/dopstick/generator/gem/generator.rb', line 39 def copy_generic_templates template "license.erb", "LICENSE.md" template "coc.erb", "CODE_OF_CONDUCT.md" template "readme.erb", "README.md" template "changelog.erb", "CHANGELOG.md" template "contributing.erb", "CONTRIBUTING.md" template "gitignore.erb", ".gitignore" end |
#copy_github_templates ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/dopstick/generator/gem/generator.rb', line 48 def copy_github_templates template "funding.erb", ".github/FUNDING.yml" template "bug_report.erb", ".github/ISSUE_TEMPLATE/bug_report.md" template "feature_request.erb", ".github/ISSUE_TEMPLATE/feature_request.md" template "pull_request.erb", ".github/PULL_REQUEST_TEMPLATE.md" template "issue_template_config.erb", ".github/ISSUE_TEMPLATE/config.yml" template "dependabot.erb", ".github/dependabot.yml" template "codeowners.erb", ".github/CODEOWNERS" end |
#copy_ruby_templates ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/dopstick/generator/gem/generator.rb', line 31 def copy_ruby_templates template "gemspec.erb", "#{.package_name}.gemspec" template "rakefile.erb", "Rakefile" template "rubocop.erb", ".rubocop.yml" template "gemfile.erb", "Gemfile" template "tests_workflow.erb", ".github/workflows/ruby-tests.yml" end |
#copy_test_files ⇒ Object
78 79 80 81 |
# File 'lib/dopstick/generator/gem/generator.rb', line 78 def copy_test_files template "test_helper.erb", "test/test_helper.rb" template "test_file.erb", "test/#{.entry_path}_test.rb" end |
#create_entry_file ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/dopstick/generator/gem/generator.rb', line 66 def create_entry_file if .entry_path.include?("/") template "gem_entry_file.erb", "lib/#{.package_name}.rb" end template "entry_file.erb", "lib/#{.entry_path}.rb" end |
#create_version_file ⇒ Object
74 75 76 |
# File 'lib/dopstick/generator/gem/generator.rb', line 74 def create_version_file template "version.erb", "lib/#{.entry_path}/version.rb" end |
#initialize_repo ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/dopstick/generator/gem/generator.rb', line 107 def initialize_repo in_root do run "git init --initial-branch=main", capture: true run "git add bin --force", capture: true run "git add .", capture: true end end |