Class: Gemsmith::CLI
- Inherits:
-
Thor
- Object
- Thor
- Gemsmith::CLI
- Includes:
- Helpers::CLI, Helpers::Template, Thor::Actions, ThorPlus::Actions
- Defined in:
- lib/gemsmith/cli.rb
Overview
The Command Line Interface (CLI) for the gem. rubocop:disable Metrics/ClassLength
Class Method Summary collapse
-
.configuration ⇒ Object
rubocop:disable Metrics/MethodLength.
- .generators ⇒ Object
-
.source_root ⇒ Object
Overwrites Thor’s template source root.
Instance Method Summary collapse
- #config ⇒ Object
-
#generate(name) ⇒ Object
rubocop:disable Metrics/AbcSize.
- #help(task = nil) ⇒ Object
-
#initialize(args = [], options = {}, config = {}) ⇒ CLI
constructor
Initialize.
- #open(name) ⇒ Object
- #read(name) ⇒ Object
- #version ⇒ Object
Methods included from Helpers::Template
#gem_class, #gem_name, #gem_path, #rails_version, #render_namespace
Methods included from Helpers::CLI
inspect_gem, pick_gem, print_gems, process_gem
Constructor Details
#initialize(args = [], options = {}, config = {}) ⇒ CLI
Initialize.
102 103 104 105 |
# File 'lib/gemsmith/cli.rb', line 102 def initialize args = [], = {}, config = {} super args, , config @configuration = {} end |
Class Method Details
.configuration ⇒ Object
rubocop:disable Metrics/MethodLength
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gemsmith/cli.rb', line 32 def self.configuration Runcom::Configuration.new file_name: Identity.file_name, defaults: { year: Time.now.year, github_user: Git.github_user, gem: { name: "undefined", path: "undefined", class: "Undefined", platform: "Gem::Platform::RUBY", url: Git.github_url("undefined"), license: "MIT" }, author: { name: Git.config_value("user.name"), email: Git.config_value("user.email"), url: "" }, organization: { name: "", url: "" }, versions: { ruby: RUBY_VERSION, rails: "5.0" }, generate: { cli: false, rails: false, security: true, pry: true, guard: true, rspec: true, reek: true, rubocop: true, scss_lint: false, git_hub: false, code_climate: false, gemnasium: false, travis: false, patreon: false }, publish: { sign: false } } end |
.generators ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/gemsmith/cli.rb', line 79 def self.generators [ Generators::Gem, Generators::Documentation, Generators::Rake, Generators::CLI, Generators::Ruby, Generators::Rails, Generators::Rspec, Generators::Reek, Generators::Rubocop, Generators::SCSSLint, Generators::CodeClimate, Generators::Guard, Generators::Travis, Generators::Bundler, Generators::GitHub, Generators::Pragma, Generators::Git ] end |
.source_root ⇒ Object
Overwrites Thor’s template source root.
27 28 29 |
# File 'lib/gemsmith/cli.rb', line 27 def self.source_root File. File.join(File.dirname(__FILE__), "templates") end |
Instance Method Details
#config ⇒ Object
199 200 201 202 203 204 205 206 |
# File 'lib/gemsmith/cli.rb', line 199 def config path = self.class.configuration.computed_path if .edit? then `#{editor} #{path}` elsif .info? then say(path) else help(:config) end end |
#generate(name) ⇒ Object
rubocop:disable Metrics/AbcSize
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/gemsmith/cli.rb', line 166 def generate name print_cli_and_rails_engine_option_error && return if .cli? && .rails? info "Generating gem..." setup_configuration name: name, options: .to_h self.class.generators.each { |generator| generator.run self, configuration: configuration } info "Gem generation finished." end |
#help(task = nil) ⇒ Object
216 217 218 |
# File 'lib/gemsmith/cli.rb', line 216 def help task = nil say and super end |
#open(name) ⇒ Object
179 180 181 |
# File 'lib/gemsmith/cli.rb', line 179 def open name process_gem name, "edit" end |
#read(name) ⇒ Object
185 186 187 |
# File 'lib/gemsmith/cli.rb', line 185 def read name error "Gem home page is not defined." unless process_gem(name, "visit") end |
#version ⇒ Object
210 211 212 |
# File 'lib/gemsmith/cli.rb', line 210 def version say Identity.version_label end |