Skip to content

Commit e3628e7

Browse files
committed
add tests; rename raizFutura to raízFutura; bump version
1 parent 1790d1c commit e3628e7

File tree

11 files changed

+251
-49
lines changed

11 files changed

+251
-49
lines changed

.swiftlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
disabled_rules:
33
- line_length
44
- function_body_length
5+
- function_parameter_count
56
- type_body_length
67
- identifier_name
78
- cyclomatic_complexity

Conjugar/Conjugator.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ class Conjugator {
102102
if !["ar", "er", "ir", "ír"].contains(ending) {
103103
return .failure(.invalidEnding(ending))
104104
}
105-
if (tense == .gerundio || tense == .participio || tense == .raizFutura || tense == .translation) && personNumber != .none {
105+
if (tense == .gerundio || tense == .participio || tense == .raízFutura || tense == .translation) && personNumber != .none {
106106
return .failure(.noSuchConjugation(personNumber))
107107
}
108-
if (tense != .gerundio && tense != .participio && tense != .raizFutura && tense != .translation) && personNumber == .none {
108+
if (tense != .gerundio && tense != .participio && tense != .raízFutura && tense != .translation) && personNumber == .none {
109109
return .failure(.personNumberAbsent(tense))
110110
}
111111

@@ -139,29 +139,29 @@ class Conjugator {
139139
return .success(Conjugator.defective)
140140
}
141141
let conjugationKey: String
142-
if tense == .gerundio || tense == .participio || tense == .raizFutura || tense == .translation {
142+
if tense == .gerundio || tense == .participio || tense == .raízFutura || tense == .translation {
143143
conjugationKey = tense.rawValue
144144
} else {
145145
conjugationKey = personNumber.rawValue + tense.rawValue
146146
}
147-
if tense == .raizFutura && verb[conjugationKey] == nil {
147+
if tense == .raízFutura && verb[conjugationKey] == nil {
148148
guard let parent = verb[Conjugator.parent] else {
149149
fatalError("verb[\(Conjugator.parent) was nil.")
150150
}
151151

152-
guard case .success(let parentStem) = conjugateRecursively(infinitive: parent, tense: .raizFutura, personNumber: .none) else {
152+
guard case .success(let parentStem) = conjugateRecursively(infinitive: parent, tense: .raízFutura, personNumber: .none) else {
153153
fatalError("parentStem was nil.")
154154
}
155155
let trim = verb[Conjugator.trim] ?? ""
156156
let stem = verb[Conjugator.stem] ?? ""
157-
var raizFutura: String
157+
var raízFutura: String
158158
if trim == "" {
159-
raizFutura = stem + parentStem
159+
raízFutura = stem + parentStem
160160
} else {
161-
raizFutura = parentStem.replaceFirstOccurence(of: trim, with: stem)
161+
raízFutura = parentStem.replaceFirstOccurence(of: trim, with: stem)
162162
}
163-
verb[conjugationKey] = raizFutura
164-
return .success(raizFutura)
163+
verb[conjugationKey] = raízFutura
164+
return .success(raízFutura)
165165
}
166166
if let conjugation = verb[conjugationKey] {
167167
return .success(conjugation)
@@ -174,9 +174,9 @@ class Conjugator {
174174
}
175175
let trim: String
176176
let stem: String
177-
if (tense == .futuroDeIndicativo || tense == .condicional) && verb[Tense.raizFutura.rawValue] != nil {
177+
if (tense == .futuroDeIndicativo || tense == .condicional) && verb[Tense.raízFutura.rawValue] != nil {
178178
trim = parent
179-
stem = verb[Tense.raizFutura.rawValue] ?? ""
179+
stem = verb[Tense.raízFutura.rawValue] ?? ""
180180
} else {
181181
trim = verb[Conjugator.trim] ?? ""
182182
stem = verb[Conjugator.stem] ?? ""
@@ -191,12 +191,12 @@ class Conjugator {
191191
verbs[infinitive] = verb
192192
return .success(conjugation)
193193
} else if [Tense.futuroDeIndicativo, Tense.condicional].contains(tense) {
194-
var futureStem = verb[Tense.raizFutura.rawValue]
194+
var futureStem = verb[Tense.raízFutura.rawValue]
195195
if futureStem == nil {
196196
guard let parent = verb[Conjugator.parent] else {
197197
fatalError("verb[\(Conjugator.parent) was nil.")
198198
}
199-
guard case .success(let parentStem) = conjugateRecursively(infinitive: parent, tense: .raizFutura, personNumber: .none) else {
199+
guard case .success(let parentStem) = conjugateRecursively(infinitive: parent, tense: .raízFutura, personNumber: .none) else {
200200
fatalError("parentStem was nil.")
201201
}
202202
let trim = verb[Conjugator.trim] ?? ""

Conjugar/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3</string>
18+
<string>1.4</string>
1919
<key>CFBundleVersion</key>
20-
<string>23</string>
20+
<string>24</string>
2121
<key>LSRequiresIPhoneOS</key>
2222
<true/>
2323
<key>UILaunchStoryboardName</key>

Conjugar/PersonNumber.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ enum PersonNumber: String, CaseIterable {
5757
return "none"
5858
}
5959
}
60+
61+
static let actualPersonNumbers: [PersonNumber] = [.firstSingular, .secondSingularTu, .secondSingularVos, .thirdSingular, .firstPlural, .secondPlural, .thirdPlural]
6062
}

Conjugar/Tense.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ enum Tense: String, CaseIterable {
1313
case translation = "tn"
1414
case gerundio = "ge"
1515
case participio = "po"
16-
case raizFutura = "rf"
16+
case raízFutura = "rf"
1717

1818
case imperativoPositivo = "io"
1919
case imperativoNegativo = "ni"
@@ -44,7 +44,7 @@ enum Tense: String, CaseIterable {
4444
extraConjugation = 1
4545
}
4646
switch self {
47-
case .infinitivo, .translation, .gerundio, .participio, .raizFutura:
47+
case .infinitivo, .translation, .gerundio, .participio, .raízFutura:
4848
return 0
4949
case .imperativoPositivo, .imperativoNegativo:
5050
return 5 + extraConjugation
@@ -60,7 +60,7 @@ enum Tense: String, CaseIterable {
6060
var hasYoForm: Bool {
6161
switch self {
6262
case .imperativoPositivo, .imperativoNegativo,
63-
.infinitivo, .translation, .gerundio, .participio, .raizFutura:
63+
.infinitivo, .translation, .gerundio, .participio, .raízFutura:
6464
return false
6565
case .presenteDeIndicativo, .preterito, .imperfectoDeIndicativo, .futuroDeIndicativo, .condicional,
6666
.presenteDeSubjuntivo, .imperfectoDeSubjuntivo1, .imperfectoDeSubjuntivo2, .futuroDeSubjuntivo,
@@ -81,7 +81,7 @@ enum Tense: String, CaseIterable {
8181
return "gerundio"
8282
case .participio:
8383
return "participio"
84-
case .raizFutura:
84+
case .raízFutura:
8585
return "raíz futura"
8686
case .imperativoPositivo:
8787
return "imperativo positivo"
@@ -136,7 +136,7 @@ enum Tense: String, CaseIterable {
136136
return "Gerundio"
137137
case .participio:
138138
return "Participio"
139-
case .raizFutura:
139+
case .raízFutura:
140140
return "Raíz Futura"
141141
case .imperativoPositivo:
142142
return "Imperativo Positivo"

Conjugar/VerbParser.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class VerbParser: NSObject, XMLParserDelegate {
5050
if let po = attributeDict[Tense.participio.rawValue] {
5151
currentConjugations[Tense.participio.rawValue] = po
5252
}
53-
if let rf = attributeDict[Tense.raizFutura.rawValue] {
54-
currentConjugations[Tense.raizFutura.rawValue] = rf
53+
if let rf = attributeDict[Tense.raízFutura.rawValue] {
54+
currentConjugations[Tense.raízFutura.rawValue] = rf
5555
}
5656
if let pe = attributeDict[Conjugator.parent] {
5757
currentConjugations[Conjugator.parent] = pe

Conjugar/VerbVC.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class VerbVC: UIViewController {
3131
override func loadView() {
3232
let verbView = VerbView(frame: UIScreen.main.bounds)
3333
verbView.participio.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapSpanish(_:))))
34-
verbView.raizFutura.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapSpanish(_:))))
34+
verbView.raízFutura.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapSpanish(_:))))
3535
verbView.gerundio.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapSpanish(_:))))
3636
verbView.translation.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapEnglish(_:))))
3737
verbView.defectivo.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapEnglish(_:))))
@@ -60,10 +60,10 @@ class VerbVC: UIViewController {
6060
default:
6161
fatalError()
6262
}
63-
let raizFuturaResult = Conjugator.shared.conjugate(infinitive: verb, tense: .raizFutura, personNumber: .none)
64-
switch raizFuturaResult {
63+
let raízFuturaResult = Conjugator.shared.conjugate(infinitive: verb, tense: .raízFutura, personNumber: .none)
64+
switch raízFuturaResult {
6565
case let .success(value):
66-
verbView.raizFutura.attributedText = value.conjugatedString + NSAttributedString(string: "-")
66+
verbView.raízFutura.attributedText = value.conjugatedString + NSAttributedString(string: "-")
6767
default:
6868
fatalError()
6969
}

Conjugar/VerbView.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ class VerbView: UIView {
1313
let parentOrType = UILabel()
1414
let participio = UILabel()
1515
let gerundio = UILabel()
16-
let raizFutura = UILabel()
16+
let raízFutura = UILabel()
1717
let defectivo = UILabel()
18-
private let raizFuturaLabel = UILabel()
18+
private let raízFuturaLabel = UILabel()
1919

2020
let table: UITableView = {
2121
let tableView = UITableView()
@@ -30,18 +30,18 @@ class VerbView: UIView {
3030

3131
override init(frame: CGRect) {
3232
super.init(frame: frame)
33-
[translation, parentOrType, participio, gerundio, raizFuturaLabel, raizFutura, defectivo].forEach {
33+
[translation, parentOrType, participio, gerundio, raízFuturaLabel, raízFutura, defectivo].forEach {
3434
$0.font = Fonts.label
3535
$0.textColor = Colors.yellow
3636
$0.enableAutoLayout()
3737
}
38-
raizFuturaLabel.text = "RF:"
38+
raízFuturaLabel.text = "RF:"
3939

40-
[translation, participio, gerundio, raizFutura, defectivo].forEach {
40+
[translation, participio, gerundio, raízFutura, defectivo].forEach {
4141
$0.isUserInteractionEnabled = true
4242
}
4343

44-
[table, translation, parentOrType, participio, gerundio, raizFuturaLabel, raizFutura, defectivo].forEach {
44+
[table, translation, parentOrType, participio, gerundio, raízFuturaLabel, raízFutura, defectivo].forEach {
4545
addSubview($0)
4646
}
4747

@@ -57,16 +57,16 @@ class VerbView: UIView {
5757
gerundio.topAnchor.constraint(equalTo: parentOrType.bottomAnchor, constant: Layout.defaultSpacing).activate()
5858
gerundio.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).activate()
5959

60-
raizFuturaLabel.topAnchor.constraint(equalTo: participio.bottomAnchor, constant: Layout.defaultSpacing).activate()
61-
raizFuturaLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).activate()
60+
raízFuturaLabel.topAnchor.constraint(equalTo: participio.bottomAnchor, constant: Layout.defaultSpacing).activate()
61+
raízFuturaLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).activate()
6262

63-
raizFutura.topAnchor.constraint(equalTo: participio.bottomAnchor, constant: Layout.defaultSpacing).activate()
64-
raizFutura.leadingAnchor.constraint(equalTo: raizFuturaLabel.trailingAnchor, constant: Layout.defaultSpacing).activate()
63+
raízFutura.topAnchor.constraint(equalTo: participio.bottomAnchor, constant: Layout.defaultSpacing).activate()
64+
raízFutura.leadingAnchor.constraint(equalTo: raízFuturaLabel.trailingAnchor, constant: Layout.defaultSpacing).activate()
6565

6666
defectivo.topAnchor.constraint(equalTo: gerundio.bottomAnchor, constant: Layout.defaultSpacing).activate()
6767
defectivo.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).activate()
6868

69-
table.topAnchor.constraint(equalTo: raizFuturaLabel.bottomAnchor, constant: Layout.defaultSpacing).activate()
69+
table.topAnchor.constraint(equalTo: raízFuturaLabel.bottomAnchor, constant: Layout.defaultSpacing).activate()
7070
table.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).activate()
7171
table.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).activate()
7272
table.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor, constant: -1.0 * Layout.defaultSpacing).activate()

ConjugarTests/Controllers/BrowseVerbsVCTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ class BrowseVerbsVCTests: XCTestCase {
1919
XCTAssertNotNil(bvvc)
2020
bvvc.viewWillAppear(true)
2121
XCTAssertEqual(analytic, "visited viewController: \(BrowseVerbsVC.self) ")
22-
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 86)
22+
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 92)
2323
bvvc.browseVerbsView.filterControl.selectedSegmentIndex = 1
24-
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 103)
24+
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 105)
2525
bvvc.browseVerbsView.filterControl.selectedSegmentIndex = 2
26-
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 189)
26+
XCTAssertEqual(bvvc.tableView(UITableView(), numberOfRowsInSection: 0), 197)
2727
bvvc.tableView(UITableView(), didSelectRowAt: IndexPath(row: 0, section: 0))
2828
XCTAssertTrue(nc.pushedViewController is VerbVC)
2929
}

0 commit comments

Comments
 (0)