Skip to content

Commit

Permalink
comicbook standardized to comicBook
Browse files Browse the repository at this point in the history
  • Loading branch information
jpavley committed Jun 28, 2019
1 parent cf44ddd commit b44d4bb
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class EditComicBookViewController: UITableViewController {
navigationBroken = false
updateUI()

if comicBookCollection.comicbooks.isEmpty {
if comicBookCollection.comicBooks.isEmpty {
loadDummyComicBook()
} else {
loadRealComicBooks()
Expand All @@ -103,9 +103,9 @@ class EditComicBookViewController: UITableViewController {
private func loadDummyComicBook() {

let cb1 = ComicBookCollection.createComicBook("", "", "", "", "", "", nil, nil, nil, nil, "")
comicBookCollection.comicbooks = [cb1]
comicBookCollection.comicBooks = [cb1]
currentIdentifier = ComicBookCollection.emptyComicIdentifier
comicBookUnderEdit = comicBookCollection.comicbooks[0]
comicBookUnderEdit = comicBookCollection.comicBooks[0]

title = "Add Comic Book"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class SeriesTableViewController: UITableViewController {
let segueSource = segue.source as! EditComicBookViewController

comicBookCollection = segueSource.comicBookCollection
comicBookCollection.comicbooks.sort()
comicBookCollection.comicBooks.sort()
tableView.reloadData()
}
}
4 changes: 2 additions & 2 deletions Comic Keeper/Models/ComicBookCollection+Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ public extension ComicBookCollection {
let cb33 = createComicBook("Marvel Comics", "Fantastic Four", "1968", "101", "101", "x", nil, nil, nil, nil, "Very Goodf")


cbc.comicbooks = [cb11, cb12, cb13, cb14, cb15, cb16, cb17, cb18, cb19, cb20, cb21, cb22, cb23, cb24, cb25, cb26, cb27, cb28, cb29, cb30, cb31, cb32, cb33, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb2, cb1, cb3, cb4a, cb5a, cb6a, cb7a, cb4b, cb5b, cb6b, cb7b, cb16a, cb17a, cb28a, cb29b, cb30c]
cbc.comicBooks = [cb11, cb12, cb13, cb14, cb15, cb16, cb17, cb18, cb19, cb20, cb21, cb22, cb23, cb24, cb25, cb26, cb27, cb28, cb29, cb30, cb31, cb32, cb33, cb4, cb5, cb6, cb7, cb8, cb9, cb10, cb2, cb1, cb3, cb4a, cb5a, cb6a, cb7a, cb4b, cb5b, cb6b, cb7b, cb16a, cb17a, cb28a, cb29b, cb30c]

cbc.comicbooks = cbc.comicbooks.sorted()
cbc.comicBooks = cbc.comicBooks.sorted()

return cbc
}
Expand Down
30 changes: 15 additions & 15 deletions Comic Keeper/Models/ComicBookCollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import Foundation

public class ComicBookCollection {

public var comicbooks: [ComicBook]
public var comicBooks: [ComicBook]
public static let emptyComicIdentifier = ""

init() {
comicbooks = [ComicBook]()
comicBooks = [ComicBook]()
}

// TODO: Merge publisherNames with starterPublisherNames

/// The names of all the publishers in this collection.
/// - No duplicates!
public var publisherNames: [String] {
let publisherNames = comicbooks.map {$0.comic.publisher}
let publisherNames = comicBooks.map {$0.comic.publisher}
var filteredNames = [String]()

// early return if we have no actual publishers
Expand All @@ -46,7 +46,7 @@ public class ComicBookCollection {
// TODO: Merge seriesNames with starterSeriesNames

public var seriesNames: [String] {
let seriesNames = comicbooks.map {$0.comic.series}
let seriesNames = comicBooks.map {$0.comic.series}
var filteredNames = [String]()

// early return if we have no actual publishers
Expand Down Expand Up @@ -110,7 +110,7 @@ public class ComicBookCollection {
/// - Parameter publisherName: unique name of the publisher
/// - Returns: list of series unique names (name + era)
public func seriesTitles(for publisherName: String) -> [String] {
let seriesTitles = comicbooks.compactMap {$0.comic.publisher == publisherName ? $0.seriesTitle : nil}
let seriesTitles = comicBooks.compactMap {$0.comic.publisher == publisherName ? $0.seriesTitle : nil}
var filteredNames = [String]()
seriesTitles.forEach { name in
if !filteredNames.contains(name) {
Expand All @@ -123,7 +123,7 @@ public class ComicBookCollection {
// TODO: seriesNames(for:) is too vauge, change to seriesNamesFor(publisher:)

public func seriesNames(for publisherName: String) -> [String] {
let seriesNames = comicbooks.compactMap {$0.comic.publisher == publisherName ? $0.seriesName : nil}
let seriesNames = comicBooks.compactMap {$0.comic.publisher == publisherName ? $0.seriesName : nil}
var filteredNames = [String]()
seriesNames.forEach { name in
if !filteredNames.contains(name) {
Expand All @@ -147,7 +147,7 @@ public class ComicBookCollection {
/// - publisherName: unique name of the publisher
/// - Returns: list of issues numbers as list of strings
public func issuesNumbers(seriesTitle: String, publisherName: String) -> [String] {
let issueNumbers = comicbooks.compactMap {
let issueNumbers = comicBooks.compactMap {
$0.comic.publisher == publisherName && $0.seriesTitle == seriesTitle ? $0.comic.issueNumber : nil
}
var filteredNumbers = [String]()
Expand All @@ -166,7 +166,7 @@ public class ComicBookCollection {
// TODO: Should it be variantSignifiers(publisher:series:era:issueNUmber) ?

public func variantSignifiers(issueNumber: String, seriesTitle: String, publisherName: String) -> [String] {
let variants = comicbooks.compactMap {
let variants = comicBooks.compactMap {
$0.comic.publisher == publisherName && $0.seriesTitle == seriesTitle && $0.comic.issueNumber == issueNumber ? $0.comic.variant : nil
}
return variants
Expand Down Expand Up @@ -198,7 +198,7 @@ public class ComicBookCollection {

/// Get a comic book by navigation hierarchy identifier
public func comicBook(from identifier: String) -> ComicBook? {
let comicBook = comicbooks.filter { $0.identifier == identifier }
let comicBook = comicBooks.filter { $0.identifier == identifier }
return comicBook.first
}

Expand All @@ -210,7 +210,7 @@ public class ComicBookCollection {
/// - UUIDs change with every run of an app.
/// - Don't use UUIDs between sessions unless you manually persist and assign them
public func comicBook(from guid: UUID) -> ComicBook? {
let comicBook = comicbooks.filter { $0.guid == guid }
let comicBook = comicBooks.filter { $0.guid == guid }
return comicBook.first
}

Expand All @@ -224,18 +224,18 @@ public class ComicBookCollection {
}

public func addComicBook(newComicBook: ComicBook) {
self.comicbooks.append(newComicBook)
self.comicbooks.sort()
self.comicBooks.append(newComicBook)
self.comicBooks.sort()
}

public func comicBookExists(guid: UUID) -> Bool {
return self.comicBook(from: guid) != nil
}

public func deleteComicBook(with guid: UUID) {
let updatedComicBooks = self.comicbooks.filter { $0.guid != guid }
self.comicbooks = updatedComicBooks
self.comicbooks.sort()
let updatedComicBooks = self.comicBooks.filter { $0.guid != guid }
self.comicBooks = updatedComicBooks
self.comicBooks.sort()
}

}
6 changes: 3 additions & 3 deletions ComicBookTests/ComicBookTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ class ComicBookTests: XCTestCase {
func testCreateComicBookCollection() {
let localCbcUT = ComicBookCollection()
XCTAssertNotNil(localCbcUT)
XCTAssertTrue(localCbcUT.comicbooks.count == 0)
XCTAssertTrue(localCbcUT.comicBooks.count == 0)
}

func testCreateComicBookCollectionWithData() {
XCTAssertNotNil(cbcUT)
XCTAssertEqual(cbcUT.comicbooks.count, dummyDataComicBookCount)
XCTAssertEqual(cbcUT.comicbooks.first!.identifier, dummyDataComicBookFirstIdentifier)
XCTAssertEqual(cbcUT.comicBooks.count, dummyDataComicBookCount)
XCTAssertEqual(cbcUT.comicBooks.first!.identifier, dummyDataComicBookFirstIdentifier)
}

func testPublisherNames() {
Expand Down

0 comments on commit b44d4bb

Please sign in to comment.