Skip to content

Commit

Permalink
Clean ups
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Oct 22, 2024
1 parent 00b7677 commit 3f19609
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions pkgs/messages_serializer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ publish_to: none
dependencies:
messages:
path: ../messages
intl: ^0.19.0

dev_dependencies:
dart_flutter_team_lints: ^3.0.0
Expand Down
2 changes: 1 addition & 1 deletion pkgs/messages_shrinker/lib/messages_shrinker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MessageShrinker {
String shrinkJson(String buffer, List<int> messagesToKeep) {
final sizeBefore = buffer.length;
final json = JsonDeserializer(buffer).deserialize(
(howMany, {few, locale, many, numberCases, required other, wordCases}) {
(howMany, locale, {few, many, numberCases, required other, wordCases}) {
throw StateError('As the deserialized MessageList is not used, but '
'just immediately reserialized, this selector will not be called.');
},
Expand Down
3 changes: 1 addition & 2 deletions pkgs/messages_shrinker/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ environment:
dependencies:
analyzer: ^6.2.0
args: ^2.4.2
build: ^2.4.1
messages: ^0.2.0
messages_builder: ^0.2.0
messages_serializer: ^0.2.0

dev_dependencies:
dart_flutter_team_lints: ^3.0.0
intl: ^0.18.1
intl: ^0.19.0
test: ^1.21.0
13 changes: 6 additions & 7 deletions pkgs/messages_shrinker/test/message_shrinker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ library;
import 'dart:convert';
import 'dart:io';

import 'package:build/build.dart';
import 'package:intl/intl.dart' as old_intl;
import 'package:messages/messages_json.dart';
import 'package:messages_builder/arb_parser.dart';
Expand All @@ -17,13 +16,13 @@ import 'package:messages_shrinker/messages_shrinker.dart';
import 'package:test/test.dart';

Message intlPluralSelector(
num howMany, {
num howMany,
String locale, {
Map<int, Message>? numberCases,
Map<int, Message>? wordCases,
Message? few,
Message? many,
required Message other,
String? locale,
}) {
return old_intl.Intl.pluralLogic(
howMany,
Expand All @@ -49,14 +48,15 @@ void main() {
});

String getMessage(int i, List<int> args) => JsonDeserializer(dataFileContents)
.deserialize(intl)
.deserialize(intlPluralSelector)
.generateStringAtIndex(i, args);

test('Shrink a json', () {
final messageIndex = 1;
final output =
MessageShrinker().shrinkJson(dataFileContents, [messageIndex]);
final deserialize = JsonDeserializer(output).deserialize(intl);
final deserialize =
JsonDeserializer(output).deserialize(intlPluralSelector);
final args = [2];
final generateStringAtIndex = deserialize.generateStringAtIndex(1, args);
expect(generateStringAtIndex, getMessage(messageIndex, args));
Expand Down Expand Up @@ -86,8 +86,7 @@ String readArbFileToDataFile() {
final path = 'test/testarb.arb';
final arbFile = File(path).readAsStringSync();
final arb = jsonDecode(arbFile) as Map<String, dynamic>;
final parsed =
ArbParser().parseMessageFile(arb, AssetId('messsages_shrinker', path));
final parsed = ArbParser().parseMessageFile(arb);
return JsonSerializer()
.serialize('', '', parsed.messages.map((e) => e.message).toList())
.data;
Expand Down

0 comments on commit 3f19609

Please sign in to comment.