Skip to content

Luccifer/ramba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

https://luccifer.github.io/ramba/

HOWTO:

  1. Install Generamba

  2. Initialize Generamba in your project's folder and install templates from this repo

  3. open terminal and execute this in the same project's folder:

$ generamba gen Module swifty_viper

The new VIPER Module/Submodule(whatever) will be generated in your project's folder with structure:

Module
  ├── View
  │    └── ModuleViewController.swift
  ├── Presenter
  │    └── ModulePresenter.swift
  ├── Interactor
  │    └── ModuleInteractor.swift
  ├── Router
  │    └── ModuleRouter.swift
  ├── Configurator
  │    ├── ModuleConfigurator.swift 
  │    └── ModuleInitializer.swift
  └── Protocols
       └── ModuleProtocols.swift

Example Content:

generamba gen Test swifty_viper

View -> TestViewController.swift:

import UIKit

class TestViewController: UIViewController, TestViewInput {

    var output: TestViewOutput!

    // MARK: Life cycle
    override func viewDidLoad() {
        super.viewDidLoad()
        TestModuleConfigurator().configureModuleForViewInput(self)
        output.viewIsReady()
    }


    // MARK: TestViewInput
    func setupInitialState() {
    }
}

Presenter -> TestPresenter.swift:

class TestPresenter: TestModuleInput, TestViewOutput, TestInteractorOutput{

    weak var view: TestViewInput!
    var interactor: TestInteractorInput!
    var router: TestRouterInput!

    func viewIsReady() {

    }
}

Interactor -> TestInteractor.swift:

class TestInteractor: TestInteractorInput {

    weak var output: TestInteractorOutput!

}

Router -> TestRouter.swift:

import UIKit

class TestRouter: TestRouterInput {

	weak var view: UIViewController?
}

Configurator -> TestConfigurator.swift:

import UIKit

class TestModuleConfigurator {

    func configureModuleForViewInput<UIViewController>(_ viewInput: UIViewController) {

        if let viewController = viewInput as? TestViewController {
            configure(viewController)
        }
    }

    private func configure(_ viewController: TestViewController) {

        let router = TestRouter()
        router.view = viewController

        let presenter = TestPresenter()
        presenter.view = viewController
        presenter.router = router

        let interactor = TestInteractor()
        interactor.output = presenter

        presenter.interactor = interactor
        viewController.output = presenter
    }

}

Configurator -> TestInitializer.swift:

import UIKit

class TestModuleInitializer: NSObject {

    //Connect with object on storyboard
    @IBOutlet weak var viewController: TestViewController!

    override func awakeFromNib() {

        let configurator = TestModuleConfigurator()
        configurator.configureModuleForViewInput(viewController)
    }

}

Protocols -> TestProtocols.swift:

protocol TestViewInput: class {

    func setupInitialState()
}

protocol TestViewOutput {

    func viewIsReady()
}

protocol TestModuleInput: class {

}

protocol TestInteractorInput {

}

protocol TestInteractorOutput: class {

}

protocol TestRouterInput {

}

Russian Federation, Moscow, 2017 Karpushkin G.A

Releases

No releases published

Packages

No packages published

Languages