-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#243 Added support to build the general service info json.
- Loading branch information
Showing
7 changed files
with
230 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,71 @@ | ||
PODS: | ||
- Cuckoo (1.4.1): | ||
- Cuckoo/Swift (= 1.4.1) | ||
- Cuckoo/Swift (1.4.1) | ||
- Floaty (4.1.0) | ||
- FMDB (2.7.5): | ||
- FMDB/standard (= 2.7.5) | ||
- FMDB/standard (2.7.5) | ||
- Nimble (9.0.0) | ||
- Quick (3.0.1) | ||
- SwiftLint (0.43.1) | ||
- SwiftyJSON (4.3.0) | ||
- Swinject (2.7.1) | ||
- SwinjectAutoregistration (2.7.0): | ||
- Swinject (~> 2.7) | ||
- SwinjectStoryboard (2.2.0): | ||
- Swinject (~> 2.7.1) | ||
- YouTubePlayer (0.7.2) | ||
|
||
DEPENDENCIES: | ||
- Cuckoo (~> 1.4.1) | ||
- Floaty | ||
- FMDB | ||
- Nimble (~> 9.0.0) | ||
- Quick (~> 3.0.0) | ||
- SwiftLint | ||
- SwiftyJSON (~> 4.0) | ||
- Swinject (~> 2.7.1) | ||
- SwinjectAutoregistration (~> 2.7.0) | ||
- SwinjectStoryboard (from `https://github.com/Swinject/SwinjectStoryboard.git`, commit `0ca45c83a8aa398c153d8a036c95abb4343cfa0c`) | ||
- YouTubePlayer | ||
|
||
SPEC REPOS: | ||
trunk: | ||
- Cuckoo | ||
- Floaty | ||
- FMDB | ||
- Nimble | ||
- Quick | ||
- SwiftLint | ||
- SwiftyJSON | ||
- Swinject | ||
- SwinjectAutoregistration | ||
- YouTubePlayer | ||
|
||
EXTERNAL SOURCES: | ||
SwinjectStoryboard: | ||
:commit: 0ca45c83a8aa398c153d8a036c95abb4343cfa0c | ||
:git: https://github.com/Swinject/SwinjectStoryboard.git | ||
|
||
CHECKOUT OPTIONS: | ||
SwinjectStoryboard: | ||
:commit: 0ca45c83a8aa398c153d8a036c95abb4343cfa0c | ||
:git: https://github.com/Swinject/SwinjectStoryboard.git | ||
|
||
SPEC CHECKSUMS: | ||
Cuckoo: 4625f7f54d9bb880123270e8969898d6c1d036b5 | ||
Floaty: 1a4e213f3512cf3045ef9cb0c1ff456226d1f66a | ||
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a | ||
Nimble: 3b4ec3fd40f1dc178058e0981107721c615643d8 | ||
Quick: 947834f0d0f43fc933d0e9dd00086a76e783e4fb | ||
SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52 | ||
SwiftyJSON: 6faa0040f8b59dead0ee07436cbf76b73c08fd08 | ||
Swinject: ddf78b8486dd9b71a667b852cad919ab4484478e | ||
SwinjectAutoregistration: 330f5012642a8b5c89a8a4adb0c5e52df07382c0 | ||
SwinjectStoryboard: f0d5b1c16459949d6ff1cbb6610107946b18e1f8 | ||
YouTubePlayer: 2b5f2830d8f9b2cde942083211291e382c9e6bd5 | ||
|
||
PODFILE CHECKSUM: 3716037c5bdd373db6ce39bd15f8bb05601b47ad | ||
PODFILE CHECKSUM: 80c9bc412ec80c0fd73847de777b8bf809ed5265 | ||
|
||
COCOAPODS: 1.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Author: James Selvakumar | ||
// Since: 3.0.0 | ||
// Copyright © 2021 mCruncher. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftyJSON | ||
|
||
protocol IOpenLPServiceConverter { | ||
func toOszlJson(favouriteList: [FavoritesSongsWithOrder]) -> JSON | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Author: James Selvakumar | ||
// Since: 3.0.0 | ||
// Copyright © 2021 mCruncher. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import SwiftyJSON | ||
|
||
class OpenLPServiceConverter : IOpenLPServiceConverter { | ||
func toOszlJson(favouriteList: [FavoritesSongsWithOrder]) -> JSON { | ||
let serviceItemHeaderContent = [ | ||
"name": "songs", | ||
"plugin": "songs" | ||
] as [String: Any?] | ||
|
||
let serviceItemHeader = [ | ||
"header": serviceItemHeaderContent | ||
] as [String: Any?] | ||
|
||
let serviceItem = ["serviceItem": serviceItemHeader] as [String: Any?] | ||
|
||
let openLPService = [getGeneralServiceInfo(), serviceItem, serviceItem] | ||
|
||
return JSON(openLPService) | ||
} | ||
|
||
private func getGeneralServiceInfo() -> [String: Any?] { | ||
let openLPCoreInfo = ["lite_service": true, "service_theme": ""] as [String: Any?] | ||
let generalServiceInfo = ["openlp_core": openLPCoreInfo] as [String: Any?] | ||
return generalServiceInfo | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// Author: James Selvakumar | ||
// Since: 3.0.0 | ||
// Copyright © 2021 mCruncher. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Quick | ||
import Nimble | ||
import SwiftyJSON | ||
@testable import worshipsongs | ||
|
||
class OpenLPServiceConverterSpec : QuickSpec { | ||
override func spec() { | ||
describe("OpenLPServiceConverter") { | ||
let openLPServiceConverter = OpenLPServiceConverter() | ||
let songsModel: [Songs] = DatabaseHelper().getSongModel() | ||
var favouriteList: [FavoritesSongsWithOrder]! | ||
var expectedJson: JSON! | ||
var result: JSON! | ||
|
||
describe("Convert favourite list to OpenLP Service Lite JSON format") { | ||
context("given a favourite list exist with some songs") { | ||
beforeEach { | ||
print(songsModel[0].title) | ||
print(songsModel[1].title) | ||
|
||
let favouriteSong1 = FavoritesSongsWithOrder(orderNo: 1, songName: songsModel[0].title, songListName: "foo") | ||
let favouriteSong2 = FavoritesSongsWithOrder(orderNo: 2, songName: songsModel[1].title, songListName: "foo") | ||
favouriteList = [favouriteSong1, favouriteSong2] | ||
} | ||
|
||
context("and a oszl (OpenLP Service Lite) json generated by OpenLP exists for the same songs in the same order") { | ||
beforeEach { | ||
let bundle = Bundle(for: type(of: self)) | ||
let path = bundle.path(forResource: "sample", ofType: "osj")! | ||
let jsonData = NSData(contentsOfFile: path)! | ||
//let jsonString = String(data: jsonData as Data, encoding: .utf8) | ||
expectedJson = try! JSON(data: jsonData as Data) | ||
print("Expected Json:\n \(expectedJson)") | ||
} | ||
|
||
context("when converting the favourite list to oszl json format") { | ||
beforeEach { | ||
result = openLPServiceConverter.toOszlJson(favouriteList: favouriteList!) | ||
} | ||
|
||
it("should have a top level array with three elements") { | ||
expect(result.count).to(equal(expectedJson.count)) | ||
} | ||
|
||
it("the first element of the array should have general service info") { | ||
let generalServiceInfo = result[0] | ||
let openlpCore = generalServiceInfo["openlp_core"] | ||
|
||
expect(openlpCore["lite_service"].bool).to(beTrue()) | ||
expect(openlpCore["service_theme"].string).to(beEmpty()) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.