xcres 0.4.2 → 0.4.3
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/Gemfile.lock +1 -1
- data/lib/xcres/analyzer/strings_analyzer.rb +7 -4
- data/lib/xcres/command/install_command.rb +3 -2
- data/lib/xcres/version.rb +1 -1
- data/spec/fixtures/Example/Example/en.lproj/Localizable.strings +3 -0
- data/spec/fixtures/StringsFiles/syntax_error_missing_semicolon.strings +1 -0
- data/spec/integration/version/after/execution_output.txt +1 -1
- data/spec/unit/analyzer/strings_analyzer_spec.rb +32 -0
- data/spec/unit/command/install_command_spec.rb +27 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c693c63079477f934beba5d70aeeeb474ba89d3c
|
4
|
+
data.tar.gz: 37daa9576e22f68af31f1fcea2d8931287fadce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d34106718f0effdf97806992013b312b0e064f6577fc8ee8ae99e995d78aba7bd1567b899024e9731d7fcac60dcdf8ba25e5a54d38d341046e610fd5942915
|
7
|
+
data.tar.gz: 207373fdbeea3645e865910b744aeda5539b69ab4553773e3da4443e7440fa7d21158cb69afd10b27ecd623adbd8f494cbe772104bce718ef71677c754b619c0
|
data/Gemfile.lock
CHANGED
@@ -170,7 +170,7 @@ module XCRes
|
|
170
170
|
def read_plist_key(path, key)
|
171
171
|
raise ArgumentError, 'Path is required, but nil' if path.nil?
|
172
172
|
raise ArgumentError, 'Key is required, but nil' if key.nil?
|
173
|
-
out = `/usr/libexec/PlistBuddy -c "Print :#{key}" #{path}`.chomp
|
173
|
+
out = `/usr/libexec/PlistBuddy -c "Print :#{key}" "#{path}"`.chomp
|
174
174
|
raise ArgumentError, out unless $?.success?
|
175
175
|
out
|
176
176
|
end
|
@@ -185,10 +185,10 @@ module XCRes
|
|
185
185
|
def read_strings_file(path)
|
186
186
|
raise ArgumentError, "File '#{path}' doesn't exist" unless path.exist?
|
187
187
|
raise ArgumentError, "File '#{path}' is not a file" unless path.file?
|
188
|
-
error = `plutil -lint -s "#{path}"`
|
189
|
-
|
188
|
+
error = `plutil -lint -s "#{path}" 2>&1`
|
189
|
+
raise ArgumentError, "File %s is malformed:\n#{error}" % path.to_s unless $?.success?
|
190
190
|
json_or_error = `plutil -convert json "#{path}" -o -`.chomp
|
191
|
-
|
191
|
+
raise ArgumentError, "File %s couldn't be converted to JSON.\n#{json_or_error}" % path.to_s unless $?.success?
|
192
192
|
JSON.parse(json_or_error.force_encoding('UTF-8'))
|
193
193
|
rescue EncodingError => e
|
194
194
|
raise StandardError, "Encoding error in #{path}: #{e}"
|
@@ -239,6 +239,9 @@ module XCRes
|
|
239
239
|
# Load strings file contents
|
240
240
|
strings = read_strings_file(path)
|
241
241
|
|
242
|
+
# Reject generated identifiers used by Interface Builder
|
243
|
+
strings.reject! { |key, _| /^[a-zA-Z0-9]{3}(-[a-zA-Z0-9]{3}){2}/.match(key) }
|
244
|
+
|
242
245
|
keys = Hash[strings.map do |key, value|
|
243
246
|
[key, { value: key, comment: value.gsub(/[\r\n]/, ' ') }]
|
244
247
|
end]
|
@@ -167,8 +167,9 @@ class XCRes::InstallCommand < XCRes::ProjectCommand
|
|
167
167
|
#
|
168
168
|
def prefix_headers
|
169
169
|
@prefix_headers ||= target.build_configurations.map do |config|
|
170
|
-
|
171
|
-
|
170
|
+
setting = config.build_settings['GCC_PREFIX_HEADER']
|
171
|
+
setting ? Pathname(setting) : nil
|
172
|
+
end.flatten.compact.to_set
|
172
173
|
end
|
173
174
|
|
174
175
|
end
|
data/lib/xcres/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
"test" = "with missing semicolon"
|
@@ -13,6 +13,8 @@ describe 'XCRes::StringsAnalyzer' do
|
|
13
13
|
|
14
14
|
@analyzer = subject.new(@target)
|
15
15
|
@analyzer.logger = stub('Logger', :log)
|
16
|
+
@analyzer.expects(:warn).never
|
17
|
+
@analyzer.expects(:error).never
|
16
18
|
end
|
17
19
|
|
18
20
|
describe "#initialize" do
|
@@ -96,4 +98,34 @@ describe 'XCRes::StringsAnalyzer' do
|
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
101
|
+
describe "#read_strings_file" do
|
102
|
+
it 'should read a valid file' do
|
103
|
+
@analyzer.read_strings_file(fixture_path + 'Example/Example/en.lproj/Localizable.strings').should == {
|
104
|
+
"foo" => "Foo String",
|
105
|
+
"bar" => "Bar String",
|
106
|
+
"en_exclusive" => "Only in english",
|
107
|
+
"example" => "Lorem Ipsum",
|
108
|
+
"123-abc-3e7.text" => "Hello Storyboards",
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should raise an error for an invalid file' do
|
113
|
+
proc do
|
114
|
+
@analyzer.read_strings_file(fixture_path + 'StringsFiles/syntax_error_missing_semicolon.strings')
|
115
|
+
end.should.raise(StandardError).message.should.include "Old-style plist parser: missing semicolon in dictionary on line 2."
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe "#keys_by_file" do
|
120
|
+
it 'should return the string keys hash' do
|
121
|
+
path = fixture_path + 'Example/Example/en.lproj/Localizable.strings'
|
122
|
+
@analyzer.keys_by_file(path).should == {
|
123
|
+
"foo" => { value: "foo", comment: "Foo String" },
|
124
|
+
"bar" => { value: "bar", comment: "Bar String" },
|
125
|
+
"en_exclusive" => { value: "en_exclusive", comment: "Only in english" },
|
126
|
+
"example" => { value: "example", comment: "Lorem Ipsum" },
|
127
|
+
}
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
99
131
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path('../../spec_helper', __FILE__)
|
2
|
+
|
3
|
+
describe 'XCRes::InstallCommand' do
|
4
|
+
|
5
|
+
def subject
|
6
|
+
XCRes::InstallCommand
|
7
|
+
end
|
8
|
+
|
9
|
+
before do
|
10
|
+
@cmd = subject.new('xcres', [], {})
|
11
|
+
@cmd.stubs(:project).returns(xcodeproj)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#prefix_headers' do
|
15
|
+
it 'should return the expected prefix headers' do
|
16
|
+
@cmd.prefix_headers.to_a.should == [Pathname('Example/Example-Prefix.pch')]
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return empty array if a target has no value for GCC_PREFIX_HEADER' do
|
20
|
+
@cmd.target.build_configurations.each do |config|
|
21
|
+
config.build_settings.stubs(:[]).with('GCC_PREFIX_HEADER').returns(nil)
|
22
|
+
end
|
23
|
+
@cmd.prefix_headers.to_a.should == []
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marius Rackwitz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -289,6 +289,7 @@ files:
|
|
289
289
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests-Info.plist
|
290
290
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests.m
|
291
291
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/en.lproj/InfoPlist.strings
|
292
|
+
- spec/fixtures/StringsFiles/syntax_error_missing_semicolon.strings
|
292
293
|
- spec/integration.rb
|
293
294
|
- spec/integration/build-keyword-clash/after/Example/Example.xcodeproj.yaml
|
294
295
|
- spec/integration/build-keyword-clash/after/Example/Example/AppDelegate.h
|
@@ -519,6 +520,7 @@ files:
|
|
519
520
|
- spec/unit/builder/file_builder_spec.rb
|
520
521
|
- spec/unit/builder/resources_builder_spec.rb
|
521
522
|
- spec/unit/builder/string_builder_spec.rb
|
523
|
+
- spec/unit/command/install_command_spec.rb
|
522
524
|
- spec/unit/command/main_command_spec.rb
|
523
525
|
- spec/unit/command/project_command_spec.rb
|
524
526
|
- spec/unit/helper/file_helper_spec.rb
|
@@ -592,6 +594,7 @@ test_files:
|
|
592
594
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests-Info.plist
|
593
595
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/ExampleOSXTests.m
|
594
596
|
- spec/fixtures/ExampleOSX/ExampleOSXTests/en.lproj/InfoPlist.strings
|
597
|
+
- spec/fixtures/StringsFiles/syntax_error_missing_semicolon.strings
|
595
598
|
- spec/integration.rb
|
596
599
|
- spec/integration/build-keyword-clash/after/Example/Example.xcodeproj.yaml
|
597
600
|
- spec/integration/build-keyword-clash/after/Example/Example/AppDelegate.h
|
@@ -822,6 +825,7 @@ test_files:
|
|
822
825
|
- spec/unit/builder/file_builder_spec.rb
|
823
826
|
- spec/unit/builder/resources_builder_spec.rb
|
824
827
|
- spec/unit/builder/string_builder_spec.rb
|
828
|
+
- spec/unit/command/install_command_spec.rb
|
825
829
|
- spec/unit/command/main_command_spec.rb
|
826
830
|
- spec/unit/command/project_command_spec.rb
|
827
831
|
- spec/unit/helper/file_helper_spec.rb
|