Skip to content

Commit 7d18983

Browse files
committed
+refactor: Improve code structure
1 parent a41df59 commit 7d18983

File tree

11 files changed

+64
-80
lines changed

11 files changed

+64
-80
lines changed

.github/_README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ cd your_project
1818
**2. Clone this repo into a `.github/` folder:**
1919

2020
```zsh
21-
git clone https://github.com/robmllze/pub.dev_package_workflow.git .github
21+
git clone https://github.com/DevCetra/pub.dev_package_workflow.git .github
2222
```
2323

2424
**3. Remove the `/.git` folder to include it to your project:**
25-
26-
*On macOS and Linux:*
25+
26+
_On macOS and Linux:_
27+
2728
```zsh
2829
rm -rf .github/.git/
2930
```
3031

31-
*On Windows:*
32+
_On Windows:_
33+
3234
```cmd
3335
rmdir /s /q .github/.git/
3436
```
35-
36-

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@
1717
**/.github/.git
1818
**/.metadata
1919
**/.flutter-plugins
20-
**/.flutter-plugins-dependencies
20+
**/.flutter-plugins-dependencies
21+
**/pubspec_overrides.yaml
22+
23+
# Don't support IntelliJ.
24+
**/*.iml
25+
**/*.idea/

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"label": "▶️ Refetch workflow",
66
"type": "shell",
7-
"command": "rm -rf .github && git clone https://github.com/robmllze/pub.dev_package_workflow.git .github && rm -rf .github/.git/"
7+
"command": "rm -rf .github && git clone https://github.com/DevCetra/pub.dev_package_workflow.git .github && rm -rf .github/.git/"
88
},
99
{
1010
"label": "▶️ Publish to pub.dev",

DEVELOPER_NOTES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
## Enabling GitHub Workflow
2020

21-
https://github.com/robmllze/YOUR_PROJECT_NAME/settings/actions
21+
https://github.com/DevCetra/YOUR_PROJECT_NAME/settings/actions
2222

2323
## Changelog
2424

@@ -33,7 +33,7 @@ git init
3333
git add .
3434
git commit -m "Initial commit"
3535
gh repo create YOUR_PROJECT_NAME --public
36-
git remote add origin https://github.com/robmllze/YOUR_PROJECT_NAME.git
36+
git remote add origin https://github.com/DevCetra/YOUR_PROJECT_NAME.git
3737
git push -u origin main
3838
```
3939

@@ -54,7 +54,7 @@ git push -u origin main
5454

5555
```bash
5656
rm -rf .github/
57-
git clone https://github.com/robmllze/pub.dev_package_workflow.git .github
57+
git clone https://github.com/DevCetra/pub.dev_package_workflow.git .github
5858
rm -rf .github/.git
5959
```
6060

@@ -71,6 +71,6 @@ find . -name '.DS_Store' -type f -delete
7171

7272
```bash
7373
rmdir /s /q .github/
74-
git clone https://github.com/robmllze/pub.dev_package_workflow.git .github
74+
git clone https://github.com/DevCetra/pub.dev_package_workflow.git .github
7575
rmdir /s /q .github/.git
7676
```

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# DF - String
2-
31
<a href="https://www.buymeacoffee.com/robmllze" target="_blank"><img align="right" src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
42

53
Dart & Flutter Packages by DevCetra.com & contributors.
@@ -52,7 +50,7 @@ No matter how you choose to contribute, your involvement is greatly appreciated
5250

5351
### Join GitHub Discussions:
5452

55-
💬 https://github.com/robmllze/df_string/discussions/
53+
💬 https://github.com/DevCetra/df_string/discussions/
5654

5755
### Chief Maintainer:
5856

lib/src/_index.g.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,14 @@
11
//.title
22
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
33
//
4-
// GENERATED BY DF GEN - DO NOT MODIFY BY HAND
5-
// See: https://github.com/robmllze/df_gen
4+
// GENERATED - DO NOT MODIFY BY HAND
5+
// See: https://github.com/DevCetra/df_generate_dart_indexes
66
//
77
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
88
//.title~
99

10-
// --- PUBLIC FILES ---
11-
export 'string_case_types.dart';
12-
export 'extensions/misc_utils_on_string_extension.dart';
13-
export 'extensions/null_if_empty_on_string_x.dart';
14-
export 'extensions/string_case_conversions_on_string_extension.dart';
15-
export 'extensions/to_timmed_or_null_on_object_extension.dart';
16-
17-
// --- PRIVATE FILES (EXCLUDED) ---
18-
// export '_index.g.dart';
19-
20-
// --- GENERATED FILES (EXCLUDED) ---
21-
// None found.
10+
export './string_case_types.dart';
11+
export './extensions/string_case_conversions_on_string_x.dart';
12+
export './extensions/misc_utils_on_string_x.dart';
13+
export './extensions/null_if_empty_on_string_x.dart';
14+
export './extensions/to_timmed_or_null_on_object_x.dart';

lib/src/extensions/misc_utils_on_string_extension.dart renamed to lib/src/extensions/misc_utils_on_string_x.dart

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
extension MiscUtilsOnStringExtension on String {
14-
/// Truncates the string to the given [length].
15-
String truncToLength(int length) {
16-
return (this.length > length ? substring(0, length).trim() : this);
13+
extension MiscUtilsOnStringX on String {
14+
/// Truncates the string to the given [length]. Specify [ellipsis] to append
15+
/// to he truncated string if it is shorter than [length], e.g.
16+
/// 'Hello World'.truncToLength(5, ellipsis: '...') => 'Hello...'.
17+
String truncToLength(
18+
int length, {
19+
String ellipsis = '',
20+
}) {
21+
final temp = (this.length > length ? substring(0, length).trim() : this);
22+
if (temp.length < length) return temp + ellipsis;
23+
return temp;
1724
}
1825

1926
/// Replaces all whitespace characters with [replace].
@@ -25,7 +32,11 @@ extension MiscUtilsOnStringExtension on String {
2532
/// [startIndex].
2633
///
2734
/// See: [replaceFirst].
28-
String replaceLast(Pattern from, String replace, [int startIndex = 0]) {
35+
String replaceLast(
36+
Pattern from,
37+
String replace, [
38+
int startIndex = 0,
39+
]) {
2940
final match = from.allMatches(this, startIndex).lastOrNull;
3041
if (match == null) return this;
3142
final lastIndex = match.start;

lib/src/extensions/string_case_conversions_on_string_extension.dart renamed to lib/src/extensions/string_case_conversions_on_string_x.dart

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
extension StringCaseConversionsOnStringExtension on String {
13+
extension StringCaseConversionsOnStringX on String {
1414
/// Converts the string to UPPER_SNAKE_CASE;
1515
String toUpperSnakeCase() => toSnakeCase().toUpperCase();
1616

@@ -32,6 +32,10 @@ extension StringCaseConversionsOnStringExtension on String {
3232
/// Converts the string to kebab-case.
3333
String toKebabCase() => _extractLowercaseComponents().join('-');
3434

35+
/// Converts the string to Capitalized-Kebab-Case.
36+
String toCapitalizedKebabCase() =>
37+
_extractLowercaseComponents().map((e) => e.capitalize()).join('-');
38+
3539
/// Converts the string to dot.case.
3640
String toDotCase() => _extractLowercaseComponents().join('.');
3741

@@ -42,15 +46,13 @@ extension StringCaseConversionsOnStringExtension on String {
4246
String toUpperDotCase() => toDotCase().toUpperCase();
4347

4448
/// Converts the string to path/case.
45-
String toPathCase([String separator = '/']) =>
46-
_extractLowercaseComponents().join(separator);
49+
String toPathCase([String separator = '/']) => _extractLowercaseComponents().join(separator);
4750

4851
/// Converts the string to camelCase.
4952
String toCamelCase() => toPascalCase().withFirstLetterAsLowerCase();
5053

5154
/// Converts the string to PascalCase.
52-
String toPascalCase() =>
53-
_extractLowercaseComponents().map((e) => e.capitalize()).join();
55+
String toPascalCase() => _extractLowercaseComponents().map((e) => e.capitalize()).join();
5456

5557
/// Extracts and returns a list of lowercase components from the string.
5658
///
@@ -85,9 +87,7 @@ extension StringCaseConversionsOnStringExtension on String {
8587
if ((a.isLowerCase && b.isUpperCase) ||
8688
(a._isDigit && bIsLetter) ||
8789
(aIsLetter && b._isDigit) ||
88-
(a.isUpperCase &&
89-
b.isUpperCase &&
90-
(n + 1 < length && this[n + 1].isLowerCase))) {
90+
(a.isUpperCase && b.isUpperCase && (n + 1 < length && this[n + 1].isLowerCase))) {
9191
words.add(currentWord.toString().toLowerCase());
9292
currentWord = StringBuffer();
9393
}
@@ -140,9 +140,6 @@ extension StringCaseConversionsOnStringExtension on String {
140140

141141
/// Capitalizes each word in the string.
142142
String withCapitalizedWords() {
143-
return trim()
144-
.split(RegExp(r'[- ]+'))
145-
.map((e) => e.trim().toLowerCase().capitalize())
146-
.join(' ');
143+
return trim().split(RegExp(r'[- ]+')).map((e) => e.trim().toLowerCase().capitalize()).join(' ');
147144
}
148145
}

lib/src/extensions/to_timmed_or_null_on_object_extension.dart renamed to lib/src/extensions/to_timmed_or_null_on_object_x.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
extension ToTrimmedOrNullOnObjectExtension on Object {
13+
extension ToTrimmedOrNullOnObjectX on Object {
1414
/// Converts the input to a string and trims it or returns `null` if the
1515
/// result is empty.
1616
String? toTrimmedOrNull() {

lib/src/string_case_types.dart

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
1111
//.title~
1212

13-
import 'extensions/string_case_conversions_on_string_extension.dart';
13+
import 'extensions/string_case_conversions_on_string_x.dart';
1414

1515
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
1616

@@ -24,6 +24,7 @@ enum StringCaseType {
2424
UPPER_SNAKE_CASE(_UPPER_SNAKE_CASE),
2525
LOWER_KEBAB_CASE(_LOWER_KEBAB_CASE),
2626
UPPER_KEBAB_CASE(_UPPER_KEBAB_CASE),
27+
CAPITALIZED_KEBAB_CASE(_UPPER_KEBAB_CASE),
2728
CAMEL_CASE(_CAMEL_CASE),
2829
PASCAL_CASE(_PASCAL_CASE),
2930
LOWER_DOT_CASE(_LOWER_DOT_CASE),
@@ -34,44 +35,17 @@ enum StringCaseType {
3435
//
3536
//
3637

37-
final String message;
38+
final String code;
3839

3940
//
4041
//
4142
//
4243

43-
const StringCaseType(this.message);
44+
const StringCaseType(this.code);
4445
}
4546

4647
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
4748

48-
/// Camel case example.
49-
const CAMEL_CASE_EXAMPLE = 'camelCase';
50-
51-
/// Lower dot case example.
52-
const LOWER_DOT_CASE_EXAMPLE = 'lower.dot.case';
53-
54-
/// Lower kebab case example.
55-
const LOWER_KEBAB_CASE_EXAMPLE = 'lower-kebab-case';
56-
57-
/// Lower snake case example.
58-
const LOWER_SNAKE_CASE_EXAMPLE = 'lower_snake_case';
59-
60-
/// Pascal case example.
61-
const PASCAL_CASE_EXAMPLE = 'PascalCase';
62-
63-
/// Path case example.
64-
const PATH_CASE_EXAMPLE = 'path/case';
65-
66-
/// Upper dot case example.
67-
const UPPER_DOT_CASE_EXAMPLE = 'UPPER.DOT.CASE';
68-
69-
/// Upper kebab case example.
70-
const UPPER_KEBAB_CASE_EXAMPLE = 'UPPER-KEBAB-CASE';
71-
72-
/// Upper snake case example.
73-
const UPPER_SNAKE_CASE_EXAMPLE = 'UPPER_SNAKE_CASE';
74-
7549
/// A key representing camel case.
7650
const CAMEL_CASE = 'CAMEL_CASE';
7751

@@ -81,6 +55,9 @@ const LOWER_DOT_CASE = 'LOWER_DOT_CASE';
8155
/// A key representing lower kebab case.
8256
const LOWER_KEBAB_CASE = 'LOWER_KEBAB_CASE';
8357

58+
/// A key representing lower kebab case.
59+
const CAPITALIZED_KEBAB_CASE = 'CAPITALIZED_KEBAB_CASE';
60+
8461
/// A key representing lower snake case.
8562
const LOWER_SNAKE_CASE = 'LOWER_SNAKE_CASE';
8663

@@ -107,6 +84,7 @@ const _PASCAL_CASE = PASCAL_CASE;
10784
const _PATH_CASE = PATH_CASE;
10885
const _UPPER_DOT_CASE = UPPER_DOT_CASE;
10986
const _UPPER_KEBAB_CASE = UPPER_KEBAB_CASE;
87+
const _CAPITALIZED_KEBAB_CASE = CAPITALIZED_KEBAB_CASE;
11088
const _UPPER_SNAKE_CASE = UPPER_SNAKE_CASE;
11189

11290
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
@@ -125,6 +103,8 @@ String convertToStringCaseType(
125103
return value.toLowerKebabCase();
126104
case StringCaseType.UPPER_KEBAB_CASE:
127105
return value.toUpperKebabCase();
106+
case StringCaseType.CAPITALIZED_KEBAB_CASE:
107+
return value.toCapitalizedKebabCase();
128108
case StringCaseType.CAMEL_CASE:
129109
return value.toCamelCase();
130110
case StringCaseType.PASCAL_CASE:
@@ -142,7 +122,7 @@ String convertToStringCaseType(
142122

143123
// ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
144124

145-
extension ConvertOnStringCaseTypeExtension on StringCaseType {
125+
extension ConvertOnStringCaseTypeX on StringCaseType {
146126
/// Converts [value] to a specific case type.
147127
String convert(String value) {
148128
return convertToStringCaseType(value, this);

0 commit comments

Comments
 (0)