vsvipergen 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Created by Vendys on <$now$>..
3
+ */
4
+
5
+ public class VS<$prefix$>Page extends FlipperPage implements VS<$prefix$>Constracts.I<$prefix$>ViewForPresenter {
6
+
7
+ public VS<$prefix$>Constracts.I<$prefix$>PresenterForView presenter;
8
+
9
+ public VS<$prefix$>Page(Context ac) {
10
+ }
11
+
12
+ @Override
13
+ public void onResumePage() {
14
+ }
15
+
16
+ @Override
17
+ public void onFlipAfter() {
18
+ super.onFlipAfter();
19
+ this.presenter.initialize();
20
+ }
21
+ }
@@ -0,0 +1,14 @@
1
+ //
2
+ // VS<$modelPrefix$>VO.h
3
+ // VLunch
4
+ //
5
+ // Created by vendys on <$now$>..
6
+ // Copyright © <$year$>년 Vendys. All rights reserved.
7
+ //
8
+
9
+ #import <UIKit/UIKit.h>
10
+ #import "VS<$prefix$>Contracts.h"
11
+
12
+ @interface VS<$prefix$>ViewController : UIViewController <I<$prefix$>ViewForPresenter>
13
+ @property (nonatomic, weak) id<I<$prefix$>PresenterForView> presenter;
14
+ @end
@@ -0,0 +1,25 @@
1
+ //
2
+ // VS<$modelPrefix$>VO.h
3
+ // VLunch
4
+ //
5
+ // Created by vendys on <$now$>..
6
+ // Copyright © <$year$>년 Vendys. All rights reserved.
7
+ //
8
+
9
+ #import "VS<$prefix$>ViewController.h"
10
+
11
+ /**
12
+ class category
13
+ */
14
+ @interface VS<$prefix$>ViewController ()
15
+ @end
16
+
17
+ @implementation VS<$prefix$>ViewController
18
+ - (void)viewDidLoad {
19
+ [super viewDidLoad];
20
+ }
21
+
22
+ - (void)didReceiveMemoryWarning {
23
+ [super didReceiveMemoryWarning];
24
+ }
25
+ @end
@@ -0,0 +1,3 @@
1
+ module Vsvipergen
2
+ VERSION = "0.1.0"
3
+ end
data/lib/vsvipergen.rb ADDED
@@ -0,0 +1,133 @@
1
+ require "vsvipergen/version"
2
+
3
+ module Vsvipergen
4
+ # abstract class for file generator
5
+ class Generator
6
+ attr_accessor :prefix
7
+ attr_accessor :currPath
8
+ attr_accessor :now
9
+ attr_accessor :year
10
+ attr_accessor :generatedFilePaths
11
+
12
+ def init(prefix, now, year)
13
+ @prefix = prefix
14
+ @currPath = Dir.pwd + "/#{prefix.strip}"
15
+ @now = now
16
+ @year = year
17
+ @generatedFilePaths = []
18
+ Dir.mkdir(currPath) unless File.exists?(currPath)
19
+ end
20
+
21
+ def makeFiles
22
+ end
23
+
24
+ end
25
+
26
+ class ViperFileReader
27
+ def readFile (filePath)
28
+ file = File.open(filePath, "r")
29
+ fileContents = file.read
30
+ file.close
31
+
32
+ return fileContents
33
+ end
34
+ end
35
+
36
+ class ViperFileWriter
37
+ def writeFile (filePath, contents)
38
+ file = File.open(filePath, "w")
39
+ file.write(contents)
40
+ file.close
41
+
42
+ puts "\nnew file created : #{filePath}\n"
43
+ end
44
+ end
45
+
46
+ class ViperGeneratorFactory
47
+ attr_accessor :filePrefix
48
+ attr_accessor :modelPrefix
49
+ attr_accessor :now
50
+ attr_accessor :year
51
+ attr_accessor :fileGenerators
52
+
53
+ def init(filePrefix, modelPrefix, now, year)
54
+ @filePrefix = filePrefix
55
+ @modelPrefix = modelPrefix
56
+ @now = now
57
+ @year = year
58
+ @fileGenerators = []
59
+ end
60
+
61
+ def createObjcGenerator
62
+ # generating model files
63
+ objcModelFileGenerator = Vsvipergen::ViperObjcModelFileGenerator.new
64
+ objcModelFileGenerator.init(filePrefix, now, year, modelPrefix)
65
+ fileGenerators.push(objcModelFileGenerator)
66
+
67
+ # generating contracts file
68
+ objcContractFileGenerator = Vsvipergen::ViperObjcContractsFileGenerator.new
69
+ objcContractFileGenerator.init(filePrefix, now, year, modelPrefix)
70
+ fileGenerators.push(objcContractFileGenerator)
71
+
72
+ # generating interactor file
73
+ objcInteractorFileGenerator = Vsvipergen::ViperObjcInteractorFileGenerator.new
74
+ objcInteractorFileGenerator.init(filePrefix, now, year, modelPrefix)
75
+ fileGenerators.push(objcInteractorFileGenerator)
76
+
77
+ # generating presenter file
78
+ objcPresenterFileGenerator = Vsvipergen::ViperObjcPresenterFileGenerator.new
79
+ objcPresenterFileGenerator.init(filePrefix, now, year, modelPrefix)
80
+ fileGenerators.push(objcPresenterFileGenerator)
81
+
82
+ # generating view file
83
+ objcViewControllerFileGenerator = Vsvipergen::ViperObjcViewControllerFileGenerator.new
84
+ objcViewControllerFileGenerator.init(filePrefix, now, year, modelPrefix)
85
+ fileGenerators.push(objcViewControllerFileGenerator)
86
+
87
+ # generating router file
88
+ objcViewRouterFileGenerator = Vsvipergen::ViperObjcRouterFileGenerator.new
89
+ objcViewRouterFileGenerator.init(filePrefix, now, year, modelPrefix)
90
+ fileGenerators.push(objcViewRouterFileGenerator)
91
+
92
+ return fileGenerators
93
+ end
94
+
95
+ def createAndroidGenerator
96
+ # generating model files
97
+ javaModelFileGenerator = Vsvipergen::ViperAndroidModelFileGenerator.new
98
+ javaModelFileGenerator.init(filePrefix, now, year, modelPrefix)
99
+ fileGenerators.push(javaModelFileGenerator)
100
+
101
+ # generating contracts file
102
+ androidContractFileGenerator = Vsvipergen::ViperAndroidContractsFileGenerator.new
103
+ androidContractFileGenerator.init(filePrefix, now, year, modelPrefix)
104
+ fileGenerators.push(androidContractFileGenerator)
105
+
106
+ # generating interactor file
107
+ androidInteractorFileGenerator = Vsvipergen::ViperAndroidInteractorFileGenerator.new
108
+ androidInteractorFileGenerator.init(filePrefix, now, year, modelPrefix)
109
+ fileGenerators.push(androidInteractorFileGenerator)
110
+
111
+ # generating presenter file
112
+ androidPresenterFileGenerator = Vsvipergen::ViperAndroidPresenterFileGenerator.new
113
+ androidPresenterFileGenerator.init(filePrefix, now, year, modelPrefix)
114
+ fileGenerators.push(androidPresenterFileGenerator)
115
+
116
+ # generating view file
117
+ androidViewControllerFileGenerator = Vsvipergen::ViperAndroidPageFileGenerator.new
118
+ androidViewControllerFileGenerator.init(filePrefix, now, year, modelPrefix)
119
+ fileGenerators.push(androidViewControllerFileGenerator)
120
+
121
+ # generating router file
122
+ androidViewRouterFileGenerator = Vsvipergen::ViperAndroidRouterFileGenerator.new
123
+ androidViewRouterFileGenerator.init(filePrefix, now, year, modelPrefix)
124
+ fileGenerators.push(androidViewRouterFileGenerator)
125
+
126
+ return fileGenerators
127
+ end
128
+ end
129
+
130
+ # class ViperApiCaller
131
+
132
+ # end
133
+ end
@@ -0,0 +1,60 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>Contracts.h
6
+ class ViperObjcContractsFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+
9
+ def init(filePrefix, now, year, modelPrefix)
10
+ super(filePrefix, now, year)
11
+ @modelPrefix = modelPrefix
12
+ end
13
+
14
+ def makeFiles
15
+ super
16
+
17
+ makeHeaderFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{prefix.strip}Contracts.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/VS<$$>Contracts.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+ end
37
+
38
+ class ViperAndroidContractsFileGenerator < ViperObjcContractsFileGenerator
39
+ def makeFiles
40
+ makeJavaFile
41
+
42
+ return generatedFilePaths
43
+ end
44
+
45
+ def makeJavaFile
46
+ newJavaFilePath = currPath + "/VS#{prefix.strip}Contracts.java"
47
+ generatedFilePaths.push(newJavaFilePath)
48
+
49
+ templateJavaFilePath = File.expand_path '../lib/templates/VS<$$>Contracts.java', File.dirname(__FILE__)
50
+
51
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
52
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
53
+ templateJavaFileContents.gsub! "<$now$>", now.strip
54
+ templateJavaFileContents.gsub! "<$year$>", year.strip
55
+ templateJavaFileContents.gsub! "<$prefix$>", prefix.strip
56
+
57
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,75 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>Interactor.h, VS<$filePrefix$>Interactor.m
6
+ class ViperObjcInteractorFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+ def init(filePrefix, now, year, modelPrefix)
9
+ super(filePrefix, now, year)
10
+ @modelPrefix = modelPrefix
11
+ end
12
+
13
+ def makeFiles
14
+ super
15
+
16
+ makeHeaderFile
17
+ makeImplementFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{prefix.strip}Interactor.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/interactor/VS<$$>Interactor.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+
37
+ def makeImplementFile
38
+ newImplementFilePath = currPath + "/VS#{prefix.strip}Interactor.m"
39
+ generatedFilePaths.push(newImplementFilePath)
40
+
41
+ templateImplementFilePath = File.expand_path '../lib/templates/interactor/VS<$$>Interactor.m', File.dirname(__FILE__)
42
+
43
+ templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
44
+ templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
45
+ templateImplementFileContents.gsub! "<$now$>", now.strip
46
+ templateImplementFileContents.gsub! "<$year$>", year.strip
47
+ templateImplementFileContents.gsub! "<$prefix$>", prefix.strip
48
+
49
+ ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
50
+ end
51
+ end
52
+
53
+ class ViperAndroidInteractorFileGenerator < ViperObjcInteractorFileGenerator
54
+ def makeFiles
55
+ makeJavaFile
56
+
57
+ return generatedFilePaths
58
+ end
59
+
60
+ def makeJavaFile
61
+ newJavaFilePath = currPath + "/VS#{prefix.strip}Interactor.java"
62
+ generatedFilePaths.push(newJavaFilePath)
63
+
64
+ templateJavaFilePath = File.expand_path '../lib/templates/interactor/VS<$$>Interactor.java', File.dirname(__FILE__)
65
+
66
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
67
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
68
+ templateJavaFileContents.gsub! "<$now$>", now.strip
69
+ templateJavaFileContents.gsub! "<$year$>", year.strip
70
+ templateJavaFileContents.gsub! "<$prefix$>", prefix.strip
71
+
72
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,75 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>VO.h, VS<$filePrefix$>VO.m
6
+ class ViperObjcModelFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+ def init(filePrefix, now, year, modelPrefix)
9
+ super(filePrefix, now, year)
10
+ @modelPrefix = modelPrefix
11
+ end
12
+
13
+ def makeFiles
14
+ super
15
+
16
+ makeHeaderFile
17
+ makeImplementFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{modelPrefix.strip}VO.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/model/VS<$$>VO.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$properties$>", "".strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+
37
+ def makeImplementFile
38
+ newImplementFilePath = currPath + "/VS#{modelPrefix.strip}VO.m"
39
+ generatedFilePaths.push(newImplementFilePath)
40
+
41
+ templateImplementFilePath = File.expand_path '../lib/templates/model/VS<$$>VO.m', File.dirname(__FILE__)
42
+
43
+ templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
44
+ templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
45
+ templateImplementFileContents.gsub! "<$now$>", now.strip
46
+ templateImplementFileContents.gsub! "<$year$>", year.strip
47
+ templateImplementFileContents.gsub! "<$properties$>", "".strip
48
+
49
+ ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
50
+ end
51
+ end
52
+
53
+ class ViperAndroidModelFileGenerator < ViperObjcModelFileGenerator
54
+ def makeFiles
55
+ makeJavaFile
56
+
57
+ return generatedFilePaths
58
+ end
59
+
60
+ def makeJavaFile
61
+ newJavaFilePath = currPath + "/VS#{modelPrefix.strip}VO.java"
62
+ generatedFilePaths.push(newJavaFilePath)
63
+
64
+ templateJavaFilePath = File.expand_path '../lib/templates/model/VS<$$>VO.java', File.dirname(__FILE__)
65
+
66
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
67
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
68
+ templateJavaFileContents.gsub! "<$now$>", now.strip
69
+ templateJavaFileContents.gsub! "<$year$>", year.strip
70
+ templateJavaFileContents.gsub! "<$properties$>", "".strip
71
+
72
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,75 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>Presenter.h, VS<$filePrefix$>Presenter.m
6
+ class ViperObjcPresenterFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+ def init(filePrefix, now, year, modelPrefix)
9
+ super(filePrefix, now, year)
10
+ @modelPrefix = modelPrefix
11
+ end
12
+
13
+ def makeFiles
14
+ super
15
+
16
+ makeHeaderFile
17
+ makeImplementFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{prefix.strip}Presenter.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/Presenter/VS<$$>Presenter.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+
37
+ def makeImplementFile
38
+ newImplementFilePath = currPath + "/VS#{prefix.strip}Presenter.m"
39
+ generatedFilePaths.push(newImplementFilePath)
40
+
41
+ templateImplementFilePath = File.expand_path '../lib/templates/Presenter/VS<$$>Presenter.m', File.dirname(__FILE__)
42
+
43
+ templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
44
+ templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
45
+ templateImplementFileContents.gsub! "<$now$>", now.strip
46
+ templateImplementFileContents.gsub! "<$year$>", year.strip
47
+ templateImplementFileContents.gsub! "<$prefix$>", prefix.strip
48
+
49
+ ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
50
+ end
51
+ end
52
+
53
+ class ViperAndroidPresenterFileGenerator < ViperObjcPresenterFileGenerator
54
+ def makeFiles
55
+ makeJavaFile
56
+
57
+ return generatedFilePaths
58
+ end
59
+
60
+ def makeJavaFile
61
+ newJavaFilePath = currPath + "/VS#{prefix.strip}Presenter.java"
62
+ generatedFilePaths.push(newJavaFilePath)
63
+
64
+ templateJavaFilePath = File.expand_path '../lib/templates/presenter/VS<$$>Presenter.java', File.dirname(__FILE__)
65
+
66
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
67
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
68
+ templateJavaFileContents.gsub! "<$now$>", now.strip
69
+ templateJavaFileContents.gsub! "<$year$>", year.strip
70
+ templateJavaFileContents.gsub! "<$prefix$>", prefix.strip
71
+
72
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,75 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>ViewController.h, VS<$filePrefix$>ViewController.m
6
+ class ViperObjcRouterFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+ def init(filePrefix, now, year, modelPrefix)
9
+ super(filePrefix, now, year)
10
+ @modelPrefix = modelPrefix
11
+ end
12
+
13
+ def makeFiles
14
+ super
15
+
16
+ makeHeaderFile
17
+ makeImplementFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{prefix.strip}Router.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/router/VS<$$>Router.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+
37
+ def makeImplementFile
38
+ newImplementFilePath = currPath + "/VS#{prefix.strip}Router.m"
39
+ generatedFilePaths.push(newImplementFilePath)
40
+
41
+ templateImplementFilePath = File.expand_path '../lib/templates/router/VS<$$>Router.m', File.dirname(__FILE__)
42
+
43
+ templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
44
+ templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
45
+ templateImplementFileContents.gsub! "<$now$>", now.strip
46
+ templateImplementFileContents.gsub! "<$year$>", year.strip
47
+ templateImplementFileContents.gsub! "<$prefix$>", prefix.strip
48
+
49
+ ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
50
+ end
51
+ end
52
+
53
+ class ViperAndroidRouterFileGenerator < ViperObjcRouterFileGenerator
54
+ def makeFiles
55
+ makeJavaFile
56
+
57
+ return generatedFilePaths
58
+ end
59
+
60
+ def makeJavaFile
61
+ newJavaFilePath = currPath + "/VS#{prefix.strip}Router.java"
62
+ generatedFilePaths.push(newJavaFilePath)
63
+
64
+ templateJavaFilePath = File.expand_path '../lib/templates/router/VS<$$>Router.java', File.dirname(__FILE__)
65
+
66
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
67
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
68
+ templateJavaFileContents.gsub! "<$now$>", now.strip
69
+ templateJavaFileContents.gsub! "<$year$>", year.strip
70
+ templateJavaFileContents.gsub! "<$prefix$>", prefix.strip
71
+
72
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,76 @@
1
+ require "vsvipergen/version"
2
+ require 'vsvipergen'
3
+
4
+ module Vsvipergen
5
+ # concrete class for VS<$filePrefix$>ViewController.h, VS<$filePrefix$>ViewController.m
6
+ class ViperObjcViewControllerFileGenerator < Generator
7
+ attr_accessor :modelPrefix
8
+ def init(filePrefix, now, year, modelPrefix)
9
+ super(filePrefix, now, year)
10
+ @modelPrefix = modelPrefix
11
+ end
12
+
13
+ def makeFiles
14
+ super
15
+
16
+ makeHeaderFile
17
+ makeImplementFile
18
+
19
+ return generatedFilePaths
20
+ end
21
+
22
+ def makeHeaderFile
23
+ newHeaderFilePath = currPath + "/VS#{prefix.strip}ViewController.h"
24
+ generatedFilePaths.push(newHeaderFilePath)
25
+
26
+ templateHeaderFilePath = File.expand_path '../lib/templates/view/VS<$$>ViewController.h', File.dirname(__FILE__)
27
+
28
+ templateHeaderFileContents = ViperFileReader.new.readFile(templateHeaderFilePath)
29
+ templateHeaderFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
30
+ templateHeaderFileContents.gsub! "<$now$>", now.strip
31
+ templateHeaderFileContents.gsub! "<$year$>", year.strip
32
+ templateHeaderFileContents.gsub! "<$prefix$>", prefix.strip
33
+
34
+ ViperFileWriter.new.writeFile(newHeaderFilePath, templateHeaderFileContents)
35
+ end
36
+
37
+ def makeImplementFile
38
+ newImplementFilePath = currPath + "/VS#{prefix.strip}ViewController.m"
39
+ generatedFilePaths.push(newImplementFilePath)
40
+
41
+ templateImplementFilePath = File.expand_path '../lib/templates/view/VS<$$>ViewController.m', File.dirname(__FILE__)
42
+
43
+ templateImplementFileContents = ViperFileReader.new.readFile(templateImplementFilePath)
44
+ templateImplementFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
45
+ templateImplementFileContents.gsub! "<$now$>", now.strip
46
+ templateImplementFileContents.gsub! "<$year$>", year.strip
47
+ templateImplementFileContents.gsub! "<$prefix$>", prefix.strip
48
+
49
+ ViperFileWriter.new.writeFile(newImplementFilePath, templateImplementFileContents)
50
+ end
51
+ end
52
+
53
+ class ViperAndroidPageFileGenerator < ViperObjcViewControllerFileGenerator
54
+ def makeFiles
55
+ makeJavaFile
56
+
57
+ return generatedFilePaths
58
+ end
59
+
60
+ def makeJavaFile
61
+ newJavaFilePath = currPath + "/VS#{prefix.strip}Page.java"
62
+ generatedFilePaths.push(newJavaFilePath)
63
+
64
+ templateJavaFilePath = File.expand_path '../lib/templates/view/VS<$$>Page.java', File.dirname(__FILE__)
65
+
66
+ templateJavaFileContents = ViperFileReader.new.readFile(templateJavaFilePath)
67
+ templateJavaFileContents.gsub! "<$modelPrefix$>", modelPrefix.strip
68
+ templateJavaFileContents.gsub! "<$now$>", now.strip
69
+ templateJavaFileContents.gsub! "<$year$>", year.strip
70
+ templateJavaFileContents.gsub! "<$prefix$>", prefix.strip
71
+
72
+ ViperFileWriter.new.writeFile(newJavaFilePath, templateJavaFileContents)
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,39 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "vsvipergen/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vsvipergen"
8
+ spec.version = Vsvipergen::VERSION
9
+ spec.authors = ["vendys-choohyoung"]
10
+ spec.email = ["lch@vendys.co.kr"]
11
+
12
+ spec.summary = "cli tool to generating objective-c code for viper structure"
13
+ spec.description = "generating VS<$prefix$>Protocol.h, VS<$prefix$>ViewController.h, VS<$prefix$>ViewController.m, VS<$prefix$>Presenter.h, VS<$prefix$>Presenter.m, VS<$prefix$>Interactor.h, VS<$prefix$>Interactor.m, VS<$prefix$>Router.h, VS<$prefix$>Router.m"
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler", "~> 1.16"
36
+ spec.add_development_dependency "rake", "~> 10.0"
37
+ # spec.add_development_dependency "rpec", "~> 3.0"
38
+ spec.add_runtime_dependency 'xcodeproj', '~> 1.7.0'
39
+ end