ObjC2RubyMotion Converter for Sublime Text 23

Build Status

A command plugin that enables to convert Objective-C code to Ruby Motion.

Screenshot:

screenshot

Using iShowU, KeyCastr, GIFBrewery

How It Works

Code in the line of the cursor or selection are converted:

// original
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.myNavController;
[self.window makeKeyAndVisible];

// select lines and run "objc_to_ruby_motion" _window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) self.window.rootViewController = self.myNavController self.window.makeKeyAndVisible

Install

Package Control

Install the ObjC2RubyMotion package from Package Control.

Manual

Clone this repository from your Sublime packages directory:

Macosx

$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
$ git clone https://github.com/kyamaguchi/SublimeObjC2RubyMotion.git ObjC2RubyMotion

Key Binding

By default,

For Conversion

super+ctrl+i objc_to_ruby_motion

Conversions

In internal order

  • Replace NSString @"String" -> "String"
  • Remove inline comments //
  • Convert blocks (may be not perfect)
  • Convert square brackets expression [[Obj alloc] init] -> Obj.alloc.init
  • Remove semicolon ; at the end of line
  • Remove autorelease at the end
  • Remove type declaration for Object Type * before =
  • YES/NO
  • Float 100.0f -> 100
  • CGRectMake CGRectMake(10, 10, 20, 20) -> [[10, 10], [20, 20]]

NOT supported

  • Complex block
  • if else conditions etc.
  • actions action:@selector(tapped:)
  • Method name and args conversion - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  • Others

Note

This converter is not intended to convert perfectly. This is intended to help the conversion of Objective-C code snippets.

Some complex expression may not be converted correctly.

Tests



ObjC2RubyMotion Converter for Sublime Text 23

建立状态

一个可以将Objective-C代码转换为Ruby Motion的命令插件。

截图:

截图data-canonical-src

使用iShowU,KeyCastr,GIFBrewery

工作原理

将光标或选择行中的代码转换为:

// original
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.myNavController;
[self.window makeKeyAndVisible];

// select lines and run "objc_to_ruby_motion" _window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds) self.window.rootViewController = self.myNavController self.window.makeKeyAndVisible

安装

软件包控制

软件包控制安装 ObjC2RubyMotion 软件包。

手册

从您的Sublime软件包目录中克隆该存储库:

Macosx

$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages
$ git clone https://github.com/kyamaguchi/SublimeObjC2RubyMotion.git ObjC2RubyMotion

键绑定

默认情况下,

转换

super + ctrl + i objc_to_ruby_motion

转换

In internal order

  • 替换NSString @String - > String
  • 删除内联注释 //
  • 转换块(可能不完美)
  • 转换方括号表达式 [[Obj alloc] init] - > Obj.alloc.init
  • 删除行尾
  • 的分号;
  • 删除
  • 末尾的 autorelease
  • =
  • 之前删除Object Type * 的类型声明
  • 是/否
  • Float 100.0f - > 100
  • CGRectMake CGRectMake(10,10,20,20) - > [[10,10],[20,20]]

NOT supported

  • 复合块
  • 如果其他条件等。
  • 动作动作:@selector(轻击:)
  • 方法名称和args转换 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)部分
  • 其他

Note

此转换器不是完美转换。这旨在帮助Objective-C代码片段的转换。

某些复杂表达式可能无法正确转换。

测试




相关问题推荐