Skip to content

Commit

Permalink
Merge pull request #50 from Nirma/dictionary_public
Browse files Browse the repository at this point in the history
 Make attributes dictionary public.
  • Loading branch information
Nicholas Maccharoli authored Mar 27, 2018
2 parents 5c829ec + c978604 commit 3a2a2ff
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Attributed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
AA28CE69206A0D5F0025AA29 /* AttributedPublicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */; };
AA3150381EA4A57300A86368 /* Attributed.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA3150371EA4A57300A86368 /* Attributed.swift */; };
AA4B73E11E0B798C004C6947 /* StringExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */; };
AABEF4EC1E98F532003260B7 /* NSString+Attributed.swift in Sources */ = {isa = PBXBuildFile; fileRef = AABEF4EB1E98F532003260B7 /* NSString+Attributed.swift */; };
Expand All @@ -29,6 +30,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedPublicTests.swift; sourceTree = "<group>"; };
AA3150371EA4A57300A86368 /* Attributed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Attributed.swift; sourceTree = "<group>"; };
AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensionTests.swift; sourceTree = "<group>"; };
AABEF4EB1E98F532003260B7 /* NSString+Attributed.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSString+Attributed.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -129,9 +131,10 @@
AAEE627A1DF8F3690079C70C /* AttributedTests */ = {
isa = PBXGroup;
children = (
AABEF4F21E98F73F003260B7 /* Supporting Files */,
AA28CE68206A0D5F0025AA29 /* AttributedPublicTests.swift */,
AAE1A2761E01537500610C40 /* AttributesTests.swift */,
AA4B73E01E0B798C004C6947 /* StringExtensionTests.swift */,
AABEF4F21E98F73F003260B7 /* Supporting Files */,
);
path = AttributedTests;
sourceTree = "<group>";
Expand Down Expand Up @@ -261,6 +264,7 @@
buildActionMask = 2147483647;
files = (
AA4B73E11E0B798C004C6947 /* StringExtensionTests.swift in Sources */,
AA28CE69206A0D5F0025AA29 /* AttributedPublicTests.swift in Sources */,
AAE1A2771E01537500610C40 /* AttributesTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
2 changes: 1 addition & 1 deletion Attributed/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Foundation

public struct Attributes {

let dictionary: [NSAttributedStringKey: Any]
public let dictionary: [NSAttributedStringKey: Any]

public init() {
dictionary = [:]
Expand Down
40 changes: 40 additions & 0 deletions AttributedTests/AttributedPublicTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// AttributedPublicTests.swift
//
// Copyright (c) 2016-2018 Nicholas Maccharoli
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import XCTest

// DO NOT USE `@testable import`
// The tests in this file are checking the behaviour from the viewpoint of a normal client of this library
import Attributed

class AttributedPublicTests: XCTestCase {
func testAttributesDictionary() {
let testAttributes = Attributes()
.font(.systemFont(ofSize: 12.0))
.background(color: .green)

let testResult = testAttributes.dictionary.keys.count == 2

XCTAssert(testResult, "Dictionary is not accessible")
}
}

0 comments on commit 3a2a2ff

Please sign in to comment.