Ruby gem to generate a clean iOS architecture
Ruby Objective-C
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Demo/iOSCleanArchitectureGenerator
bin
lib
spec
templates/objc
.coveralls.yml
.gitignore
.hound.yml
.rubocop.yml
Gemfile
Gemfile.lock
Guardfile
LICENSE
README.md
Rakefile
iosgen.gemspec

README.md

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 -t
spec/ios_gen/generator/spec.json
[+] Created Source File: FJBNotificationsViewController.h
[+] Created Source File: FJBNotificationsViewController.m
[+] Created Source File: FJBNotificationsViewModelProtocol.h
[+] Created Source File: FJBNotificationsViewModel.h
[+] Created Source File: FJBNotificationsViewModel.m
[+] Created Source File: FJBNotificationsApiInteractorProtocol.h
[+] Created Source File: FJBNotificationsApiInteractor.h
[+] Created Source File: FJBNotificationsApiInteractor.m
[+] Created Test File: FJBNotificationsViewModelTests.m
[+] Created Test File: FJBNotificationsApiInteractorTests.m
  • Add -t to generate XCTest files

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"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}