Class: GemMine::Scaffold
- Inherits:
-
Object
- Object
- GemMine::Scaffold
- Defined in:
- lib/gem_mine.rb
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 ⇒ Object
readonly
Returns the value of attribute author.
-
#gem_home ⇒ Object
readonly
Returns the value of attribute gem_home.
-
#homepage ⇒ Object
readonly
Returns the value of attribute homepage.
-
#license ⇒ Object
readonly
Returns the value of attribute license.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required_ruby_version ⇒ Object
readonly
Returns the value of attribute required_ruby_version.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #build ⇒ Object
- #built_gem_file ⇒ Object
- #built_gem_path ⇒ Object
- #clean ⇒ Object
- #create ⇒ Object
- #gemspec_file ⇒ Object
- #gemspec_path ⇒ Object
-
#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 ⇒ Object
- #install ⇒ Object
- #lib_file ⇒ Object
- #lib_path ⇒ Object
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.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gem_mine.rb', line 46 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 ⇒ Object (readonly)
Returns the value of attribute author.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def @author end |
#gem_home ⇒ Object (readonly)
Returns the value of attribute gem_home.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def gem_home @gem_home end |
#homepage ⇒ Object (readonly)
Returns the value of attribute homepage.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def homepage @homepage end |
#license ⇒ Object (readonly)
Returns the value of attribute license.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def license @license end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def name @name end |
#required_ruby_version ⇒ Object (readonly)
Returns the value of attribute required_ruby_version.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def required_ruby_version @required_ruby_version end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def root @root end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def summary @summary end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
36 37 38 |
# File 'lib/gem_mine.rb', line 36 def version @version end |
Instance Method Details
#build ⇒ Object
77 78 79 80 81 |
# File 'lib/gem_mine.rb', line 77 def build create unless File.file?(gemspec_path) run("gem", "build", gemspec_file, chdir: root) self end |
#built_gem_file ⇒ Object
120 121 122 |
# File 'lib/gem_mine.rb', line 120 def built_gem_file "#{name}-#{version}.gem" end |
#built_gem_path ⇒ Object
124 125 126 |
# File 'lib/gem_mine.rb', line 124 def built_gem_path File.join(root, built_gem_file) end |
#clean ⇒ Object
99 100 101 102 |
# File 'lib/gem_mine.rb', line 99 def clean FileUtils.rm_rf(root) self end |
#create ⇒ Object
70 71 72 73 74 75 |
# File 'lib/gem_mine.rb', line 70 def create FileUtils.mkdir_p(lib_dir) write_gemspec write_lib_file self end |
#gemspec_file ⇒ Object
112 113 114 |
# File 'lib/gem_mine.rb', line 112 def gemspec_file "#{name}.gemspec" end |
#gemspec_path ⇒ Object
116 117 118 |
# File 'lib/gem_mine.rb', line 116 def gemspec_path File.join(root, gemspec_file) end |
#initialize_git ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/gem_mine.rb', line 89 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 ⇒ Object
83 84 85 86 87 |
# File 'lib/gem_mine.rb', line 83 def install build unless File.file?(built_gem_path) run(*install_command, chdir: root, env: gem_home_env) self end |
#lib_file ⇒ Object
104 105 106 |
# File 'lib/gem_mine.rb', line 104 def lib_file File.join("lib", "#{name}.rb") end |
#lib_path ⇒ Object
108 109 110 |
# File 'lib/gem_mine.rb', line 108 def lib_path File.join(root, lib_file) end |