Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Adds readonly field in XCScheme to get the name of the scheme. #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/src/scheme/scheme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class XCScheme extends XmlElementWrapper {

XCScheme._(this._path, XmlElement element) : super(element);

String get name => path_lib.basename(_path).split('.').first;

factory XCScheme.load(String path) {
var doc = XmlDocument.parse(File(path).readAsStringSync());
return XCScheme._(path, doc.findElements('Scheme').first);
Expand Down
6 changes: 4 additions & 2 deletions lib/src/xcode.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:io';

import 'package:path/path.dart' as path_lib;
import 'package:snapshot/snapshot.dart';
import 'package:xcodeproj/src/plist/plain_format.dart';
import 'package:path/path.dart' as path_lib;
import 'package:xcodeproj/src/scheme.dart';

import 'pbx.dart';

mixin XCodeProjMixin on SnapshotView {
Expand Down Expand Up @@ -92,7 +93,8 @@ class XCodeProj extends ModifiableSnapshotView with XCodeProjMixin {
return dir
.listSync()
.where((f) => f.path.endsWith('.xcscheme'))
.map((f) => XCScheme.load(f.path)) as List<XCScheme>;
.map((f) => XCScheme.load(f.path))
.toList();
}

XCScheme createScheme(String name, PBXTarget target) {
Expand Down
8 changes: 5 additions & 3 deletions test/plist/plain_format_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void main() {
});

group('Parsing annotated value', () {
var parser = grammar.buildFrom(grammar.annotatedValue());
var parser = grammar.build(arguments: grammar.annotatedValue().children);

test('Parsing annotated value with single annotation', () {
shouldSucceed(
Expand All @@ -85,7 +85,9 @@ void main() {
});

group('Parsing arrays', () {
var parser = grammar.buildFrom(grammar.array());
final array = grammar.array();

var parser = grammar.build(arguments: array.children);
test('Parsing empty array', () {
shouldSucceed(parser, '()', []);
});
Expand Down Expand Up @@ -117,7 +119,7 @@ void main() {
});

group('Parsing dictionaries', () {
var parser = grammar.buildFrom(grammar.dictionary());
var parser = grammar.build(arguments: grammar.dictionary().children);
test('Parsing an empty dictionary', () {
shouldSucceed(parser, '{}', {});
shouldSucceed(parser, '\t\n\t{\n\t\n}', {});
Expand Down