Class: GemMine::Scaffold
- Inherits:
-
Object
- Object
- GemMine::Scaffold
- Defined in:
- lib/gem_mine.rb,
sig/gem_mine.rbs
Constant Summary collapse
- DEFAULT_AUTHOR =
"Mr. Smith"- DEFAULT_GIT_USER_EMAIL =
"gem_mine@appraisal-rb.local"- DEFAULT_GIT_USER_NAME =
"GemMine"- DEFAULT_HOMEPAGE_BASE =
"https://github.com/appraisal-rb"- DEFAULT_LICENSE =
"MIT"- DEFAULT_REQUIRED_RUBY_VERSION =
">= 1.8.7"- DEFAULT_SUMMARY =
"summary"- DEFAULT_VERSION =
"1.0.0"
Instance Attribute Summary collapse
-
#author ⇒ String
readonly
Returns the value of attribute author.
-
#gem_home ⇒ String?
readonly
Returns the value of attribute gem_home.
-
#homepage ⇒ String
readonly
Returns the value of attribute homepage.
-
#license ⇒ String
readonly
Returns the value of attribute license.
-
#name ⇒ String
readonly
Returns the value of attribute name.
-
#required_ruby_version ⇒ String
readonly
Returns the value of attribute required_ruby_version.
-
#root ⇒ String
readonly
Returns the value of attribute root.
-
#summary ⇒ String
readonly
Returns the value of attribute summary.
-
#version ⇒ String
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #build ⇒ self
- #built_gem_file ⇒ String
- #built_gem_path ⇒ String
- #clean ⇒ self
- #create ⇒ self
- #gemspec_file ⇒ String
- #gemspec_path ⇒ String
-
#initialize(name, root:, version: DEFAULT_VERSION, gem_home: nil, author: DEFAULT_AUTHOR, summary: DEFAULT_SUMMARY, license: DEFAULT_LICENSE, homepage: nil, required_ruby_version: DEFAULT_REQUIRED_RUBY_VERSION, verbose: false) ⇒ Scaffold
constructor
A new instance of Scaffold.
- #initialize_git ⇒ self
- #install ⇒ self
- #lib_file ⇒ String
- #lib_path ⇒ String
Constructor Details
#initialize(name, root:, version: DEFAULT_VERSION, gem_home: nil, author: DEFAULT_AUTHOR, summary: DEFAULT_SUMMARY, license: DEFAULT_LICENSE, homepage: nil, required_ruby_version: DEFAULT_REQUIRED_RUBY_VERSION, verbose: false) ⇒ Scaffold
Returns a new instance of Scaffold.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gem_mine.rb', line 47 def initialize( name, root:, version: DEFAULT_VERSION, gem_home: nil, author: DEFAULT_AUTHOR, summary: DEFAULT_SUMMARY, license: DEFAULT_LICENSE, homepage: nil, required_ruby_version: DEFAULT_REQUIRED_RUBY_VERSION, verbose: false ) @name = name.to_s @version = version.to_s @root = File.(root) @gem_home = gem_home && File.(gem_home) @author = @summary = summary @license = license @homepage = homepage || "#{DEFAULT_HOMEPAGE_BASE}/#{@name}" @required_ruby_version = required_ruby_version @verbose = verbose end |
Instance Attribute Details
#author ⇒ String (readonly)
Returns the value of attribute author.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def @author end |
#gem_home ⇒ String? (readonly)
Returns the value of attribute gem_home.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def gem_home @gem_home end |
#homepage ⇒ String (readonly)
Returns the value of attribute homepage.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def homepage @homepage end |
#license ⇒ String (readonly)
Returns the value of attribute license.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def license @license end |
#name ⇒ String (readonly)
Returns the value of attribute name.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def name @name end |
#required_ruby_version ⇒ String (readonly)
Returns the value of attribute required_ruby_version.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def required_ruby_version @required_ruby_version end |
#root ⇒ String (readonly)
Returns the value of attribute root.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def root @root end |
#summary ⇒ String (readonly)
Returns the value of attribute summary.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def summary @summary end |
#version ⇒ String (readonly)
Returns the value of attribute version.
37 38 39 |
# File 'lib/gem_mine.rb', line 37 def version @version end |
Instance Method Details
#build ⇒ self
78 79 80 81 82 |
# File 'lib/gem_mine.rb', line 78 def build create unless File.file?(gemspec_path) run("gem", "build", gemspec_file, chdir: root) self end |
#built_gem_file ⇒ String
121 122 123 |
# File 'lib/gem_mine.rb', line 121 def built_gem_file "#{name}-#{version}.gem" end |
#built_gem_path ⇒ String
125 126 127 |
# File 'lib/gem_mine.rb', line 125 def built_gem_path File.join(root, built_gem_file) end |
#clean ⇒ self
100 101 102 103 |
# File 'lib/gem_mine.rb', line 100 def clean FileUtils.rm_rf(root) self end |
#create ⇒ self
71 72 73 74 75 76 |
# File 'lib/gem_mine.rb', line 71 def create FileUtils.mkdir_p(lib_dir) write_gemspec write_lib_file self end |
#gemspec_file ⇒ String
113 114 115 |
# File 'lib/gem_mine.rb', line 113 def gemspec_file "#{name}.gemspec" end |
#gemspec_path ⇒ String
117 118 119 |
# File 'lib/gem_mine.rb', line 117 def gemspec_path File.join(root, gemspec_file) end |
#initialize_git ⇒ self
90 91 92 93 94 95 96 97 98 |
# File 'lib/gem_mine.rb', line 90 def initialize_git create unless File.file?(gemspec_path) run("git", "init", ".", "--initial-branch=main", chdir: root) run("git", "config", "user.email", DEFAULT_GIT_USER_EMAIL, chdir: root) run("git", "config", "user.name", DEFAULT_GIT_USER_NAME, chdir: root) run("git", "add", ".", chdir: root) run("git", "commit", "--all", "--no-verify", "--message", "initial commit", chdir: root) self end |
#install ⇒ self
84 85 86 87 88 |
# File 'lib/gem_mine.rb', line 84 def install build unless File.file?(built_gem_path) run(*install_command, chdir: root, env: gem_home_env) self end |
#lib_file ⇒ String
105 106 107 |
# File 'lib/gem_mine.rb', line 105 def lib_file File.join("lib", "#{name}.rb") end |
#lib_path ⇒ String
109 110 111 |
# File 'lib/gem_mine.rb', line 109 def lib_path File.join(root, lib_file) end |