Skip to content

Instantly share code, notes, and snippets.

View eofster's full-sized avatar

Alexey Kuznetsov eofster

View GitHub Profile
@eofster
eofster / TrackSummary.swift
Created December 15, 2015 12:39
GPS track summary data structure
struct TrackSummary {
let trackID: Int
let name: String
let startTime: Double
let distance: Float
}
@eofster
eofster / TrackRepository.swift
Created December 15, 2015 12:38
GPS track repository
protocol TrackRepository {}
class TrackRepositoryImpl {}
extension TrackRepositoryImpl: TrackRepository {}
@eofster
eofster / TrackNameUpdateInteractor.swift
Created December 15, 2015 12:33
Interactor for updating GPS track name in the store
class TrackNameUpdateInteractor {
let repository: TrackRepository
init(repository: TrackRepository) {
self.repository = repository
}
}
extension TrackNameUpdateInteractor: Interactor {
func execute() {
@eofster
eofster / TrackSummaryInteractor.swift
Last active December 16, 2015 09:06
Interactor for presenting GPS track summary
protocol TrackSummaryInteractorOutput {
func update(track: TrackSummary)
}
class TrackSummaryInteractor {
let repository: TrackRepository
let output: TrackSummaryInteractorOutput
init(repository: TrackRepository, output: TrackSummaryInteractorOutput) {
self.repository = repository
@eofster
eofster / Interactor.swift
Created December 15, 2015 12:25
Interactor protocol
protocol Interactor {
func execute()
}
@eofster
eofster / TrackSummaryComposition.swift
Last active December 8, 2015 15:42
GPS track summary composition
let interactor = TrackSummaryInteractor(
output: TrackSummaryPresenter(
output: TrackSummaryViewController()
)
)
interactor.execute()
@eofster
eofster / TrackSummaryViewController.swift
Created December 8, 2015 14:29
GPS track summary view controller
import UIKit
class TrackSummaryViewController: UIViewController {
@IBOutlet private(set) var nameLabel: UILabel!
@IBOutlet private(set) var dateLabel: UILabel!
@IBOutlet private(set) var distanceLabel: UILabel!
}
extension TrackSummaryViewController: TrackSummaryPresenterOutput {
func setName(name: String) {
@eofster
eofster / TrackSummaryPresenterTests.swift
Last active December 8, 2015 14:24
GPS track summary presenter tests
import Foundation
import XCTest
class TrackSummaryPresenterTests: XCTestCase {
func testCallsOutputWithExpectedValues() {
let outputSpy = TrackSummaryPresenterOutputSpy()
let presenter = TrackSummaryPresenter(output: outputSpy)
let track = TrackSummary(name: "Trip", startTime: 1449567617, distance: 200)
presenter.update(track)
@eofster
eofster / TrackSummaryPresenter.swift
Last active December 8, 2015 16:04
GPS track summary presenter
import Foundation
protocol TrackSummaryPresenterOutput {
func setName(name: String)
func setDate(date: String)
func setDistance(distance: String)
}
class TrackSummaryPresenter {
let output: TrackSummaryPresenterOutput
@eofster
eofster / TrackSummaryInteractor.swift
Created December 8, 2015 13:57
Use case for presenting GPS track summary
protocol TrackSummaryInteractorOutput {
func update(track: TrackSummary)
}
class TrackSummaryInteractor {
let output: TrackSummaryInteractorOutput
init(output: TrackSummaryInteractorOutput) {
self.output = output
}