• This repository has been archived on 05/Jan/2020
  • Stars
    star
    320
  • Rank 127,913 (Top 3 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Extensions for Swift with hundreds of handy methods.

Codecov

RbSwift provides a series of Swift struct/class extension including lots of handy functions with elaborate API Reference.

Most of the APIs and test cases are from Ruby Core Libraries and ActiveSupport example.

Features

  • Transform functions support for Sequence, Array, and Dictionary

    [1, 2, 3, nil, nil, 4, 5, 6, 7]
        .flatten()              //=> [1, 2, 3, 4, 5, 6, 7]
        .select { $0 > 2 }      //=> [3, 4, 5, 6, 7]      
        .reject { $0.isEven }   //=> [3, 5, 7]
        .count                  //=> 3
  • Built-in Regex support for String

    "hello".gsub("l", "abc")    //=> "heabcabco"
    "hello".gsub("l", "lll")    //=> "lllllllllllllll"
    
    if "hello world" =~ "hello" {
        print("this will match")
    }
  • Convenient methods build Date instance

    Date.now + 1.day            //=> 2017-01-01 12:00:00 +0000
    2.years + 1.day > 1.year    //=> true
    
  • File and IO supports which build on top of low-level C API

    File.basename("/home/work/file.swift") //=> file.swift
    File.open("empty.txt", "w") { file in
        file.write("Content")
    }
    
    Dir.isEmpty("a/empty/folder")   //=> true
    Dir.entries(entriesDir)         //=> [".", "..", "file.swift"]
    
    FileUtils.mkdir_p("draveness/spool/mail") // create folder recursively
  • Bridge between NS to swift type

    let str: NSString = "string"
    "string".bridge         //=> String
    "string".bridge.bridge  //=> NSString

Documentation

Full documentation for RbSwift can be found here.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate RbSwift into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'RbSwift', '~> 0.5.0'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralised dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate RbSwift into your Xcode project using Carthage, specify it in your Cartfile:

github "Draveness/RbSwift" ~> 0.5.0

Run carthage update to build the framework and drag the built RbSwift.framework into your Xcode project.

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but RbSwift does support its use on supported platforms.

Once you have your Swift package set up, adding RbSwift as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "https://github.com/Draveness/RbSwift.git", majorVersion: 0)
]

Manually

If you prefer not to use either of the aforementioned dependency managers, you can integrate RbSwift into your project manually.

Contact

Follow and contact me with email. If you find an issue, open a ticket. Pull requests are warmly welcome as well.

License

RbSwift is released under the MIT license. See LICENSE for details.

More Repositories

1

analyze

Draven's Blog
Objective-C
8,089
star
2

DKNightVersion

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)
Objective-C
3,556
star
3

DKChainableAnimationKit

A DSL to make animation easy on iOS with Swift.
Swift
1,892
star
4

NightNight

Elegant way to integrate night mode to swift projects
Swift
776
star
5

Typeset

Deal with AttributedString efficiently
Objective-C
450
star
6

go-internal

《Go 语言设计与实现》示例代码
Go
263
star
7

Ouroboros

🐍 ObjectiveC library for magical scroll interactions.
Objective-C
149
star
8

blog-comments

面向信仰编程
140
star
9

ATProperty

☀️ Create @property with shortcut
Objective-C
136
star
10

proxier

A better approach to expose application in Kubernetes.
Go
109
star
11

linux-archive

Linux archive for studying the process scheduler. 调度系统设计精要 http://draveness.me/system-design-scheduler
C
87
star
12

JSONCop

A better way to deal with JSON parsing in Swift.
Ruby
30
star
13

Mineral

A library used to separate concerns from the original UIKit framework.
Swift
29
star
14

ChainableKit

Chainable UIKit in Objective-C
Objective-C
27
star
15

oceanbook

A Modern Matching Engine without documentation YET [alpha]
Go
25
star
16

Crotalus

Elegant approach to create AttributedString in swift
Swift
19
star
17

SpaceShuttle

🚀 A library manages Inter-View value passing
Objective-C
13
star
18

OKObserver

A lightweight wrapper for KVO, bind view and model easily
Objective-C
12
star
19

go-utils

Go
11
star
20

draveness

10
star
21

git-ignore

Rust
3
star
22

tmpwatch-controller

Dockerfile
2
star
23

gitbook-plugin-gitalk

JavaScript
2
star
24

Daytabase

An key/value store database built atop sqlite
Swift
1
star