vipergen 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +15 -5
  3. data/lib/templates/default/objc/DataManager/API/VIPERAPIDataManager.h +2 -2
  4. data/lib/templates/default/objc/DataManager/API/VIPERAPIDataManager.m +2 -2
  5. data/lib/templates/default/objc/DataManager/Local/VIPERLocalDataManager.h +2 -2
  6. data/lib/templates/default/objc/DataManager/Local/VIPERLocalDataManager.m +2 -2
  7. data/lib/templates/default/objc/Interactor/VIPERInteractor.h +2 -2
  8. data/lib/templates/default/objc/Interactor/VIPERInteractor.m +2 -2
  9. data/lib/templates/default/objc/Interactor/VIPERItem.h +2 -5
  10. data/lib/templates/default/objc/Interactor/VIPERItem.m +2 -5
  11. data/lib/templates/default/objc/Presenter/VIPERPresenter.h +2 -2
  12. data/lib/templates/default/objc/Presenter/VIPERPresenter.m +2 -2
  13. data/lib/templates/default/objc/Protocols/VIPERProtocols.h +2 -2
  14. data/lib/templates/default/objc/View/VIPERView.h +2 -2
  15. data/lib/templates/default/objc/View/VIPERView.m +2 -2
  16. data/lib/templates/default/objc/WireFrame/VIPERWireFrame.h +2 -2
  17. data/lib/templates/default/objc/WireFrame/VIPERWireFrame.m +2 -2
  18. data/lib/templates/default/swift/DataManager/API/VIPERAPIDataManager.swift +2 -5
  19. data/lib/templates/default/swift/DataManager/Local/VIPERLocalDataManager.swift +2 -5
  20. data/lib/templates/default/swift/Interactor/VIPERInteractor.swift +2 -5
  21. data/lib/templates/default/swift/Interactor/VIPERItem.swift +2 -5
  22. data/lib/templates/default/swift/Presenter/VIPERPresenter.swift +2 -5
  23. data/lib/templates/default/swift/Protocols/VIPERProtocols.swift +5 -8
  24. data/lib/templates/default/swift/View/VIPERView.swift +2 -5
  25. data/lib/templates/default/swift/WireFrame/VIPERWireFrame.swift +2 -5
  26. data/lib/vipergen/generator.rb +12 -7
  27. data/lib/vipergen/version.rb +1 -1
  28. data/lib/vipergen/viperthor.rb +2 -1
  29. data/spec/vipergen/vipergen_spec.rb +9 -7
  30. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0e9a2fe1c4464f75cd7dfa761e575b2111d9dc7
4
- data.tar.gz: 6d674ca32c2ae04c1630e785e7306d45b1d8cb76
3
+ metadata.gz: 3247a8166344baa0ddda9c8dbe2c075d9b38cbd8
4
+ data.tar.gz: 59b81a5b17de090ab513717644ca6d0dff9415a7
5
5
  SHA512:
6
- metadata.gz: 8f062cf785ee645e99a3980bee3dc717c6652097d7a88a35c1ff7eeec3a3bfcb39f00f751ac94ac981d9ee8e042df6958af8b814bf75928395fc4439f4ea3268
7
- data.tar.gz: e904e13533cdb6fe616896cf07e8b63a0543ecfec9ca9fb95237259f396895b560c5fecb414252196a7c469242f8e6755ff812bbcf6b38b813871fa32ad65929
6
+ metadata.gz: 879f5c3929b2228b75b95f5766d9380185321c2ab6ca513529d80da07eb5a7e2a3b336d9a0cdcb0ea44b7dfd24a961b5f0845fddd4958f1ab3179f027483644d
7
+ data.tar.gz: 35a37204ea55241aa6e956e801bdc838383ffe7474375bb6488ea695c19442b2e98d284e7be2fca16cd565afa346edb646cd0511dd834b1624aabafd8d732a5b
data/README.md CHANGED
@@ -34,11 +34,12 @@ The implementation scheme returned by this generator is hardly inspired in the e
34
34
  - Added default template
35
35
  - Fully components tested
36
36
 
37
- ### Expected in version 0.2
38
- - Example project of Redbooth login with notifications
39
- - FetchedResultsController template
40
- - Default template in Swift
41
- - Login template
37
+ ### Changelog 0.2.3
38
+ - VIPER Example using the Twitter API
39
+ - Default template implemented in Swift
40
+ -
41
+
42
+ ### Expected in version 0.3
42
43
  - Integrate with XCode as a plugin (http://nshipster.com/xcode-plugins/)
43
44
 
44
45
  ## Viper files structure
@@ -89,6 +90,15 @@ vipergen generate MyFirstViperModule --path=~/myproject/shared
89
90
  ```
90
91
  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
91
92
 
93
+ ## How can I try the demo project?
94
+
95
+ 1. Clone the repo `git clone https://github.com/pepibumur/viper-module-generator.git`
96
+ 2. Move into the repo folder and update the git submodules `git sumodule update --init`
97
+ 3. In the folder VIPERGenDemo install the pods `pod install`
98
+ 4. Open the project from the `VIPERGenDemo.xcworkspace` file
99
+ 5. Enjoy it!
100
+
101
+
92
102
  ## Developer tips
93
103
  ### Update the gem
94
104
  When the gem is updated it has to be reported to the gem repository. I followed this tutorial http://amaras-tech.co.uk/article/43/Creating_executable_gems that basically says that once you have your gem ready execute:
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR.
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERAPIDataManager.h"
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERLocalDataManager.h"
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERInteractor.h"
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERItem.h
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___PPinera___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  #import <Foundation/Foundation.h>
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERItem.m
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___PPinera___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  #import "VIPERItem.h"
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERPresenter.h"
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <UIKit/UIKit.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERView.h"
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import <Foundation/Foundation.h>
@@ -1,6 +1,6 @@
1
1
  //
2
- // Created by Pedro Piñera Buendía on 2014.
3
- // Copyright (c) 2014 PPinera. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
4
4
  //
5
5
 
6
6
  #import "VIPERWireFrame.h"
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERAPIDataManager.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERLocalDataManager.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERInteractor.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERItem.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERPresenter.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERProtocols.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 22/08/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -12,7 +9,7 @@ protocol VIPERViewProtocol: class
12
9
  {
13
10
  var presenter: VIPERPresenterProtocol? { get set }
14
11
  /**
15
- * Add here your methods for communication VIEWCONTROLLER -> PRESENTER
12
+ * Add here your methods for communication PRESENTER -> VIEW
16
13
  */
17
14
  }
18
15
 
@@ -30,7 +27,7 @@ protocol VIPERPresenterProtocol: class
30
27
  var interactor: VIPERInteractorInputProtocol? { get set }
31
28
  var wireFrame: VIPERWireFrameProtocol? { get set }
32
29
  /**
33
- * Add here your methods for communication VIEWCONTROLLER -> PRESENTER
30
+ * Add here your methods for communication VIEW -> PRESENTER
34
31
  */
35
32
  }
36
33
 
@@ -68,6 +65,6 @@ protocol VIPERAPIDataManagerInputProtocol: class
68
65
  protocol VIPERLocalDataManagerInputProtocol: class
69
66
  {
70
67
  /**
71
- * Add here your methods for communication INTERACTOR -> APIDATAMANAGER
68
+ * Add here your methods for communication INTERACTOR -> LOCALDATAMANAGER
72
69
  */
73
70
  }
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERView.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -1,9 +1,6 @@
1
1
  //
2
- // VIPERWireFrame.swift
3
- // VIPERGenDemo
4
- //
5
- // Created by Pedro Piñera Buendía on 24/10/14.
6
- // Copyright (c) 2014 ___Redbooth___. All rights reserved.
2
+ // Created by AUTHOR
3
+ // Copyright (c) YEAR AUTHOR. All rights reserved.
7
4
  //
8
5
 
9
6
  import Foundation
@@ -4,43 +4,46 @@ module Vipergen
4
4
  # Constants
5
5
  LANGUAGES = ["swift", "objc"]
6
6
  REPLACEMENT_KEY = "VIPER"
7
+ AUTHOR_REPLACEMENT_KEY = "AUTHOR"
8
+ YEAR_REPLACEMENT_KEY = "YEAR"
7
9
 
8
10
  # Main method that generate the VIPER files structure
9
- def self.generate_viper(template, language, name, path)
11
+ def self.generate_viper(template, language, name, path, author)
10
12
  puts "Generating VIPER-Module"
11
13
  puts "Template: #{template}"
12
14
  puts "Language: #{language}"
13
15
  puts "Name: #{name}"
14
16
  puts "Path: #{path}"
17
+ puts "Author: #{author}"
15
18
  path_from = Vipergen::FileManager.path_from(template, language)
16
19
  path_to = Vipergen::FileManager.destination_viper_path(path, name)
17
20
  Vipergen::FileManager.copy(path_from, path_to)
18
21
  files = Vipergen::FileManager.files_in_path(path_to)
19
- rename_files(files,name)
22
+ rename_files(files, name, author)
20
23
  end
21
24
 
22
25
  # Rename all the files in the files array
23
26
  # - It renames the name of the file
24
27
  # - It renames the content of the file
25
- def self.rename_files(files, name)
28
+ def self.rename_files(files, name, author)
26
29
  files.each do |file|
27
30
  raise SyntaxError unless file.include? (Vipergen::Generator::REPLACEMENT_KEY)
28
- rename_file(file, name)
31
+ rename_file(file, name, author)
29
32
  end
30
33
  end
31
34
 
32
35
  # Rename a given file
33
36
  # - It renames the name of the file
34
37
  # - It renames the content of the file
35
- def self.rename_file(file, name)
38
+ def self.rename_file(file, name, author)
36
39
  new_path = file.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
37
40
  Vipergen::FileManager.move(file, new_path)
38
- rename_file_content(new_path, name)
41
+ rename_file_content(new_path, name, author)
39
42
  end
40
43
 
41
44
  # Rename the file content
42
45
  # @return: An String with the every VIPER replaced by 'name'
43
- def self.rename_file_content(filename, name)
46
+ def self.rename_file_content(filename, name, author)
44
47
  # Reading content
45
48
  file = File.open(filename, "rb")
46
49
  content = file.read
@@ -48,6 +51,8 @@ module Vipergen
48
51
 
49
52
  # Replacing content
50
53
  content = content.gsub((Vipergen::Generator::REPLACEMENT_KEY), name)
54
+ content = content.gsub((Vipergen::Generator::AUTHOR_REPLACEMENT_KEY), author)
55
+ content = content.gsub((Vipergen::Generator::YEAR_REPLACEMENT_KEY), "#{Time.new.year}")
51
56
 
52
57
  # Saving content with replaced string
53
58
  File.open(filename, "w+") do |file|
@@ -1,4 +1,4 @@
1
1
  module Vipergen
2
2
  NAME = "vipergen"
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.4"
4
4
  end
@@ -7,8 +7,9 @@ module Vipergen
7
7
  option :language, :required => false, :default => 'objc', :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
+ option :author, :required => false, :default => 'VIPER', :type => :string , :desc => "Author to be specified on the file's header. Otherwise VIPER will be used"
10
11
  def generate(name)
11
- Vipergen::Generator.generate_viper(options[:template], options[:language], name, options[:path])
12
+ Vipergen::Generator.generate_viper(options[:template], options[:language], name, options[:path], options[:author])
12
13
  end
13
14
 
14
15
  desc "templates", "Get a list of available templates"
@@ -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") }
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}") }
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")
51
+ Vipergen::Generator.rename_file_content("test.txt","RENAMED", "pepito")
52
52
  file = File.open("test.txt", "rb")
53
53
  content = file.read
54
- expect(content).to eq("I'm a RENAMED file")
54
+ expect(content).to eq("I'm a RENAMED file by pepito on #{Time.new.year}")
55
55
  end
56
56
 
57
57
  after (:each) do
@@ -66,25 +66,27 @@ 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"], "pepito")
69
+ Vipergen::Generator.rename_files(["#{Vipergen::Generator::REPLACEMENT_KEY}file.txt"], "MyModule", "Pepi")
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"], "pepito")}.to raise_error
73
+ expect{Vipergen::Generator.rename_files(["asgasgs.txt"], "MyModule", "Pepi")}.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
- Vipergen::Generator.rename_file(file, name)
79
+ author = "PEPI"
80
+ Vipergen::Generator.rename_file(file, name, author)
80
81
  expect(File.exist? "RENAMEDtest.txt").to eq(true)
81
82
  end
82
83
 
83
84
  it "should rename the file content after the file name rename" do
84
85
  file = "#{Vipergen::Generator::REPLACEMENT_KEY}test.txt"
85
86
  name = "RENAMED"
87
+ author = "PEPI"
86
88
  expect(Vipergen::Generator).to receive(:rename_file_content)
87
- Vipergen::Generator.rename_file(file, name)
89
+ Vipergen::Generator.rename_file(file, name, author)
88
90
  end
89
91
 
90
92
  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.2
4
+ version: 0.2.4
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-10-27 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake