Clean iOS architecture generator

Build Status Coverage Status Code Climate Gem Version

Ruby gem to generate a clean iOS architecture based on a spec file written in json format. Having the following components, the gem will generate files according and it will add some logic in order to save development time.

In the roadmap there are features like estimations and creation of tickets in Github Issues and others management tools.

Install

gem install iosgen

Execute

$ iosgen generate spec.json
spec.json
[+] Created FJBNotificationsViewController.h
[+] Created FJBNotificationsViewController.m
[+] Created FJBNotificationsViewModelProtocol.h
[+] Created FJBNotificationsViewModel.h
[+] Created FJBNotificationsViewModel.m
[+] Created FJBNotificationsApiInteractorProtocol.h
[+] Created FJBNotificationsApiInteractor.h
[+] Created FJBNotificationsApiInteractor.m

Components

Property

The property object is composited of two strings, type and name, which repesent variables.

  • type : Any Object type
  • name : name of the object
{
  "type": "NSIndexPath *",
  "name": "selectedIndexPath"
}

Action

{
  "description": "Dismiss the ViewController when the button is tapped",
  "return_type": "void",
  "name": "didTapOnCloseButton:",
  "arguments": [{
    "type" : "UIButton *",
    "name" : "closeButton"
    }]
}

Interactor

Interactor is an object which perform actions for other components. In this example the ViewModel needs to comunicate to the server which notification has been mark as read.

{
  "description" : "Api Interactions required by Notification ViewModel",
  "name": "FJBNotificationsApiInteractor",
  "properties": [],
  "actions": [
    {
      "description": "Perform API request to mark a notification as read",
      "return_type": "void",
      "name": "markNotificationAsRead:onCompletionBlock:",
      "arguments": [
        {
          "type": "NSString *",
          "name": "notificationId"
        },
        {
          "type": "void(^)()",
          "name": "completionBlock"
        }
      ]
    }
  ]
}

ViewModel

{
  "description" : "State of NotificationViewController and perform bussiness logic",
  "name": "FJBNotificationsViewModel",
  "properties": [],
  "actions": [],
  "interactors": []
}

UIViewController

  "view_controller": {
    "description": "ViewController to show the list of notifications",
    "name": "FJBNotificationsViewController"
  }

Example of Spec.json

{
  "view_controller": {
    "description": "ViewController to show the list of notifications", 
    "name": "FJBNotificationViewController",
    "view_model": {
      "description" : "State of NotificationViewController and perform bussiness logic",
      "name": "FJBNotificationsViewModel",
      "properties": [
        {
          "type": "NSIndexPath *",
          "name": "selectedIndexPath"
        }
      ],
      "actions": [
        {
          "description": "Dismiss the ViewController when the button is tapped",
          "return_type": "void",
          "name": "didTapOnCloseButton"
        },
        {
          "description": "Mark notification as read when the notification is selected",
          "return_type": "void",
          "name": "didTapAtIndexPath:",
          "arguments": [
            {
              "type": "NSIndexPath *",
              "name": "indexPath"
            }
          ]
        }
      ],
      "interactors": [
        {
          "description" : "Api Interactions required by Notification ViewModel",
          "name": "FJBNotificationsApiInteractor",
          "properties": [],
          "actions": [
            {
              "description": "Perform API request to mark a notification as read",
              "return_type": "void",
              "name": "markNotificationAsRead:onCompletionBlock:",
              "arguments": [
                {
                  "type": "NSString *",
                  "name": "notificationId"
                },
                {
                  "type": "^()",
                  "name": "completionBlock"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}