Class: Vsvipergen::ViperObjcViewControllerFileGenerator

Inherits:
Generator
  • Object
show all
Defined in:
lib/vsvipergen_view.rb

Overview

concrete class for VS<$filePrefix$>ViewController.h, VS<$filePrefix$>ViewController.m

Direct Known Subclasses

ViperAndroidPageFileGenerator

Instance Attribute Summary collapse

Attributes inherited from Generator

#currPath, #generatedFilePaths, #now, #prefix, #year

Instance Method Summary collapse

Instance Attribute Details

#modelPrefixObject

Returns the value of attribute modelPrefix.



7
8
9
# File 'lib/vsvipergen_view.rb', line 7

def modelPrefix
  @modelPrefix
end

Instance Method Details

#init(filePrefix, now, year, modelPrefix) ⇒ Object



8
9
10
11
# File 'lib/vsvipergen_view.rb', line 8

def init(filePrefix, now, year, modelPrefix)
  super(filePrefix, now, year)
  @modelPrefix = modelPrefix 
end

#makeFilesObject



13
14
15
16
17
18
19
20
# File 'lib/vsvipergen_view.rb', line 13

def makeFiles
  super

  makeHeaderFile
  makeImplementFile

  return generatedFilePaths
end

#makeHeaderFileObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/vsvipergen_view.rb', line 22

def makeHeaderFile
  subPath = currPath + "/view"
  Dir.mkdir(subPath) unless File.exists?(subPath)

  newHeaderFilePath = subPath + "/VS#{prefix.strip}ViewController.h"
  generatedFilePaths.push(newHeaderFilePath)

  templateHeaderFilePath = File.expand_path '../lib/templates/view/VS<$$>ViewController.h', File.dirname(__FILE__)

  templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
  templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
  templateHeaderFileContents.gsub! "<$now$>", now.strip
  templateHeaderFileContents.gsub! "<$year$>", year.strip
  templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip

  ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
end

#makeImplementFileObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vsvipergen_view.rb', line 40

def makeImplementFile
  subPath = currPath + "/view"
  Dir.mkdir(subPath) unless File.exists?(subPath)

  newImplementFilePath = subPath + "/VS#{prefix.strip}ViewController.m"
  generatedFilePaths.push(newImplementFilePath)

  templateImplementFilePath = File.expand_path '../lib/templates/view/VS<$$>ViewController.m', File.dirname(__FILE__)

  templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
  templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
  templateImplementFileContents.gsub! "<$now$>", now.strip
  templateImplementFileContents.gsub! "<$year$>", year.strip
  templateImplementFileContents.gsub! "<$prefix$>", prefix.strip

  ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
end