Class: Slnky::Generator::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/slnky/generator.rb

Direct Known Subclasses

Command, Service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/slnky/generator.rb', line 11

def initialize(name)
  @name = name
  @dir = File.expand_path("slnky-#{name}")
  short = self.class.name.split('::').last.downcase
  @template = File.expand_path("../template/#{short}", __FILE__)
end

Instance Attribute Details

#dirObject (readonly)

Returns the value of attribute dir.



9
10
11
# File 'lib/slnky/generator.rb', line 9

def dir
  @dir
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/slnky/generator.rb', line 8

def name
  @name
end

Instance Method Details

#generateObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/slnky/generator.rb', line 18

def generate
  puts "generating service #{@name}:"
  puts "  from: #{@template}"
  puts "  to:   #{@dir}"
  process_files
  # make service executable
  `chmod 755 #{@dir}/service-slnky-#{@name}`
  # git init
  puts "initializing git..."
  `cd #{@dir} && git init . || true`
  `cd #{@dir} && git add .`
end