Skip to content

Commit

Permalink
Merge branch 'release/0.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hardtack committed Jul 9, 2016
2 parents eb5dd13 + c9bcf87 commit 2ad8f1b
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 139 deletions.
30 changes: 21 additions & 9 deletions .travis.yml
@@ -1,14 +1,26 @@
osx_image: xcode7.3
language: objective-c
cache: cocoapods
podfile: Example/Podfile
rvm:
- 2.3.1
language: objective-c
cache:
- bundler
- cocoapods
podfile: Example/Podfile
before_install:
- sudo gem install bundler
- bundle install
- pod repo update
- pod install --project-directory=Example
- bundle install
- pod repo remove master
- pod setup
install:
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- bundle exec pod install --project-directory=Example
script:
- set -o pipefail && xcodebuild test -workspace Example/RxMVC.xcworkspace -scheme RxMVC-Example -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint
- >
set -o pipefail &&
xcodebuild test
-workspace Example/RxMVC.xcworkspace
-scheme RxMVC-Example
-sdk iphonesimulator9.3
-jobs `sysctl hw.ncpu | awk '{print 2*$2}'`
ONLY_ACTIVE_ARCH=NO | xcpretty
- pod lib lint

3 changes: 0 additions & 3 deletions Example/Podfile
Expand Up @@ -9,10 +9,7 @@ target 'RxMVC_Example' do
target 'RxMVC_Tests' do
inherit! :search_paths

pod 'Quick', '~> 0.8'
pod 'RxBlocking', '~> 2.5'
pod 'RxTests', '~> 2.5'
pod 'Quick', '~> 0.8'
pod 'Nimble', '~> 3.0'
end
end
8 changes: 1 addition & 7 deletions Example/Podfile.lock
@@ -1,8 +1,6 @@
PODS:
- Alamofire (3.4.1)
- JLToast (1.4.2)
- Nimble (3.2.0)
- Quick (0.9.2)
- Reachability (3.2)
- RxAlamofire (2.5):
- RxAlamofire/Core (= 2.5)
Expand All @@ -22,8 +20,6 @@ PODS:

DEPENDENCIES:
- JLToast (~> 1.4)
- Nimble (~> 3.0)
- Quick (~> 0.8)
- Reachability (~> 3.0)
- RxAlamofire (~> 2.0)
- RxBlocking (~> 2.5)
Expand All @@ -37,8 +33,6 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Alamofire: 01a82e2f6c0f860ade35534c8dd88be61bdef40c
JLToast: bf63282a7df069557e80c77dbd2c6b9f9fc4de72
Nimble: 703854335d181df169bbca9c97117b5cf8c47c1d
Quick: 18d057bc66451eedd5d1c8dc99ba2a5db6e60226
Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96
RxAlamofire: b4572a077b6b2410c8732a27266299df4c00736e
RxBlocking: 595d9ab56dde6b00beaa5aba40e95b150d2135f1
Expand All @@ -47,6 +41,6 @@ SPEC CHECKSUMS:
RxSwift: 402b41a50e922a0368fc14cb3bc9f4427920e8ae
RxTests: 1b13bea0a138552b52aeead549ef08d578bcda9e

PODFILE CHECKSUM: 856eb51429b6dde45667304822499856c2afcf58
PODFILE CHECKSUM: 37bccfc005668b46d59c9809a80e626165ad8447

COCOAPODS: 1.0.1
24 changes: 20 additions & 4 deletions Example/RxMVC.xcodeproj/project.pbxproj
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
235C93951CCE2CB700E67605 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 235C93901CCE2CB700E67605 /* AppDelegate.swift */; };
235C93991CCE2CB700E67605 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 235C93941CCE2CB700E67605 /* Main.storyboard */; };
5A7A266F1D30CB2900219E63 /* UpDownTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A7A266D1D30CB2400219E63 /* UpDownTest.swift */; };
5A7A26711D30CB4A00219E63 /* ModelTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5A7A26701D30CB4A00219E63 /* ModelTest.swift */; };
5AB80BB21D28402D00C13E1E /* GitHubSearchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB80BAF1D28402D00C13E1E /* GitHubSearchViewController.swift */; };
5AB80BB31D28402D00C13E1E /* MasterViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB80BB01D28402D00C13E1E /* MasterViewController.swift */; };
5AB80BB41D28402D00C13E1E /* UpDownViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AB80BB11D28402D00C13E1E /* UpDownViewController.swift */; };
Expand All @@ -19,7 +21,6 @@
5AF1FEF41D2D3F4F00018671 /* GitHubSearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5AF1FEF31D2D3F4F00018671 /* GitHubSearchView.swift */; };
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
698EE95498280C4D72969284 /* Pods_RxMVC_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 29FB0BBE892E25D5DB0879E8 /* Pods_RxMVC_Example.framework */; };
B9AA200CB24503358EFAA644 /* Pods_RxMVC_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B13A29920C873DAC049F638A /* Pods_RxMVC_Tests.framework */; };
/* End PBXBuildFile section */
Expand All @@ -38,6 +39,8 @@
235C93901CCE2CB700E67605 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
235C93941CCE2CB700E67605 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
29FB0BBE892E25D5DB0879E8 /* Pods_RxMVC_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RxMVC_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
5A7A266D1D30CB2400219E63 /* UpDownTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpDownTest.swift; sourceTree = "<group>"; };
5A7A26701D30CB4A00219E63 /* ModelTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModelTest.swift; sourceTree = "<group>"; };
5AB80BAF1D28402D00C13E1E /* GitHubSearchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GitHubSearchViewController.swift; sourceTree = "<group>"; };
5AB80BB01D28402D00C13E1E /* MasterViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MasterViewController.swift; sourceTree = "<group>"; };
5AB80BB11D28402D00C13E1E /* UpDownViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UpDownViewController.swift; sourceTree = "<group>"; };
Expand All @@ -52,7 +55,6 @@
607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
607FACE51AFB9204008FA782 /* RxMVC_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RxMVC_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
64F2E66B3CFB98E9E4EF9350 /* Pods-RxMVC_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RxMVC_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RxMVC_Example/Pods-RxMVC_Example.debug.xcconfig"; sourceTree = "<group>"; };
762337A399CB79B60E5F0239 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
AA1D28E0F1EF023DA619F8C0 /* RxMVC.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = RxMVC.podspec; path = ../RxMVC.podspec; sourceTree = "<group>"; };
Expand Down Expand Up @@ -83,6 +85,14 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
5A7A266C1D30CB2400219E63 /* Example */ = {
isa = PBXGroup;
children = (
5A7A266D1D30CB2400219E63 /* UpDownTest.swift */,
);
path = Example;
sourceTree = "<group>";
};
5AB80BAE1D28402D00C13E1E /* ViewControllers */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -169,8 +179,9 @@
607FACE81AFB9204008FA782 /* Tests */ = {
isa = PBXGroup;
children = (
607FACEB1AFB9204008FA782 /* Tests.swift */,
5A7A266C1D30CB2400219E63 /* Example */,
607FACE91AFB9204008FA782 /* Supporting Files */,
5A7A26701D30CB4A00219E63 /* ModelTest.swift */,
);
path = Tests;
sourceTree = "<group>";
Expand Down Expand Up @@ -420,7 +431,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */,
5A7A266F1D30CB2900219E63 /* UpDownTest.swift in Sources */,
5A7A26711D30CB4A00219E63 /* ModelTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -560,6 +572,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = E2721FBB958801016129AB50 /* Pods-RxMVC_Tests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -572,13 +585,15 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RxMVC_Example.app/RxMVC_Example";
};
name = Debug;
};
607FACF41AFB9204008FA782 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FC481AAF4732B6F4A2A15EEC /* Pods-RxMVC_Tests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -587,6 +602,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RxMVC_Example.app/RxMVC_Example";
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Example/RxMVC/Base.lproj/LaunchScreen.xib
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10116" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
Expand Down
110 changes: 61 additions & 49 deletions Example/RxMVC/ViewControllers/UpDownViewController.swift
Expand Up @@ -13,54 +13,43 @@ import RxSwift
import RxCocoa
import RxMVC

class UpDownViewController: UIViewController, View, UserInteractable {
enum Event {
case ClickUp
case ClickDown
case ClickReset
}

enum Action {
case Increase
case Decrease
case Reset
}

enum UpDownEvent {
case ClickUp
case ClickDown
case ClickReset
}

enum UpDownAction {
case Increase
case Decrease
case Reset
}

struct UpDownModel: ReducerModel {
typealias Action = UpDownAction
typealias State = Int

struct UpDownController: MapController {
func mapEventToAction(event: Event) -> Action {
switch event {
case .ClickUp:
return Action.Increase
case .ClickDown:
return Action.Decrease
default:
return Action.Reset
}
}
}

struct UpDownModel: ReducerModel {
let initialState = 0
func reduce(state: State, with action: Action) -> State {
switch action {
case .Increase:
return state + 1
case .Decrease:
return state - 1
case .Reset:
return initialState
}
let initialState = 0
func reduce(state: State, with action: Action) -> State {
switch action {
case .Increase:
return state + 1
case .Decrease:
return state - 1
case .Reset:
return initialState
}
}
}

struct UpDownView: View, UserInteractable {
typealias State = Int
typealias Event = UpDownEvent

@IBOutlet weak var countLabel: UILabel!
@IBOutlet weak var upButton: UIButton!
@IBOutlet weak var downButton: UIButton!
@IBOutlet weak var resetButton: UIButton!

var disposeBag = DisposeBag()
let countLabel: UILabel
let upButton: UIButton
let downButton: UIButton
let resetButton: UIButton

func update(stateStream: Observable<State>) -> Disposable {
return stateStream.subscribeNext { (number) in
Expand All @@ -75,17 +64,40 @@ class UpDownViewController: UIViewController, View, UserInteractable {
self.resetButton.rx_tap.map{_ in Event.ClickReset},
].toObservable().merge()
}
}

struct UpDownController: MapController {
typealias Event = UpDownEvent
typealias Action = UpDownAction

func mapEventToAction(event: Event) -> Action {
switch event {
case .ClickUp:
return Action.Increase
case .ClickDown:
return Action.Decrease
case .ClickReset:
return Action.Reset
}
}
}

class UpDownViewController: UIViewController {
@IBOutlet weak var countLabel: UILabel!
@IBOutlet weak var upButton: UIButton!
@IBOutlet weak var downButton: UIButton!
@IBOutlet weak var resetButton: UIButton!

var disposeBag = DisposeBag()

override func viewDidLoad() {
super.viewDidLoad()
let model = UpDownModel()
let view = self
let view = UpDownView(countLabel: countLabel,
upButton: upButton,
downButton: downButton,
resetButton: resetButton)
let controller = UpDownController()
combineModel(model, withView: view, controller: controller).addDisposableTo(disposeBag)
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
61 changes: 61 additions & 0 deletions Example/Tests/Example/UpDownTest.swift
@@ -0,0 +1,61 @@
//
// UpDownTest.swift
// RxMVC
//

import XCTest
import RxSwift
import RxBlocking
import RxTests
import RxMVC

@testable import RxMVC_Example

class UpDownTest: XCTestCase {
func testModel() {
let model = UpDownModel()
let scheduler = TestScheduler(initialClock: 0)
let xs = scheduler.createHotObservable([
next(210, UpDownAction.Increase),
next(220, UpDownAction.Increase),
next(230, UpDownAction.Increase),
next(240, UpDownAction.Decrease),
next(250, UpDownAction.Decrease),
next(260, UpDownAction.Reset),
next(270, UpDownAction.Increase),
completed(300)
])
let res = scheduler.start { model.manipulate(xs.asObservable()) }
let expected = [
next(200, 0),
next(210, 1),
next(220, 2),
next(230, 3),
next(240, 2),
next(250, 1),
next(260, 0),
next(270, 1),
completed(300)
]
XCTAssertEqual(res.events, expected)
}

func testController() {
let controller = UpDownController()
let scheduler = TestScheduler(initialClock: 0)
let xs = scheduler.createHotObservable([
next(210, UpDownEvent.ClickUp),
next(220, UpDownEvent.ClickDown),
next(230, UpDownEvent.ClickReset),
completed(300)
])
let res = scheduler.start { controller.use(xs.asObservable()) }
let expected = [
next(210, UpDownAction.Increase),
next(220, UpDownAction.Decrease),
next(230, UpDownAction.Reset),
completed(300)
]
XCTAssertEqual(res.events, expected)
}
}

0 comments on commit 2ad8f1b

Please sign in to comment.