SkillAgentSearch skills...

LaneKit

LaneKit - an iOS Objective-C code generator for integration with RestKit.

Install / Use

/learn @larryaasen/LaneKit
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

LaneKit

Gem Version

LaneKit is an iOS Objective-C code generator for integration with RestKit. It generates models, resource providers, table views, and full iOS apps with mimimal effort. There is support for unit testing with XCTest including fixtures and tests. LaneKit is a command line app written in Ruby and packaged as a Ruby Gem.

Benefits

  • properly implemented models, resource providers, and table views
  • easy integration with RestKit
  • consistent Objective-C code
  • unit tests with XCTest
  • test fixtures in JSON and Objective-C
  • iOS app creation fully integrated with CocoaPods and RestKit, and .gitignore file
  • tested code
  • rapid development
  • enhanced productivity of junior developers
  • reduces dependency on senior developers

How To Get Started

  1. Install the LaneKit Ruby Gem from RubyGems.org on the command line:

     $ gem install lanekit
     Successfully installed lanekit-0.9.0
     $ lanekit -v
     LaneKit 0.9.0
    
  2. LaneKit is ready to use.

Example Usage

Add a new model called Video to an existing Xcode project:

$ lanekit generate model Video headline:string duration:string id:integer image:string itemDate:date location:string

  create  SportsFrames/SportsFrames/Models
  create  SportsFrames/SportsFramesTests/Fixtures
  create  SportsFrames/SportsFramesTests/Models
  create  SportsFrames/SportsFramesTests/Resources
  create  SportsFrames/SportsFrames/Models/Video.h
  create  SportsFrames/SportsFrames/Models/Video.m
  create  SportsFrames/SportsFramesTests/Fixtures/VideoFixtures.h
  create  SportsFrames/SportsFramesTests/Fixtures/VideoFixtures.m
  create  SportsFrames/SportsFramesTests/Resources/VideoFixtures.one.json
  create  SportsFrames/SportsFramesTests/Resources/VideoFixtures.two.json
  create  SportsFrames/SportsFramesTests/Models/VideoTest.h
  create  SportsFrames/SportsFramesTests/Models/VideoTest.m
  create  SportsFrames/SportsFrames/Models/LKModel.h
  create  SportsFrames/SportsFrames/Models/LKModel.m

and here is the Objective-C header file that was generated by LaneKit:

//
//  Video.h
//
//  LaneKit is available under the MIT license. See the LICENSE file for more info.
//
//  This model was created on 2014-01-11 by LaneKit v0.4.4.
//
// The following LaneKit command was used to generate this file:
// lanekit generate model Video headline:string duration:string id:integer image:string itemDate:date location:string
//

#import "LKModel.h"

@interface Video : LKModel

@property (nonatomic,strong) NSString *headline;
@property (nonatomic,strong) NSString *duration;
@property (nonatomic,strong) NSNumber *id;
@property (nonatomic,strong) NSString *image;
@property (nonatomic,strong) NSDate *itemDate;
@property (nonatomic,strong) NSString *location;

@end

and here is the Objective-C .m file that was generated by LaneKit:

//
//  Video.m
//
//  LaneKit is available under the MIT license. See the LICENSE file for more info.
//
//  This model was created on 2014-01-11 by LaneKit v0.4.4.
//
// The following LaneKit command was used to generate this file:
// lanekit generate model Video headline:string duration:string id:integer image:string itemDate:date location:string
//

#import "Video.h"

@implementation Video

#pragma mark LKModel overrides

// Dictionary to convert self to JSON/XML. For XML mappings, add .text to the end of the destination attribute name like this: "title.text".
+ (NSDictionary *)dictionaryForRequestMappings
{
    return @{
             // source key path : destination attribute name
             @"headline": @"headline",
             @"duration": @"duration",
             @"id": @"id",
             @"image": @"image",
             @"itemDate": @"itemDate",
             @"location": @"location"
    };
}

// Dictionary to convert JSON/XML to self. For XML mappings, add .text to the end of the key path like this: "title.text".
+ (NSDictionary *)dictionaryForResponseMappings
{
  return @{
           // source key path : destination attribute name
             @"headline": @"headline",
             @"duration": @"duration",
             @"id": @"id",
             @"image": @"image",
             @"itemDate": @"itemDate",
             @"location": @"location"
    };
}

+ (NSString *)keyPath
{
  return @"video";
}

- (NSString *)descriptionForDisplay
{
  return [NSString stringWithFormat:@"%@", self.headline];
}

@end

and here is the unit test fixtures file that was generated by LaneKit:

//
//  VideoFixtures.m
//
//  LaneKit is available under the MIT license. See the LICENSE file for more info.
//
//  This model fixture was created on 2014-01-11 by LaneKit v0.4.4.
//
// The following LaneKit command was used to generate this file:
// lanekit generate model Video headline:string duration:string id:integer image:string itemDate:date location:string
//

#import "VideoFixtures.h"

@implementation VideoFixtures

+ (Video *)one
{
  Video *video = Video.new;

  video.headline = @"MyString";
  video.duration = @"MyString";
  video.id = [NSNumber numberWithInteger:1];
  video.image = @"MyString";
  video.itemDate = NSDate.new;
  video.location = @"MyString";

  return video;
}

+ (Video *)two
{
  Video *video = Video.new;

  video.headline = @"MyString";
  video.duration = @"MyString";
  video.id = [NSNumber numberWithInteger:1];
  video.image = @"MyString";
  video.itemDate = NSDate.new;
  video.location = @"MyString";

  return video;
}

@end

and here is a RestKit compatible JSON fixture file that was generated by LaneKit:

{
  "video": {
    "headline": "MyString",
    "duration": "MyString",
    "id": "1",
    "image": "MyString",
    "itemDate": "03/01/2012",
    "location": "MyString"
  }
}

and here is part of a unit test that was generated in Models/VideoTest.m by LaneKit:

- (void)testVideoNewOne
{
  Video *video = VideoFixtures.one;
  XCTAssertNotNil(video, @"video is nil");

  XCTAssertTrue([video.headline isEqualToString:@"MyString"], @"headline not correct value");
  XCTAssertTrue([video.duration isEqualToString:@"MyString"], @"duration not correct value");
  XCTAssertTrue(video.id.integerValue == [NSNumber numberWithInteger:1].integerValue, @"id not [NSNumber numberWithInteger:1]");
  XCTAssertTrue([video.image isEqualToString:@"MyString"], @"image not correct value");
  XCTAssertNotNil(video.itemDate, @"itemDate is nil");
  XCTAssertTrue([video.location isEqualToString:@"MyString"], @"location not correct value");
}

- (void)testVideoNewTwo
{
  Video *video = VideoFixtures.two;
  XCTAssertNotNil(video, @"video is nil");

  XCTAssertTrue([video.headline isEqualToString:@"MyString"], @"headline not correct value");
  XCTAssertTrue([video.duration isEqualToString:@"MyString"], @"duration not correct value");
  XCTAssertTrue(video.id.integerValue == [NSNumber numberWithInteger:1].integerValue, @"id not [NSNumber numberWithInteger:1]");
  XCTAssertTrue([video.image isEqualToString:@"MyString"], @"image not correct value");
  XCTAssertNotNil(video.itemDate, @"itemDate is nil");
  XCTAssertTrue([video.location isEqualToString:@"MyString"], @"location not correct value");
}

- (void)testMapping
{
  RKObjectMapping *requestMapping = [Video requestMapping];
  XCTAssertNotNil(requestMapping, @"[Video requestMapping] returned nil.");
  
  RKObjectMapping *responseMapping = [Video responseMapping];
  XCTAssertNotNil(responseMapping, @"[Video responseMapping] returned nil.");
}

Add a new model called Contents that contains a list of Videos and uses a relationship mapping.

$ lanekit generate model contents contents:array:Video
 exist  Classes/model
create  Classes/model/Contents.h
create  Classes/model/Contents.m

Add a new resource provider called Contents.

$ lanekit generate provider Contents Contents http://scores.espn.go.com/allsports/scorecenter/v2/videos/build?sport=top
create  Classes/Controllers
create  Classes/Controllers/LKResourceProvider.h
create  Classes/Controllers/LKResourceProvider.m
create  Classes/Controllers/ContentsProvider.h
create  Classes/Controllers/ContentsProvider.m

Create a new iOS app fully integrated with CocoaPods and RestKit.

$ lanekit new SportsFrames
create  SportsFrames
create  SportsFrames/Podfile
create  SportsFrames/lanekit-ios-project.xcworkspace/contents.xcworkspacedata
create  SportsFrames/lanekit-ios-project.xcworkspace/xcshareddata/lanekit-ios-project.xccheckout
create  SportsFrames/lanekit-ios-project.xcworkspace/xcuserdata/larry.xcuserdatad/UserInterfaceState.xcuserstate
create  SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/project.pbxproj
create  SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create  SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/lanekit-ios-project.xcscheme
create  SportsFrames/lanekit-ios-project/lanekit-ios-project.xcodeproj/xcuserdata/larry.xcuserdatad/xcschemes/xcschememanagement.plist
create  SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKAppDelegate.h
create  SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKAppDelegate.m
create  SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKDetailViewController.h
create  SportsFrames/lanekit-ios-project/lanekit-ios-project/Controllers/LKDetailViewController.m
create  SportsFrames/lanekit-ios-project/lanek

Related Skills

View on GitHub
GitHub Stars51
CategoryDevelopment
Updated5mo ago
Forks3

Languages

Ruby

Security Score

97/100

Audited on Oct 24, 2025

No findings