Class: Slnky::Generator::Base
- Inherits:
-
Object
- Object
- Slnky::Generator::Base
- Defined in:
- lib/slnky/generator.rb
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(name, options = {}) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(name, options = {}) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/slnky/generator.rb', line 12 def initialize(name, ={}) = { force: false, }.merge() @name = name @service = "slnky-#{name}" @dir = File.("./#{@service}") short = self.class.name.split('::').last.downcase @template = File.("../template/#{short}", __FILE__) @force = [:force] end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
10 11 12 |
# File 'lib/slnky/generator.rb', line 10 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/slnky/generator.rb', line 9 def name @name end |
Instance Method Details
#generate ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/slnky/generator.rb', line 24 def generate say "<%= color('generating service #{@name}', BOLD) %>" # puts " from: #{@template}" # puts " to: #{@dir}" process_files # git init if File.directory?("#{@dir}/.git") puts "git already initialized" else puts "initializing git..." `cd #{@dir} && git init . || true` `cd #{@dir} && git add .` end end |