twine 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/twine/cli.rb +63 -48
- data/lib/twine/encoding.rb +16 -14
- data/lib/twine/formatters/abstract.rb +9 -48
- data/lib/twine/formatters/android.rb +30 -26
- data/lib/twine/formatters/apple.rb +20 -48
- data/lib/twine/formatters/django.rb +23 -55
- data/lib/twine/formatters/flash.rb +21 -47
- data/lib/twine/formatters/gettext.rb +25 -26
- data/lib/twine/formatters/jquery.rb +8 -8
- data/lib/twine/formatters/tizen.rb +27 -29
- data/lib/twine/output_processor.rb +2 -2
- data/lib/twine/runner.rb +81 -21
- data/lib/twine/version.rb +1 -1
- data/test/fixtures/enc_utf16be.dummy +0 -0
- data/test/fixtures/enc_utf16be_bom.dummy +0 -0
- data/test/fixtures/enc_utf16le.dummy +0 -0
- data/test/fixtures/enc_utf16le_bom.dummy +0 -0
- data/test/fixtures/enc_utf8.dummy +2 -0
- data/test/test_cli.rb +3 -15
- data/test/test_consume_loc_drop.rb +1 -1
- data/test/test_consume_string_file.rb +73 -7
- data/test/test_formatters.rb +96 -38
- data/test/test_generate_all_string_files.rb +43 -17
- data/test/test_generate_loc_drop.rb +19 -13
- data/test/test_generate_string_file.rb +17 -8
- data/test/test_output_processor.rb +2 -2
- data/test/test_strings_file.rb +2 -2
- data/test/twine_file_dsl.rb +1 -1
- data/test/twine_test_case.rb +6 -7
- metadata +7 -2
@@ -1,30 +1,30 @@
|
|
1
1
|
require 'command_test_case'
|
2
2
|
|
3
3
|
class TestGenerateLocDrop < CommandTestCase
|
4
|
-
def
|
5
|
-
super
|
6
|
-
|
4
|
+
def new_runner(twine_file = nil)
|
7
5
|
options = {}
|
8
6
|
options[:output_path] = @output_path
|
9
7
|
options[:format] = 'apple'
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
unless twine_file
|
10
|
+
twine_file = build_twine_file 'en', 'fr' do
|
11
|
+
add_section 'Section' do
|
12
|
+
add_row key: 'value'
|
13
|
+
end
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
Twine::Runner.new(options, twine_file)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_generates_zip_file
|
21
|
-
|
21
|
+
new_runner.generate_loc_drop
|
22
22
|
|
23
|
-
assert File.exists?(@output_path), "
|
23
|
+
assert File.exists?(@output_path), "zip file should exist"
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_zip_file_structure
|
27
|
-
|
27
|
+
new_runner.generate_loc_drop
|
28
28
|
|
29
29
|
names = []
|
30
30
|
Zip::File.open(@output_path) do |zipfile|
|
@@ -37,12 +37,18 @@ class TestGenerateLocDrop < CommandTestCase
|
|
37
37
|
|
38
38
|
def test_uses_formatter
|
39
39
|
formatter = prepare_mock_formatter Twine::Formatters::Apple
|
40
|
-
formatter.expects(:
|
40
|
+
formatter.expects(:format_file).twice
|
41
|
+
|
42
|
+
new_runner.generate_loc_drop
|
43
|
+
end
|
41
44
|
|
42
|
-
|
45
|
+
def test_prints_empty_file_warnings
|
46
|
+
empty_twine_file = build_twine_file('en') {}
|
47
|
+
new_runner(empty_twine_file).generate_loc_drop
|
48
|
+
assert_match "Skipping file", Twine::stderr.string
|
43
49
|
end
|
44
50
|
|
45
|
-
class
|
51
|
+
class TestValidate < CommandTestCase
|
46
52
|
def new_runner(validate)
|
47
53
|
options = {}
|
48
54
|
options[:output_path] = @output_path
|
@@ -12,31 +12,31 @@ class TestGenerateStringFile < CommandTestCase
|
|
12
12
|
Twine::Runner.new(options, strings)
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def prepare_mock_format_file_formatter(formatter_class)
|
16
16
|
formatter = prepare_mock_formatter(formatter_class)
|
17
|
-
formatter.expects(:
|
17
|
+
formatter.expects(:format_file).returns(true)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_deducts_android_format_from_output_path
|
21
|
-
|
21
|
+
prepare_mock_format_file_formatter Twine::Formatters::Android
|
22
22
|
|
23
23
|
new_runner('fr', 'fr.xml').generate_string_file
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_deducts_apple_format_from_output_path
|
27
|
-
|
27
|
+
prepare_mock_format_file_formatter Twine::Formatters::Apple
|
28
28
|
|
29
29
|
new_runner('fr', 'fr.strings').generate_string_file
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_deducts_jquery_format_from_output_path
|
33
|
-
|
33
|
+
prepare_mock_format_file_formatter Twine::Formatters::JQuery
|
34
34
|
|
35
35
|
new_runner('fr', 'fr.json').generate_string_file
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_deducts_gettext_format_from_output_path
|
39
|
-
|
39
|
+
prepare_mock_format_file_formatter Twine::Formatters::Gettext
|
40
40
|
|
41
41
|
new_runner('fr', 'fr.po').generate_string_file
|
42
42
|
end
|
@@ -44,12 +44,21 @@ class TestGenerateStringFile < CommandTestCase
|
|
44
44
|
def test_deducts_language_from_output_path
|
45
45
|
random_language = KNOWN_LANGUAGES.sample
|
46
46
|
formatter = prepare_mock_formatter Twine::Formatters::Android
|
47
|
-
formatter.expects(:
|
47
|
+
formatter.expects(:format_file).with(random_language).returns(true)
|
48
48
|
|
49
49
|
new_runner(nil, "#{random_language}.xml").generate_string_file
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
def test_returns_error_if_nothing_written
|
53
|
+
formatter = prepare_mock_formatter Twine::Formatters::Android
|
54
|
+
formatter.expects(:format_file).returns(false)
|
55
|
+
|
56
|
+
assert_raises Twine::Error do
|
57
|
+
new_runner('fr', 'fr.xml').generate_string_file
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class TestValidate < CommandTestCase
|
53
62
|
def new_runner(validate)
|
54
63
|
options = {}
|
55
64
|
options[:output_path] = @output_path
|
@@ -43,14 +43,14 @@ class TestOutputProcessor < TwineTestCase
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_include_translated
|
46
|
-
processor = Twine::Processors::OutputProcessor.new(@strings, { include:
|
46
|
+
processor = Twine::Processors::OutputProcessor.new(@strings, { include: :translated })
|
47
47
|
result = processor.process('fr')
|
48
48
|
|
49
49
|
assert_equal %w(key4), result.strings_map.keys.sort
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_include_untranslated
|
53
|
-
processor = Twine::Processors::OutputProcessor.new(@strings, { include:
|
53
|
+
processor = Twine::Processors::OutputProcessor.new(@strings, { include: :untranslated })
|
54
54
|
result = processor.process('fr')
|
55
55
|
|
56
56
|
assert_equal %w(key1 key2 key3), result.strings_map.keys.sort
|
data/test/test_strings_file.rb
CHANGED
@@ -6,7 +6,7 @@ class TestStringsFile < TwineTestCase
|
|
6
6
|
super
|
7
7
|
|
8
8
|
@strings = Twine::StringsFile.new
|
9
|
-
@strings.read
|
9
|
+
@strings.read fixture_path('twine_accent_values.txt')
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_reading_keeps_leading_accent
|
@@ -50,7 +50,7 @@ class TestStringsFile < TwineTestCase
|
|
50
50
|
|
51
51
|
@strings.write @output_path
|
52
52
|
|
53
|
-
assert_equal content('twine_accent_values.txt'),
|
53
|
+
assert_equal content('twine_accent_values.txt'), File.read(@output_path)
|
54
54
|
end
|
55
55
|
|
56
56
|
end
|
data/test/twine_file_dsl.rb
CHANGED
@@ -20,7 +20,7 @@ module TwineFileDSL
|
|
20
20
|
return unless @currently_built_twine_file
|
21
21
|
return unless @currently_built_twine_file_section
|
22
22
|
|
23
|
-
# this relies on Ruby
|
23
|
+
# this relies on Ruby preserving the order of hash elements
|
24
24
|
key, value = parameters.first
|
25
25
|
row = Twine::StringsRow.new(key.to_s)
|
26
26
|
if value.is_a? Hash
|
data/test/twine_test_case.rb
CHANGED
@@ -29,21 +29,20 @@ class TwineTestCase < Minitest::Test
|
|
29
29
|
super
|
30
30
|
end
|
31
31
|
|
32
|
-
def output_content
|
33
|
-
File.read @output_path
|
34
|
-
end
|
35
|
-
|
36
32
|
def execute(command)
|
37
33
|
command += " -o #{@output_path}"
|
38
34
|
Twine::Runner.run(command.split(" "))
|
39
35
|
end
|
40
36
|
|
41
|
-
def
|
37
|
+
def fixture_path(filename)
|
42
38
|
File.join File.dirname(__FILE__), 'fixtures', filename
|
43
39
|
end
|
44
|
-
alias :f :fixture
|
45
40
|
|
46
41
|
def content(filename)
|
47
|
-
ERB.new(File.read
|
42
|
+
ERB.new(File.read fixture_path(filename)).result
|
43
|
+
end
|
44
|
+
|
45
|
+
def content_io(filename)
|
46
|
+
StringIO.new ERB.new(File.read fixture_path(filename)).result
|
48
47
|
end
|
49
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02
|
11
|
+
date: 2016-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -114,6 +114,11 @@ files:
|
|
114
114
|
- lib/twine/version.rb
|
115
115
|
- test/command_test_case.rb
|
116
116
|
- test/fixtures/consume_loc_drop.zip
|
117
|
+
- test/fixtures/enc_utf16be.dummy
|
118
|
+
- test/fixtures/enc_utf16be_bom.dummy
|
119
|
+
- test/fixtures/enc_utf16le.dummy
|
120
|
+
- test/fixtures/enc_utf16le_bom.dummy
|
121
|
+
- test/fixtures/enc_utf8.dummy
|
117
122
|
- test/fixtures/formatter_android.xml
|
118
123
|
- test/fixtures/formatter_apple.strings
|
119
124
|
- test/fixtures/formatter_django.po
|