vipergeng 1.0.1 → 1.0.2
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.
- checksums.yaml +4 -4
- data/README.md +13 -3
- data/lib/templates/default/swift/ViewController/VIPERViewController.swift +16 -1
- data/lib/templates/naja/swift/Views/VIPERView.swift +1 -1
- data/lib/vipergen/generator.rb +18 -15
- data/lib/vipergen/version.rb +1 -1
- data/lib/vipergen/viperthor.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 759e5e163fdc23b978c192c468fe0231972425e9
|
4
|
+
data.tar.gz: f9503621d07087f340e133762598256150dffefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14522321d7671cab73287022a512cbf52fe16a843928296beb98c28bcdb3e0fc020b6e88d0cbe421b64cb0e2bd9143ed66e3e71cb7dcb4a9b5ce560645915954
|
7
|
+
data.tar.gz: f6a781e5121fd02fa08c464b8914f2bb84df73b393a03fbd54cf3436fd252a2f66b7badbf9bdb51dfd5dabbfd7b2b6a2920f3d6f8a4f6c4c76e7a104bc7ea026
|
data/README.md
CHANGED
@@ -29,6 +29,10 @@ The implementation scheme returned by this generator is hardly inspired in the e
|
|
29
29
|
### Changelog 0.2.23
|
30
30
|
- 날짜 포맷을 바꿈.
|
31
31
|
|
32
|
+
### Changelog 1.0.1
|
33
|
+
- g command 추가.
|
34
|
+
- generate or g 사용시 --path 인자를 지정하지 않으면 현재 폴더에 생성하도록 수정
|
35
|
+
|
32
36
|
## Viper files structure
|
33
37
|
```bash
|
34
38
|
.swift
|
@@ -50,13 +54,19 @@ You can install it easily as using the gem. With ruby installed in your OSX exec
|
|
50
54
|
```bash
|
51
55
|
sudo gem install vipergeng
|
52
56
|
```
|
53
|
-
If everything were right, you should have now the
|
57
|
+
If everything were right, you should have now the vipergeng command available in your system console
|
54
58
|
|
55
59
|
## How to generate a VIPER module with a given name?
|
56
60
|
You have just to execute the following command
|
61
|
+
|
62
|
+
--path 지정을 하지 않으면 현재 폴더에 생성.
|
57
63
|
```bash
|
58
64
|
vipergeng generate MyFirstViperModule --path=~/myproject/shared
|
59
65
|
```
|
66
|
+
or
|
67
|
+
```bash
|
68
|
+
vipergeng g MyFirstViperModule
|
69
|
+
```
|
60
70
|
Another example:
|
61
71
|
```bash
|
62
72
|
vipergeng generate MySecondViperModule --path=~/myproject/shared --author='My Name' --company='My Company' --project='project name'
|
@@ -73,7 +83,7 @@ gem install vipergeng-0.1.gem
|
|
73
83
|
gem push vipergeng-0.1.gem
|
74
84
|
```
|
75
85
|
Then you'll be asked for your credentials in order to make the update in the repo (http://guides.rubygems.org/publishing/)
|
76
|
-
|
86
|
+
``
|
77
87
|
### Add a new template
|
78
88
|
Are you interested in VIPER and you would like to contribute with this gem adding new templates? Feel free to do it. It's pretty easy. You've just to:
|
79
89
|
- Create a folder inside `templates` with the name of your template
|
@@ -97,7 +107,7 @@ updated_at: 2014-08-24
|
|
97
107
|
- XCode Plugins: http://nshipster.com/xcode-plugins/
|
98
108
|
- XCodeProj gem (to modify project groups structure): https://github.com/CocoaPods/Xcodeproj
|
99
109
|
- Thor, powerful Ruby library for command line: http://whatisthor.com/
|
100
|
-
- Cocoa Design
|
110
|
+
- Cocoa Design Patterns: https://developer.apple.com/legacy/library/documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html
|
101
111
|
|
102
112
|
## Contact
|
103
113
|
If you have any doubt about the gem or even if you want to make any suggestion you can do it directly to my email address, pedro@redbooth.com . You can use the issues Github page too
|
@@ -9,7 +9,7 @@
|
|
9
9
|
import Foundation
|
10
10
|
import UIKit
|
11
11
|
|
12
|
-
class VIPERViewController:
|
12
|
+
class VIPERViewController: _BASE_VIEW_CONTROLLER_, VIPERViewProtocol {
|
13
13
|
var presenter: VIPERPresenterProtocol?
|
14
14
|
|
15
15
|
override func viewDidLoad() {
|
@@ -23,6 +23,21 @@ class VIPERViewController: UIViewController, VIPERViewProtocol {
|
|
23
23
|
// Dispose of any resources that can be recreated.
|
24
24
|
}
|
25
25
|
|
26
|
+
override func viewWillAppear(_ animated: Bool) {
|
27
|
+
super.viewWillAppear(animated)
|
28
|
+
}
|
29
|
+
|
30
|
+
override func viewDidAppear(_ animated: Bool) {
|
31
|
+
super.viewDidAppear(animated)
|
32
|
+
}
|
33
|
+
|
34
|
+
override func viewWillDisappear(_ animated: Bool) {
|
35
|
+
super.viewWillDisappear(animated)
|
36
|
+
}
|
37
|
+
|
38
|
+
override func viewDidDisappear(_ animated: Bool) {
|
39
|
+
super.viewDidAppear(animated)
|
40
|
+
}
|
26
41
|
|
27
42
|
/*
|
28
43
|
// MARK: - Navigation
|
data/lib/vipergen/generator.rb
CHANGED
@@ -6,13 +6,14 @@ module Vipergen
|
|
6
6
|
REPLACEMENT_KEY = "VIPER"
|
7
7
|
AUTHOR_REPLACEMENT_KEY = "___FULLUSERNAME___"
|
8
8
|
YEAR_REPLACEMENT_KEY = "___YEAR___"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
COMPANY_REPLACEMENT_KEY = "___ORGANIZATIONNAME___"
|
10
|
+
PROJECT_REPLACEMENT_KEY = "___PROJECTNAME___"
|
11
|
+
FILE_REPLACEMENT_KEY= "___FILENAME___"
|
12
|
+
DATE_REPLACEMENT_KEY= "___DATE___"
|
13
|
+
VC_REPLACEMENT_KEY= "_BASE_VIEW_CONTROLLER_"
|
13
14
|
|
14
15
|
# Main method that generate the VIPER files structure
|
15
|
-
def self.generate_viper(template, language, name, path, author, company, project)
|
16
|
+
def self.generate_viper(template, language, name, path, author, company, project, baseviewcontroller)
|
16
17
|
puts "Generating VIPER-Module"
|
17
18
|
puts "Template: #{template}"
|
18
19
|
puts "Language: #{language}"
|
@@ -21,35 +22,36 @@ module Vipergen
|
|
21
22
|
puts "Author: #{author}"
|
22
23
|
puts "Company: #{company}"
|
23
24
|
puts "Project: #{project}"
|
25
|
+
puts "BaseViewController : #{baseviewcontroller}"
|
24
26
|
path_from = Vipergen::FileManager.path_from(template, language)
|
25
27
|
path_to = Vipergen::FileManager.destination_viper_path(path, name)
|
26
28
|
Vipergen::FileManager.copy(path_from, path_to)
|
27
29
|
files = Vipergen::FileManager.files_in_path(path_to)
|
28
|
-
rename_files(files, name, author, company, project)
|
30
|
+
rename_files(files, name, author, company, project, baseviewcontroller)
|
29
31
|
end
|
30
32
|
|
31
33
|
# Rename all the files in the files array
|
32
34
|
# - It renames the name of the file
|
33
35
|
# - It renames the content of the file
|
34
|
-
def self.rename_files(files, name, author, company, project)
|
36
|
+
def self.rename_files(files, name, author, company, project, baseviewcontroller)
|
35
37
|
files.each do |file|
|
36
38
|
raise SyntaxError unless file.include? (Vipergen::Generator::REPLACEMENT_KEY)
|
37
|
-
rename_file(file, name, author, company, project)
|
39
|
+
rename_file(file, name, author, company, project, baseviewcontroller)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
41
43
|
# Rename a given file
|
42
44
|
# - It renames the name of the file
|
43
45
|
# - It renames the content of the file
|
44
|
-
def self.rename_file(file, name, author, company, project)
|
46
|
+
def self.rename_file(file, name, author, company, project, baseviewcontroller)
|
45
47
|
new_path = file.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
|
46
48
|
Vipergen::FileManager.move(file, new_path)
|
47
|
-
rename_file_content(new_path, name, author, company, project)
|
49
|
+
rename_file_content(new_path, name, author, company, project, baseviewcontroller)
|
48
50
|
end
|
49
51
|
|
50
52
|
# Rename the file content
|
51
53
|
# @return: An String with the every VIPER replaced by 'name'
|
52
|
-
def self.rename_file_content(filename, name, author, company, project)
|
54
|
+
def self.rename_file_content(filename, name, author, company, project, baseviewcontroller)
|
53
55
|
# Reading content
|
54
56
|
file = File.open(filename, "rb")
|
55
57
|
content = file.read
|
@@ -60,14 +62,15 @@ module Vipergen
|
|
60
62
|
content = content.gsub((Vipergen::Generator::AUTHOR_REPLACEMENT_KEY), author)
|
61
63
|
content = content.gsub((Vipergen::Generator::YEAR_REPLACEMENT_KEY), "#{Time.new.year}")
|
62
64
|
content = content.gsub((Vipergen::Generator::COMPANY_REPLACEMENT_KEY), company)
|
63
|
-
|
64
|
-
|
65
|
+
content = content.gsub((Vipergen::Generator::PROJECT_REPLACEMENT_KEY), project)
|
66
|
+
content = content.gsub((Vipergen::Generator::FILE_REPLACEMENT_KEY), File.basename(filename,File.extname(filename)))
|
65
67
|
str = '%02d/%02d/%02d' % [Time.new.day, Time.new.month, Time.new.year%100]
|
66
|
-
|
68
|
+
content = content.gsub((Vipergen::Generator::DATE_REPLACEMENT_KEY), str)
|
69
|
+
content = content.gsub((Vipergen::Generator::VC_REPLACEMENT_KEY), baseviewcontroller)
|
67
70
|
|
68
71
|
# Saving content with replaced string
|
69
72
|
File.open(filename, "w+") do |file|
|
70
|
-
|
73
|
+
file.write(content)
|
71
74
|
end
|
72
75
|
end
|
73
76
|
end
|
data/lib/vipergen/version.rb
CHANGED
data/lib/vipergen/viperthor.rb
CHANGED
@@ -10,8 +10,9 @@ module Vipergen
|
|
10
10
|
option :author, :required => false, :default => 'AuthorXXX', :type => :string , :desc => "Author to be specified on the file's header. Otherwise VIPER will be used"
|
11
11
|
option :company, :required => false, :default => 'CompanyXXX', :type => :string, :desc => "Company to be specified on the file's header. Otherwise Company will be used"
|
12
12
|
option :project, :required => false, :default => 'ProjectXXX', :type => :string, :desc => "Project to be specified on the file's header. Otherwise Project will be used"
|
13
|
+
option :base, :required => false, :default => 'UIViewController', :type => :string, :desc => "View Controller의 베이스 클래스 이름"
|
13
14
|
def generate(name)
|
14
|
-
Vipergen::Generator.generate_viper(options[:template], 'swift', name, options[:path], options[:author], options[:company], options[:project])
|
15
|
+
Vipergen::Generator.generate_viper(options[:template], 'swift', name, options[:path], options[:author], options[:company], options[:project], options[:base])
|
15
16
|
end
|
16
17
|
|
17
18
|
desc "g MODULE", "Generate a VIPER module"
|
@@ -20,8 +21,9 @@ module Vipergen
|
|
20
21
|
option :author, :required => false, :default => 'AuthorXXX', :type => :string , :desc => "Author to be specified on the file's header. Otherwise VIPER will be used"
|
21
22
|
option :company, :required => false, :default => 'CompanyXXX', :type => :string, :desc => "Company to be specified on the file's header. Otherwise Company will be used"
|
22
23
|
option :project, :required => false, :default => 'ProjectXXX', :type => :string, :desc => "Project to be specified on the file's header. Otherwise Project will be used"
|
24
|
+
option :base, :required => false, :default => 'UIViewController', :type => :string, :desc => "View Controller의 베이스 클래스 이름"
|
23
25
|
def g(name)
|
24
|
-
Vipergen::Generator.generate_viper(options[:template], 'swift', name, options[:path], options[:author], options[:company], options[:project])
|
26
|
+
Vipergen::Generator.generate_viper(options[:template], 'swift', name, options[:path], options[:author], options[:company], options[:project], options[:base])
|
25
27
|
end
|
26
28
|
|
27
29
|
desc "templates", "Get a list of available templates"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vipergeng
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pedro Piñera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|