Skip to content

Commit

Permalink
#243 Added support to build the general service info json.
Browse files Browse the repository at this point in the history
  • Loading branch information
sskjames committed Mar 19, 2021
1 parent 750d1ef commit 03579bf
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ def common_pods
pod 'FMDB'
pod 'YouTubePlayer'
pod 'Floaty'
pod 'Swinject', '~> 2.7.1'
pod 'SwinjectAutoregistration', '~> 2.7.0'
pod 'SwinjectStoryboard', :git => 'https://github.com/Swinject/SwinjectStoryboard.git', :commit => '0ca45c83a8aa398c153d8a036c95abb4343cfa0c'
pod 'SwiftyJSON', '~> 4.0'
end

def test_pods
pod 'SwiftLint'
pod 'Quick', '~> 3.0.0'
pod 'Nimble', '~> 9.0.0'
pod 'Cuckoo', '~> 1.4.1'
end

target "worshipsongs" do
Expand Down
43 changes: 42 additions & 1 deletion Podfile.lock
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
70 changes: 70 additions & 0 deletions worshipsongs.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
1A9333A826031B4300953865 /* IOpenLPServiceConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9333A726031B4300953865 /* IOpenLPServiceConverter.swift */; };
1A9333B926031C9200953865 /* OpenLPServiceConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9333B826031C9200953865 /* OpenLPServiceConverter.swift */; };
1A9333CF26031E0000953865 /* OpenLPServiceConverterSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A9333CE26031E0000953865 /* OpenLPServiceConverterSpec.swift */; };
1A9333D82603372E00953865 /* sample.osj in Resources */ = {isa = PBXBuildFile; fileRef = 1A9333D72603372E00953865 /* sample.osj */; };
280B923E1E77830E00833EAA /* DeviceUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 280B923D1E77830E00833EAA /* DeviceUtils.swift */; };
283D8F0A1E7797540078B159 /* DeviceUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 280B923D1E77830E00833EAA /* DeviceUtils.swift */; };
285D5A641E76497000C3F1EE /* CommonConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285D5A631E76497000C3F1EE /* CommonConstants.swift */; };
Expand Down Expand Up @@ -92,6 +96,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1A9333A726031B4300953865 /* IOpenLPServiceConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IOpenLPServiceConverter.swift; sourceTree = "<group>"; };
1A9333B826031C9200953865 /* OpenLPServiceConverter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenLPServiceConverter.swift; sourceTree = "<group>"; };
1A9333CE26031E0000953865 /* OpenLPServiceConverterSpec.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenLPServiceConverterSpec.swift; sourceTree = "<group>"; };
1A9333D72603372E00953865 /* sample.osj */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = sample.osj; sourceTree = "<group>"; };
280B923D1E77830E00833EAA /* DeviceUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceUtils.swift; sourceTree = "<group>"; };
285D5A631E76497000C3F1EE /* CommonConstants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CommonConstants.swift; sourceTree = "<group>"; };
28786FCB1F78F7310085B216 /* SongBook.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SongBook.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -210,6 +218,39 @@
name = Frameworks;
sourceTree = "<group>";
};
1A9333CC26031DBA00953865 /* Library */ = {
isa = PBXGroup;
children = (
1A9333CD26031DC900953865 /* Utilities */,
);
name = Library;
sourceTree = "<group>";
};
1A9333CD26031DC900953865 /* Utilities */ = {
isa = PBXGroup;
children = (
1A9333CE26031E0000953865 /* OpenLPServiceConverterSpec.swift */,
);
name = Utilities;
sourceTree = "<group>";
};
1A9333D62603371400953865 /* Resources */ = {
isa = PBXGroup;
children = (
1A9333D72603372E00953865 /* sample.osj */,
);
name = Resources;
sourceTree = "<group>";
};
1A9333E7260347DA00953865 /* OpenLP */ = {
isa = PBXGroup;
children = (
1A9333A726031B4300953865 /* IOpenLPServiceConverter.swift */,
1A9333B826031C9200953865 /* OpenLPServiceConverter.swift */,
);
name = OpenLP;
sourceTree = "<group>";
};
2F0A70F71E1B43020025F156 /* Component */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -264,6 +305,8 @@
2F5D3D331BC788F8001C4B6F /* worshipsongsTests */ = {
isa = PBXGroup;
children = (
1A9333D62603371400953865 /* Resources */,
1A9333CC26031DBA00953865 /* Library */,
2F5D3D341BC788F8001C4B6F /* worshipsongsTests.swift */,
2F5D3D361BC788F8001C4B6F /* Info.plist */,
);
Expand Down Expand Up @@ -356,6 +399,7 @@
2F5D3D571BC78D85001C4B6F /* Library */ = {
isa = PBXGroup;
children = (
1A9333E7260347DA00953865 /* OpenLP */,
2FC6EA3E22680B5C007882A6 /* SimplePDF.swift */,
2FC6EA3F22680B5C007882A6 /* SimplePDFLabel.swift */,
2FC6EA4022680B5C007882A6 /* SimplePDFUtilities.swift */,
Expand Down Expand Up @@ -552,6 +596,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1A9333D82603372E00953865 /* sample.osj in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -596,12 +641,20 @@
"${PODS_ROOT}/Target Support Files/Pods-worshipsongs/Pods-worshipsongs-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
"${BUILT_PRODUCTS_DIR}/Floaty/Floaty.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
"${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectAutoregistration/SwinjectAutoregistration.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework",
"${BUILT_PRODUCTS_DIR}/YouTubePlayer/YouTubePlayer.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Floaty.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectAutoregistration.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YouTubePlayer.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -640,13 +693,27 @@
"${PODS_ROOT}/Target Support Files/Pods-worshipsongsTests/Pods-worshipsongsTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/FMDB/FMDB.framework",
"${BUILT_PRODUCTS_DIR}/Floaty/Floaty.framework",
"${BUILT_PRODUCTS_DIR}/SwiftyJSON/SwiftyJSON.framework",
"${BUILT_PRODUCTS_DIR}/Swinject/Swinject.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectAutoregistration/SwinjectAutoregistration.framework",
"${BUILT_PRODUCTS_DIR}/SwinjectStoryboard/SwinjectStoryboard.framework",
"${BUILT_PRODUCTS_DIR}/YouTubePlayer/YouTubePlayer.framework",
"${BUILT_PRODUCTS_DIR}/Cuckoo/Cuckoo.framework",
"${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework",
"${BUILT_PRODUCTS_DIR}/Quick/Quick.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FMDB.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Floaty.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftyJSON.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Swinject.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectAutoregistration.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwinjectStoryboard.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/YouTubePlayer.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cuckoo.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -666,6 +733,7 @@
28786FCC1F78F7310085B216 /* SongBook.swift in Sources */,
2FC6EA4222680B5C007882A6 /* SimplePDFLabel.swift in Sources */,
2F5D3D561BC78D51001C4B6F /* Songs.swift in Sources */,
1A9333A826031B4300953865 /* IOpenLPServiceConverter.swift in Sources */,
2FB0ADC622154B6600EB305F /* CustomProvider.swift in Sources */,
2F18C4C31E8DE6B800E540AF /* CategoriesTableViewController.swift in Sources */,
2FFBC33E1E7BAB85006B2405 /* DatabaseService.swift in Sources */,
Expand All @@ -679,6 +747,7 @@
2FDE48531DF140BD00948236 /* SettingsController.swift in Sources */,
2FEDF61F1F721AF1005D1B83 /* FavoritesListViewController.swift in Sources */,
280B923E1E77830E00833EAA /* DeviceUtils.swift in Sources */,
1A9333B926031C9200953865 /* OpenLPServiceConverter.swift in Sources */,
625E81751BD664D000BE80B8 /* XmlParserService.swift in Sources */,
2F5D3D5C1BC7A216001C4B6F /* CommonService.swift in Sources */,
2FD589991C16775C00668951 /* ArtistSongsTitleTableViewController.swift in Sources */,
Expand Down Expand Up @@ -721,6 +790,7 @@
files = (
625E81761BD664D000BE80B8 /* XmlParserService.swift in Sources */,
283D8F0A1E7797540078B159 /* DeviceUtils.swift in Sources */,
1A9333CF26031E0000953865 /* OpenLPServiceConverterSpec.swift in Sources */,
2F5D3D351BC788F8001C4B6F /* worshipsongsTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
12 changes: 12 additions & 0 deletions worshipsongs/IOpenLPServiceConverter.swift
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
}
33 changes: 33 additions & 0 deletions worshipsongs/OpenLPServiceConverter.swift
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
}
}
65 changes: 65 additions & 0 deletions worshipsongsTests/OpenLPServiceConverterSpec.swift
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())
}
}
}
}
}
}
}
}
1 change: 1 addition & 0 deletions worshipsongsTests/sample.osj

Large diffs are not rendered by default.

0 comments on commit 03579bf

Please sign in to comment.