Skip to content

Commit 3563555

Browse files
committed
init
0 parents  commit 3563555

14 files changed

+245
-0
lines changed

.github/FUNDING.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [marzvrover]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13+

.github/workflows/codacy-analysis.yml

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# This workflow checks out code, performs a Codacy security scan
2+
# and integrates the results with the
3+
# GitHub Advanced Security code scanning feature. For more information on
4+
# the Codacy security scan action usage and parameters, see
5+
# https://github.com/codacy/codacy-analysis-cli-action.
6+
# For more information on Codacy Analysis CLI in general, see
7+
# https://github.com/codacy/codacy-analysis-cli.
8+
9+
name: Codacy Security Scan
10+
11+
on:
12+
push:
13+
branches: [ main ]
14+
pull_request:
15+
branches: [ main ]
16+
17+
jobs:
18+
codacy-security-scan:
19+
name: Codacy Security Scan
20+
runs-on: ubuntu-latest
21+
steps:
22+
# Checkout the repository to the GitHub Actions runner
23+
- name: Checkout code
24+
uses: actions/checkout@v2
25+
26+
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
27+
- name: Run Codacy Analysis CLI
28+
uses: codacy/[email protected]
29+
with:
30+
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
31+
# You can also omit the token and run the tools that support default configurations
32+
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
33+
verbose: true
34+
output: results.sarif
35+
format: sarif
36+
# Adjust severity of non-security issues
37+
gh-code-scanning-compat: true
38+
# Force 0 exit code to allow SARIF file generation
39+
# This will handover control about PR rejection to the GitHub side
40+
max-allowed-issues: 2147483647
41+
42+
# Upload the SARIF file generated in the previous step
43+
- name: Upload SARIF results file
44+
uses: github/codeql-action/upload-sarif@v1
45+
with:
46+
sarif_file: results.sarif

.github/workflows/docs.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: docs
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: macos-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Get Tag
15+
id: get_tag
16+
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
17+
- name: Run Jazzy
18+
uses: swiftpackages/[email protected]
19+
with:
20+
args: --module_version ${{ steps.get_tag.outputs.tag }} --github_file_prefix https://github.com/swiftpackages/SuperString/tree/${{ steps.get_tag.outputs.tag }} --output docs/${{ steps.get_tag.outputs.tag }}
21+
personal_access_token: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}

.github/workflows/macOS.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: macOS
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: macos-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Setup Swift
17+
uses: fwal/[email protected]
18+
- name: Build
19+
run: swift build -v
20+
- name: Run tests
21+
run: swift test -v

.github/workflows/maindocs.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
build:
9+
10+
runs-on: macos-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Run Jazzy
15+
uses: swiftpackages/[email protected]
16+
with:
17+
args: --module_version main --github_file_prefix https://github.com/swiftpackages/SuperString/tree/main --output docs/main
18+
personal_access_token: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}

.github/workflows/ubuntu.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: ubuntu
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Setup Swift
17+
uses: fwal/[email protected]
18+
- name: Build
19+
run: swift build -v
20+
- name: Run tests
21+
run: swift test -v

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
/.build
3+
/Packages
4+
/*.xcodeproj
5+
xcuserdata/
6+
.swiftpm

.swiftlint.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trailing_comma:
2+
mandatory_comma: true
3+
disabled_rules:
4+
- switch_case_alignment

Package.swift

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// swift-tools-version:5.3
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "SuperString",
8+
products: [
9+
// Products define the executables and libraries a package produces, and make them visible to other packages.
10+
.library(
11+
name: "SuperString",
12+
targets: ["SuperString"]),
13+
],
14+
dependencies: [
15+
// Dependencies declare other packages that this package depends on.
16+
// .package(url: /* package url */, from: "1.0.0"),
17+
],
18+
targets: [
19+
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20+
// Targets can depend on other targets in this package, and on products in packages this package depends on.
21+
.target(
22+
name: "SuperString",
23+
dependencies: []),
24+
.testTarget(
25+
name: "SuperStringTests",
26+
dependencies: ["SuperString"]),
27+
]
28+
)

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SuperString
2+
3+
SuperString provides useful string extensions such as `kebabcased`.

Sources/SuperString/SuperString.swift

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
public extension StringProtocol {
2+
/// Turns the string into a kebab-case string
3+
/// - returns: String in kebab-case
4+
func kebabcased() -> String {
5+
guard self.count > 0 else {
6+
return ""
7+
}
8+
9+
var output: String = self.first!.lowercased()
10+
var previous: Character = output.first!
11+
12+
for char in self.dropFirst() {
13+
if char.isWhitespace {
14+
output.append("-")
15+
} else if char.isUppercase {
16+
if !previous.isWhitespace {
17+
output.append("-")
18+
}
19+
output.append(char.lowercased())
20+
} else {
21+
output.append(char)
22+
}
23+
previous = char
24+
}
25+
26+
return output
27+
}
28+
}

Tests/LinuxMain.swift

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import XCTest
2+
3+
import SuperStringTests
4+
5+
var tests = [XCTestCaseEntry]()
6+
tests += SuperStringTests.allTests()
7+
XCTMain(tests)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import XCTest
2+
import SuperString
3+
// swiftlint:disable
4+
final class SuperStringTests: XCTestCase {
5+
func testKebabcased() {
6+
let inputPairs: [(input: String, expected: String)] = [
7+
(input: "this is a test", expected: "this-is-a-test"),
8+
(input: "this is A test", expected: "this-is-a-test"),
9+
(input: "ThisIsATest", expected: "this-is-a-test"),
10+
(input: "ThisIs a Test", expected: "this-is-a-test"),
11+
]
12+
for inputPair in inputPairs {
13+
XCTAssertEqual(inputPair.input.kebabcased(), inputPair.expected)
14+
}
15+
}
16+
17+
static var allTests = [
18+
("testKebabcased", testKebabcased),
19+
]
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import XCTest
2+
3+
#if !canImport(ObjectiveC)
4+
public func allTests() -> [XCTestCaseEntry] {
5+
return [
6+
testCase(SuperStringTests.allTests),
7+
]
8+
}
9+
#endif

0 commit comments

Comments
 (0)