Giter VIP home page Giter VIP logo

rbswift's Introduction

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.

rbswift's People

Contributors

draveness avatar muizidn avatar whirlwind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rbswift's Issues

Carthage install not work on Xcode 10.1

Carthage build failed on Apple Swift version 4.2.1.

Cartfile:

github "Draveness/RbSwift" "master"
 ✘  /d/s/macOS   master ±  carthage update --platform macOS
*** Fetching RbSwift
*** Checking out RbSwift at "f4492d4dfbd5ecc6b299e424bfd7f36aa619098c"
*** xcodebuild output can be found in /var/folders/y0/x6j7_86s6c9br9r5yfhk11n80000gn/T/carthage-xcodebuild.1ikVNW.log
*** Building scheme "RbSwift macOS" in RbSwift.xcworkspace
Build Failed
	Task failed with exit code 65:
	/usr/bin/xcrun xcodebuild -workspace /data/simrganizer/macOS/Carthage/Checkouts/RbSwift/RbSwift.xcworkspace -scheme RbSwift\ macOS -configuration Release -derivedDataPath /Users/alek/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/RbSwift/f4492d4dfbd5ecc6b299e424bfd7f36aa619098c ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/y0/x6j7_86s6c9br9r5yfhk11n80000gn/T/RbSwift SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /data/simple-photo-organizer/macOS/Carthage/Checkouts/RbSwift)

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/y0/x6j7_86s6c9br9r5yfhk11n80000gn/T/carthage-xcodebuild.1ikVNW.log

logfile:

/usr/bin/xcrun xcodebuild -workspace /data/snizer/macOS/Carthage/Checkouts/RbSwift/RbSwift.xcworkspace -scheme RbSwift\ macOS -configuration Release -derivedDataPath /Users/alov/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/RbSwift/f4492d4dfbd5ecc6b299e424bfd7f36aa619098c ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath /var/folders/y0/x6j7_86s6c9br9r5yfhk11n80000gn/T/RbSwift SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO STRIP_INSTALLED_PRODUCT=NO (launched in /data/snizer/macOS/Carthage/Checkouts/RbSwift)User defaults from command line:
    IDEArchivePathOverride = /var/folders/y0/x6j7_86s6c9br9r5yfhk11n80000gn/T/RbSwift
    IDEDerivedDataPathOverride = /Users/alrov/Library/Caches/org.carthage.CarthageKit/DerivedData/10.1_10B61/RbSwift/f4492d4dfbd5ecc6b299e424bfd7f36aa619098c

Build settings from command line:
    CARTHAGE = YES
    CLANG_ENABLE_CODE_COVERAGE = NO
    CODE_SIGN_IDENTITY = 
    CODE_SIGNING_REQUIRED = NO
    GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO
    ONLY_ACTIVE_ARCH = NO
    SKIP_INSTALL = YES
    STRIP_INSTALLED_PRODUCT = NO

note: Using new build system
note: Planning build
note: Constructing build description
Build system information
error: /data/snizer/macOS/Carthage/Checkouts/RbSwift/Pods/Target Support Files/Pods-RbSwift macOS/Pods-RbSwift macOS.release.xcconfig: unable to open file (in target "RbSwift macOS" in project "RbSwift") (in target 'RbSwift macOS')

Build system information
error: /data/snizer/macOS/Carthage/Checkouts/RbSwift/Pods/Target Support Files/Pods-RbSwift macOS/Pods-RbSwift macOS.release.xcconfig: unable to open file (in target "RbSwift macOS" in project "RbSwift") (in target 'RbSwift macOS')

Build system information
error: /data/snizer/macOS/Carthage/Checkouts/RbSwift/Pods/Target Support Files/Pods-RbSwift macOS/Pods-RbSwift macOS.release.xcconfig: unable to open file (in target "RbSwift macOS" in project "RbSwift") (in target 'RbSwift macOS')

** ARCHIVE FAILED **


flatten & select

I tried this in playground:

let count = [1, 2, 3, nil, nil, 4, 5, 6, 7]
.flatten()

and I got an error:

Playground execution failed:

error: RbSwift.playground:1:6: error: cannot invoke 'flatten' with no arguments
.flatten()
^

and I tried this in playground:

let count = [1, 2, 3, nil, nil, 4, 5, 6, 7]
.flatten()
.select { true }

and I got count was a :

[]

Please update pod.

Although

public static func chdir<T>(_ path: String = "~", closure: (() -> T)) -> T {
        let pwd = Dir.pwd
        Dir.chdir(path)
        let result = closure()
        Dir.chdir(pwd)
        return result
 }

But if you install through Pod it still

public static func chdir<T>(_ path: String = "~", closure: ((Void) -> T)) -> T {
        let pwd = Dir.pwd
        Dir.chdir(path)
        let result = closure()
        Dir.chdir(pwd)
        return result
}

Which in Swift 4 or later will generate error since it must pass tuple () to closure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.