class GemGenerator::Command

Main CLI command for Gem Generator

Main CLI command for Gem Generator

Main CLI command for Gem Generator

Public Instance Methods

execute() click to toggle source
# File lib/gem_generator/command.rb, line 21
def execute
        check_target_directory

        ## Prevent error like '"FIXME" or "TODO" is not a description' for `bundle install`
        @summary = ask_for_summary

        refine_template_parameter if git?

        process_files

        install_dependencies

        initialize_git

        FileUtils.rm_r @git_tmp_dir if git?

        done
end

Private Instance Methods

ask_for_summary() click to toggle source
# File lib/gem_generator/command.rb, line 42
                def ask_for_summary
                        require 'readline'

                        puts 'Please, write a summary for the gem:'

                        result = Readline.readline('> ', true)

                        puts <<~TEXT

                                Thank you! You can write more detailed description later for `spec.description` and `README.md`.

                        TEXT

                        ## Give a time to read the hint about description
                        # sleep 3

                        result
                end
install_dependencies() click to toggle source
# File lib/gem_generator/command.rb, line 61
def install_dependencies
        puts 'Installing dependencies...'

        Dir.chdir name do
                ## Helpful for specs of templates, probably somewhere else
                Bundler.with_unbundled_env do
                        system 'bundle update'
                end

                system 'npm install' if File.exist? 'package.json'
        end
end