-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
380 additions
and
34 deletions.
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
49 changes: 49 additions & 0 deletions
49
lib/src/processors/commons/dynamic_file_string_processor.dart
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,49 @@ | ||
/* | ||
* Copyright (c) 2024 Angelo Cassano | ||
* | ||
* 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 'package:flutter_flavorizr/src/processors/commons/abstract_file_string_processor.dart'; | ||
|
||
class DynamicFileStringProcessor extends AbstractFileStringProcessor { | ||
DynamicFileStringProcessor( | ||
super.path, | ||
super.processor, { | ||
required super.config, | ||
}); | ||
|
||
@override | ||
void execute() { | ||
if (!file.existsSync()) { | ||
return; | ||
} | ||
|
||
processor.input = file.readAsStringSync(); | ||
|
||
super.execute(); | ||
} | ||
|
||
@override | ||
String toString() => | ||
"DynamicFileStringProcessor: writing on file $path with nested $processor if exists"; | ||
} |
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,81 @@ | ||
/* | ||
* Copyright (c) 2024 Angelo Cassano | ||
* | ||
* 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 'package:flutter_flavorizr/src/exception/malformed_resource_exception.dart'; | ||
import 'package:flutter_flavorizr/src/extensions/extensions_string.dart'; | ||
import 'package:flutter_flavorizr/src/parser/models/flavors/darwin/enums.dart'; | ||
import 'package:flutter_flavorizr/src/processors/commons/string_processor.dart'; | ||
|
||
class PodfileProcessor extends StringProcessor { | ||
static const projectEntryPoint = 'project \'Runner\', {'; | ||
static const projectClosure = '}'; | ||
|
||
final List<String> flavors; | ||
|
||
PodfileProcessor({ | ||
super.input, | ||
required this.flavors, | ||
required super.config, | ||
}); | ||
|
||
@override | ||
String execute() { | ||
final projectPosition = input!.indexOf(projectEntryPoint); | ||
final closedProjectPosition = input!.indexOf(projectClosure); | ||
|
||
if (projectPosition < 0) { | ||
throw MalformedResourceException(input!); | ||
} | ||
|
||
final buffer = StringBuffer(); | ||
|
||
_appendStartContent(buffer, projectPosition); | ||
_appendFlavors(buffer); | ||
|
||
_appendEndContent(buffer, closedProjectPosition); | ||
|
||
return buffer.toString(); | ||
} | ||
|
||
void _appendStartContent(StringBuffer buffer, int position) { | ||
buffer.writeln(input!.substring(0, position + projectEntryPoint.length)); | ||
} | ||
|
||
void _appendFlavors(StringBuffer buffer) { | ||
for (final flavor in flavors) { | ||
for (final target in Target.values) { | ||
buffer.writeln( | ||
' \'${target.name.capitalize}-$flavor\' => :${target.darwinTarget},'); | ||
} | ||
} | ||
} | ||
|
||
void _appendEndContent(StringBuffer buffer, int position) { | ||
buffer.write(input!.substring(position)); | ||
} | ||
|
||
@override | ||
String toString() => 'PodfileProcessor'; | ||
} |
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
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
Oops, something went wrong.