vipergen 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3247a8166344baa0ddda9c8dbe2c075d9b38cbd8
4
- data.tar.gz: 59b81a5b17de090ab513717644ca6d0dff9415a7
3
+ metadata.gz: b1808e7fb8e6e8f67adc01355dedd9097304dd52
4
+ data.tar.gz: 7bdf7932d7f3e2a686891cb1efc4b1e8d69d63be
5
5
  SHA512:
6
- metadata.gz: 879f5c3929b2228b75b95f5766d9380185321c2ab6ca513529d80da07eb5a7e2a3b336d9a0cdcb0ea44b7dfd24a961b5f0845fddd4958f1ab3179f027483644d
7
- data.tar.gz: 35a37204ea55241aa6e956e801bdc838383ffe7474375bb6488ea695c19442b2e98d284e7be2fca16cd565afa346edb646cd0511dd834b1624aabafd8d732a5b
6
+ metadata.gz: d15353e2e591ad34ce129acd3df2f853e18c85bbea5bce31a90688dbe1ec6a637867fd7e12c84fe8a1bf70ab668d7c7bee887446773cb9867ac1c868975d89db
7
+ data.tar.gz: 81cef6cd1053b84421cb017a7e066fc9a2f4a407b9eeb4827125f810bb0d0826bc099bafc40691c99602213d02ec06021b896d1f4b8ebe31f8a9179deac12dd7
data/README.md CHANGED
@@ -37,7 +37,10 @@ The implementation scheme returned by this generator is hardly inspired in the e
37
37
  ### Changelog 0.2.3
38
38
  - VIPER Example using the Twitter API
39
39
  - Default template implemented in Swift
40
- -
40
+
41
+ ### Changelog 0.2.5
42
+ - Add `COMPANY` parameter to set the company name on the files header
43
+ - Set Swift as the default language
41
44
 
42
45
  ### Expected in version 0.3
43
46
  - Integrate with XCode as a plugin (http://nshipster.com/xcode-plugins/)
@@ -88,6 +91,11 @@ You have just to execute the following command
88
91
  ```bash
89
92
  vipergen generate MyFirstViperModule --path=~/myproject/shared
90
93
  ```
94
+ Another example:
95
+ ```bash
96
+ vipergen generate MySecondViperModule --path=~/myproject/shared --author='My Name' --company='My Company' --template='existing_template' --language=swift
97
+ ```
98
+
91
99
  And then the files structure will be automatically created. Don't forget to add this folder to your project dragging it into the XCode/Appcode inspector
92
100
 
93
101
  ## How can I try the demo project?
@@ -0,0 +1,17 @@
1
+ //
2
+ // VIPERInteractor.swift
3
+ //
4
+ // Created by AUTHOR.
5
+ // Copyright © YEAR COMPANY. All rights reserved.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ class VIPERInteractor: VIPERInteractorInputProtocol {
11
+
12
+ // MARK: Properties
13
+
14
+ weak var presenter: VIPERInteractorOutputProtocol?
15
+
16
+ // MARK: VIPERInteractorInputProtocol
17
+ }
@@ -0,0 +1,21 @@
1
+ //
2
+ // VIPERPresenter.swift
3
+ //
4
+ // Created by AUTHOR.
5
+ // Copyright © YEAR COMPANY. All rights reserved.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ class VIPERPresenter: VIPERPresenterProtocol, VIPERInteractorOutputProtocol {
11
+
12
+ // MARK: Properties
13
+
14
+ weak var view: VIPERViewProtocol?
15
+ var interactor: VIPERInteractorInputProtocol?
16
+ var wireFrame: VIPERWireFrameProtocol?
17
+
18
+ // MARK: VIPERPresenterProtocol
19
+
20
+ // MARK: VIPERInteractorOutputProtocol
21
+ }
@@ -0,0 +1,28 @@
1
+ //
2
+ // VIPERProtocols.swift
3
+ //
4
+ // Created by AUTHOR.
5
+ // Copyright © YEAR COMPANY. All rights reserved.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ protocol VIPERViewProtocol: class {
11
+
12
+ }
13
+
14
+ protocol VIPERPresenterProtocol: class {
15
+
16
+ }
17
+
18
+ protocol VIPERInteractorInputProtocol {
19
+
20
+ }
21
+
22
+ protocol VIPERInteractorOutputProtocol: class {
23
+
24
+ }
25
+
26
+ protocol VIPERWireFrameProtocol {
27
+
28
+ }
@@ -0,0 +1,24 @@
1
+ //
2
+ // VIPERView.swift
3
+ //
4
+ // Created by AUTHOR.
5
+ // Copyright © YEAR COMPANY. All rights reserved.
6
+ //
7
+
8
+ import Foundation
9
+ import UIKit
10
+
11
+ class VIPERView: UIViewController, VIPERViewProtocol {
12
+
13
+ // MARK: Properties
14
+
15
+ var presenter: VIPERPresenterProtocol?
16
+
17
+ // MARK: UIViewController
18
+
19
+ override func viewDidLoad() {
20
+ super.viewDidLoad()
21
+ }
22
+
23
+ // MARK: VIPERViewProtocol
24
+ }
@@ -0,0 +1,41 @@
1
+ //
2
+ // VIPERWireFrame.swift
3
+ //
4
+ // Created by AUTHOR.
5
+ // Copyright © YEAR COMPANY. All rights reserved.
6
+ //
7
+
8
+ import UIKit
9
+
10
+ public class VIPERWireFrame: VIPERWireFrameProtocol {
11
+
12
+ // MARK: Properties
13
+
14
+ weak var navigationController: UINavigationController?
15
+
16
+ // MARK: Factory
17
+
18
+ public class func presentVIPERFromViewController(source: UIViewController) {
19
+ let presenter = VIPERPresenter()
20
+ let view = VIPERView()
21
+ /*
22
+ If using UIStoryboard use:
23
+ let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
24
+ view = storyboard.instantiateViewControllerWithIdentifier("VIPERView") as! VIPERView
25
+ */
26
+ let interactor = VIPERInteractor()
27
+ let wireFrame = VIPERWireFrame()
28
+
29
+ view.presenter = presenter
30
+ interactor.presenter = presenter
31
+ presenter.view = view
32
+ presenter.interactor = interactor
33
+ presenter.wireFrame = wireFrame
34
+
35
+ let navigationController = UINavigationController(rootViewController: view)
36
+ wireFrame.navigationController = navigationController
37
+ source.presentViewController(navigationController, animated: true, completion: nil)
38
+ }
39
+
40
+ // MARK: VIPERWireFrameProtocol
41
+ }
@@ -0,0 +1,4 @@
1
+ author: Raphael Oliveira
2
+ author_email: raphaelfpoliveira@gmail.com
3
+ template_description: Yet another Swift VIPER template
4
+ updated_at: 2015-12-15
@@ -6,44 +6,46 @@ module Vipergen
6
6
  REPLACEMENT_KEY = "VIPER"
7
7
  AUTHOR_REPLACEMENT_KEY = "AUTHOR"
8
8
  YEAR_REPLACEMENT_KEY = "YEAR"
9
+ COMPANY_REPLACEMENT_KEY = "COMPANY"
9
10
 
10
11
  # Main method that generate the VIPER files structure
11
- def self.generate_viper(template, language, name, path, author)
12
+ def self.generate_viper(template, language, name, path, author, company)
12
13
  puts "Generating VIPER-Module"
13
14
  puts "Template: #{template}"
14
15
  puts "Language: #{language}"
15
16
  puts "Name: #{name}"
16
17
  puts "Path: #{path}"
17
18
  puts "Author: #{author}"
19
+ puts "Company: #{company}"
18
20
  path_from = Vipergen::FileManager.path_from(template, language)
19
21
  path_to = Vipergen::FileManager.destination_viper_path(path, name)
20
22
  Vipergen::FileManager.copy(path_from, path_to)
21
23
  files = Vipergen::FileManager.files_in_path(path_to)
22
- rename_files(files, name, author)
24
+ rename_files(files, name, author, company)
23
25
  end
24
26
 
25
27
  # Rename all the files in the files array
26
28
  # - It renames the name of the file
27
29
  # - It renames the content of the file
28
- def self.rename_files(files, name, author)
30
+ def self.rename_files(files, name, author, company)
29
31
  files.each do |file|
30
32
  raise SyntaxError unless file.include? (Vipergen::Generator::REPLACEMENT_KEY)
31
- rename_file(file, name, author)
33
+ rename_file(file, name, author, company)
32
34
  end
33
35
  end
34
36
 
35
37
  # Rename a given file
36
38
  # - It renames the name of the file
37
39
  # - It renames the content of the file
38
- def self.rename_file(file, name, author)
40
+ def self.rename_file(file, name, author, company)
39
41
  new_path = file.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
40
42
  Vipergen::FileManager.move(file, new_path)
41
- rename_file_content(new_path, name, author)
43
+ rename_file_content(new_path, name, author, company)
42
44
  end
43
45
 
44
46
  # Rename the file content
45
47
  # @return: An String with the every VIPER replaced by 'name'
46
- def self.rename_file_content(filename, name, author)
48
+ def self.rename_file_content(filename, name, author, company)
47
49
  # Reading content
48
50
  file = File.open(filename, "rb")
49
51
  content = file.read
@@ -53,6 +55,7 @@ module Vipergen
53
55
  content = content.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
54
56
  content = content.gsub((Vipergen::Generator::AUTHOR_REPLACEMENT_KEY), author)
55
57
  content = content.gsub((Vipergen::Generator::YEAR_REPLACEMENT_KEY), "#{Time.new.year}")
58
+ content = content.gsub((Vipergen::Generator::COMPANY_REPLACEMENT_KEY), company)
56
59
 
57
60
  # Saving content with replaced string
58
61
  File.open(filename, "w+") do |file|
@@ -60,4 +63,4 @@ module Vipergen
60
63
  end
61
64
  end
62
65
  end
63
- end
66
+ end
@@ -4,7 +4,7 @@ module Vipergen
4
4
 
5
5
  # Returns the templates dir
6
6
  def self.templates_dir
7
- t = "#{Gem.dir}/gems/#{Vipergen::NAME}-#{Vipergen::VERSION}/lib/templates"
7
+ t = "#{File.expand_path File.dirname(__FILE__)}/../templates"
8
8
  end
9
9
 
10
10
  # Get the available templates paths
@@ -1,4 +1,4 @@
1
1
  module Vipergen
2
2
  NAME = "vipergen"
3
- VERSION = "0.2.4"
3
+ VERSION = "0.2.5"
4
4
  end
@@ -3,13 +3,14 @@ require 'vipergen'
3
3
 
4
4
  module Vipergen
5
5
  class ViperThor < Thor
6
- desc "generate", "Generate a VIPER module"
7
- option :language, :required => false, :default => 'objc', :type => :string, :desc => "The language of the generated module (swift, objc)"
6
+ desc "generate MODULE", "Generate a VIPER module"
7
+ option :language, :required => false, :default => 'swift', :type => :string, :desc => "The language of the generated module (swift, objc)"
8
8
  option :template, :required => false, :default => 'default', :type => :string , :desc => "Template for the generation"
9
9
  option :path, :required => true, :type => :string , :desc => "Path where the output module is going to be saved"
10
10
  option :author, :required => false, :default => 'VIPER', :type => :string , :desc => "Author to be specified on the file's header. Otherwise VIPER will be used"
11
+ option :company, :required => false, :default => 'Company', :type => :string, :desc => "Company to be specified on the file's header. Otherwise Company will be used"
11
12
  def generate(name)
12
- Vipergen::Generator.generate_viper(options[:template], options[:language], name, options[:path], options[:author])
13
+ Vipergen::Generator.generate_viper(options[:template], options[:language], name, options[:path], options[:author], options[:company])
13
14
  end
14
15
 
15
16
  desc "templates", "Get a list of available templates"
@@ -17,4 +18,4 @@ module Vipergen
17
18
  puts Vipergen::TemplateManager.templates_description()
18
19
  end
19
20
  end
20
- end
21
+ end
@@ -44,14 +44,14 @@ end
44
44
  describe Vipergen::Generator do
45
45
  context "when renaming file content" do
46
46
  before (:each) do
47
- File.open("test.txt", 'w') {|f| f.write("I'm a #{Vipergen::Generator::REPLACEMENT_KEY} file by #{Vipergen::Generator::AUTHOR_REPLACEMENT_KEY} on #{Vipergen::Generator::YEAR_REPLACEMENT_KEY}") }
47
+ File.open("test.txt", 'w') {|f| f.write("I'm a #{Vipergen::Generator::REPLACEMENT_KEY} file by #{Vipergen::Generator::AUTHOR_REPLACEMENT_KEY} @ #{Vipergen::Generator::COMPANY_REPLACEMENT_KEY} on #{Vipergen::Generator::YEAR_REPLACEMENT_KEY}") }
48
48
  end
49
49
 
50
50
  it "should rename every VIPER word to the given name" do
51
- Vipergen::Generator.rename_file_content("test.txt","RENAMED", "pepito")
51
+ Vipergen::Generator.rename_file_content("test.txt","RENAMED", "pepito", "ViperGen")
52
52
  file = File.open("test.txt", "rb")
53
53
  content = file.read
54
- expect(content).to eq("I'm a RENAMED file by pepito on #{Time.new.year}")
54
+ expect(content).to eq("I'm a RENAMED file by pepito @ ViperGen on #{Time.new.year}")
55
55
  end
56
56
 
57
57
  after (:each) do
@@ -66,18 +66,19 @@ describe Vipergen::Generator do
66
66
 
67
67
  it "every file should be renamed in rename_files" do
68
68
  expect(Vipergen::Generator).to receive(:rename_file)
69
- Vipergen::Generator.rename_files(["#{Vipergen::Generator::REPLACEMENT_KEY}file.txt"], "MyModule", "Pepi")
69
+ Vipergen::Generator.rename_files(["#{Vipergen::Generator::REPLACEMENT_KEY}file.txt"], "MyModule", "Pepi", "ViperGen")
70
70
  end
71
71
 
72
72
  it "should raise a SyntaxError exeption if there's a file in the template without the proper name" do
73
- expect{Vipergen::Generator.rename_files(["asgasgs.txt"], "MyModule", "Pepi")}.to raise_error
73
+ expect{Vipergen::Generator.rename_files(["asgasgs.txt"], "MyModule", "Pepi", "ViperGen")}.to raise_error
74
74
  end
75
75
 
76
76
  it "should rename the VIPER in name to the given name" do
77
77
  file = "#{Vipergen::Generator::REPLACEMENT_KEY}test.txt"
78
78
  name = "RENAMED"
79
79
  author = "PEPI"
80
- Vipergen::Generator.rename_file(file, name, author)
80
+ company = "ViperGen"
81
+ Vipergen::Generator.rename_file(file, name, author, company)
81
82
  expect(File.exist? "RENAMEDtest.txt").to eq(true)
82
83
  end
83
84
 
@@ -85,8 +86,9 @@ describe Vipergen::Generator do
85
86
  file = "#{Vipergen::Generator::REPLACEMENT_KEY}test.txt"
86
87
  name = "RENAMED"
87
88
  author = "PEPI"
89
+ company = "ViperGen"
88
90
  expect(Vipergen::Generator).to receive(:rename_file_content)
89
- Vipergen::Generator.rename_file(file, name, author)
91
+ Vipergen::Generator.rename_file(file, name, author, company)
90
92
  end
91
93
 
92
94
  after (:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vipergen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
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: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2015-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -116,6 +116,12 @@ files:
116
116
  - lib/templates/default/swift/View/VIPERView.swift
117
117
  - lib/templates/default/swift/WireFrame/VIPERWireFrame.swift
118
118
  - lib/templates/default/viperspec.yml
119
+ - lib/templates/naja/swift/Interactor/VIPERInteractor.swift
120
+ - lib/templates/naja/swift/Presenter/VIPERPresenter.swift
121
+ - lib/templates/naja/swift/Protocols/VIPERProtocols.swift
122
+ - lib/templates/naja/swift/Views/VIPERView.swift
123
+ - lib/templates/naja/swift/WireFrame/VIPERWireFrame.swift
124
+ - lib/templates/naja/viperspec.yml
119
125
  - lib/vipergen.rb
120
126
  - lib/vipergen/dirutils.rb
121
127
  - lib/vipergen/filemanager.rb
@@ -146,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
152
  version: '0'
147
153
  requirements: []
148
154
  rubyforge_project:
149
- rubygems_version: 2.2.2
155
+ rubygems_version: 2.4.5.1
150
156
  signing_key:
151
157
  specification_version: 4
152
158
  summary: Generates XCode VIPER module controllers structure