Class: Liquigen::Scaffold::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/liquigen/scaffold/base.rb

Direct Known Subclasses

Controller, Entity, Repository, Schema

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, props) ⇒ Base

Returns a new instance of Base.



6
7
8
9
# File 'lib/liquigen/scaffold/base.rb', line 6

def initialize(name, props)
  self.name = name
  self.props = props
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/liquigen/scaffold/base.rb', line 3

def name
  @name
end

#propsObject

Returns the value of attribute props.



4
5
6
# File 'lib/liquigen/scaffold/base.rb', line 4

def props
  @props
end

Instance Method Details

#class_linesObject



54
55
56
# File 'lib/liquigen/scaffold/base.rb', line 54

def class_lines
  []
end

#current_packageObject



29
30
31
# File 'lib/liquigen/scaffold/base.rb', line 29

def current_package
  Liquigen.package_name
end

#directoryObject



33
34
35
# File 'lib/liquigen/scaffold/base.rb', line 33

def directory
  "#{Liquigen.java_codes_root}/#{current_package.split('.').join('/')}"
end

#file_appendObject



41
42
43
# File 'lib/liquigen/scaffold/base.rb', line 41

def file_append
  ''
end

#file_nameObject



37
38
39
# File 'lib/liquigen/scaffold/base.rb', line 37

def file_name
  "#{name.singularize.camelize}#{file_append}.java"
end

#import_linesObject



50
51
52
# File 'lib/liquigen/scaffold/base.rb', line 50

def import_lines
  []
end

#methods_linesObject



58
59
60
# File 'lib/liquigen/scaffold/base.rb', line 58

def methods_lines
  []
end

#processObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/liquigen/scaffold/base.rb', line 11

def process
  file = "#{directory}/#{file_name}"
  return if File.exist? file

  lines = []
  lines += import_lines
  lines += []
  lines += class_lines
  lines += []
  lines += methods_lines
  lines += ['}']
  lines += ['']

  File.open(file, 'w') do |f|
    f.write lines.join("\n")
  end
end

#write_lines(file, lines = []) ⇒ Object



45
46
47
48
# File 'lib/liquigen/scaffold/base.rb', line 45

def write_lines(file, lines = [])
  file.write lines.join("\n")
  file.write("\n")
end