nanaimo 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +98 -1
- data/.travis.yml +8 -3
- data/CHANGELOG.md +62 -0
- data/Gemfile +5 -1
- data/Gemfile.lock +28 -26
- data/README.md +1 -1
- data/Rakefile +9 -3
- data/bin/console +1 -0
- data/lib/nanaimo.rb +2 -0
- data/lib/nanaimo/object.rb +3 -1
- data/lib/nanaimo/plist.rb +2 -0
- data/lib/nanaimo/reader.rb +8 -8
- data/lib/nanaimo/unicode.rb +3 -2
- data/lib/nanaimo/version.rb +3 -1
- data/lib/nanaimo/writer.rb +5 -3
- data/lib/nanaimo/writer/pbxproj.rb +23 -18
- data/lib/nanaimo/writer/xml.rb +2 -0
- data/nanaimo.gemspec +3 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d44e0a3c7b1780d4f3599d2e8c215577fd518a95a8a581c9f322e0b607127df2
|
4
|
+
data.tar.gz: 3610b29faf500e0a9489a5f3e6fda8d6f3d0da4fa38eba6c28c66cd34521c221
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1bc93d5f8536a491ccbb93f6f22571e11201d08d8db3116c73c4707bfc54945ca65ad4f30fe09eb04ef700a9ac55b91779aff5f7bfefc9efdb88847d86874e7
|
7
|
+
data.tar.gz: e637b3f427c8507ff47f92ecea660416673fa7f5d5243b0a6f992cb7ac2133427041d96fe52f0a95ce11a0429fc8dc566f3e1af653166867dfd552622ebb229e
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,7 +1,104 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-02-13 09:45:35 -0800 using RuboCop version 0.52.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 22
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyle.
|
12
|
+
# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent
|
13
|
+
Layout/IndentHeredoc:
|
14
|
+
Exclude:
|
15
|
+
- 'Rakefile'
|
16
|
+
- 'lib/nanaimo/writer/xml.rb'
|
17
|
+
- 'spec/nanaimo/reader_spec.rb'
|
18
|
+
- 'spec/nanaimo/writer/xml_spec.rb'
|
19
|
+
|
20
|
+
# Offense count: 2
|
21
|
+
# Configuration parameters: Blacklist.
|
22
|
+
# Blacklist: END, (?-mix:EO[A-Z]{1})
|
23
|
+
Naming/HeredocDelimiterNaming:
|
24
|
+
Exclude:
|
25
|
+
- 'lib/nanaimo/writer/xml.rb'
|
26
|
+
|
27
|
+
# Offense count: 3
|
28
|
+
# Cop supports --auto-correct.
|
29
|
+
Performance/RegexpMatch:
|
30
|
+
Exclude:
|
31
|
+
- 'lib/nanaimo/unicode.rb'
|
32
|
+
- 'lib/nanaimo/writer.rb'
|
33
|
+
|
34
|
+
# Offense count: 1
|
35
|
+
# Cop supports --auto-correct.
|
36
|
+
# Configuration parameters: EnforcedStyle.
|
37
|
+
# SupportedStyles: compact, expanded
|
38
|
+
Style/EmptyMethod:
|
39
|
+
Exclude:
|
40
|
+
- 'lib/nanaimo/writer/xml.rb'
|
41
|
+
|
42
|
+
# Offense count: 1
|
43
|
+
# Cop supports --auto-correct.
|
44
|
+
Style/Encoding:
|
45
|
+
Exclude:
|
46
|
+
- 'nanaimo.gemspec'
|
47
|
+
|
48
|
+
# Offense count: 2
|
49
|
+
# Configuration parameters: .
|
50
|
+
# SupportedStyles: annotated, template, unannotated
|
51
|
+
Style/FormatStringToken:
|
52
|
+
EnforcedStyle: unannotated
|
53
|
+
|
54
|
+
# Offense count: 2
|
55
|
+
Style/IdenticalConditionalBranches:
|
56
|
+
Exclude:
|
57
|
+
- 'lib/nanaimo/unicode.rb'
|
58
|
+
|
59
|
+
# Offense count: 4
|
60
|
+
# Cop supports --auto-correct.
|
61
|
+
Style/IfUnlessModifier:
|
62
|
+
Exclude:
|
63
|
+
- 'lib/nanaimo/reader.rb'
|
64
|
+
- 'lib/nanaimo/unicode.rb'
|
65
|
+
|
66
|
+
# Offense count: 3
|
67
|
+
# Cop supports --auto-correct.
|
68
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle.
|
69
|
+
# SupportedStyles: predicate, comparison
|
70
|
+
Style/NumericPredicate:
|
71
|
+
Exclude:
|
72
|
+
- 'spec/**/*'
|
73
|
+
- 'lib/nanaimo/writer.rb'
|
74
|
+
|
75
|
+
# Offense count: 8
|
76
|
+
# Cop supports --auto-correct.
|
77
|
+
# Configuration parameters: PreferredDelimiters.
|
78
|
+
Style/PercentLiteralDelimiters:
|
79
|
+
Exclude:
|
80
|
+
- 'lib/nanaimo/reader.rb'
|
81
|
+
- 'lib/nanaimo/unicode.rb'
|
82
|
+
- 'spec/nanaimo/reader_spec.rb'
|
83
|
+
- 'spec/nanaimo/unicode_spec.rb'
|
84
|
+
- 'spec/nanaimo/writer/xml_spec.rb'
|
85
|
+
- 'spec/nanaimo/writer_spec.rb'
|
86
|
+
|
87
|
+
# Offense count: 1
|
88
|
+
# Cop supports --auto-correct.
|
89
|
+
Style/RedundantFreeze:
|
90
|
+
Exclude:
|
91
|
+
- 'lib/nanaimo/reader.rb'
|
92
|
+
|
93
|
+
# Offense count: 1
|
94
|
+
# Cop supports --auto-correct.
|
95
|
+
# Configuration parameters: MinSize.
|
96
|
+
# SupportedStyles: percent, brackets
|
97
|
+
Style/SymbolArray:
|
98
|
+
EnforcedStyle: brackets
|
99
|
+
|
100
|
+
# Offense count: 56
|
101
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
102
|
+
# URISchemes: http, https
|
103
|
+
Metrics/LineLength:
|
104
|
+
Max: 331
|
data/.travis.yml
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
dist: trusty
|
2
|
+
bundler_args: --without debugging documentation
|
1
3
|
branches:
|
2
4
|
only:
|
3
5
|
- master
|
@@ -6,8 +8,11 @@ language: ruby
|
|
6
8
|
cache: bundler
|
7
9
|
rvm:
|
8
10
|
# The latest ruby version
|
9
|
-
- 2.
|
11
|
+
- 2.7.0
|
12
|
+
- 2.6.2
|
13
|
+
- 2.5.0
|
14
|
+
- 2.4.2
|
10
15
|
# OS X 10.9.5-10.10.0 (2.0.0-p481)
|
11
16
|
- 2.0.0-p481
|
12
|
-
|
13
|
-
-
|
17
|
+
before_install:
|
18
|
+
- gem install bundler -v "~> 1.17"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,67 @@
|
|
1
1
|
# Nanaimo Changelog
|
2
2
|
|
3
|
+
## 0.3.0 (2020-07-17)
|
4
|
+
|
5
|
+
##### Enhancements
|
6
|
+
|
7
|
+
* None.
|
8
|
+
|
9
|
+
##### Bug Fixes
|
10
|
+
|
11
|
+
* None.
|
12
|
+
|
13
|
+
|
14
|
+
## 0.2.6 (2018-07-01)
|
15
|
+
|
16
|
+
##### Enhancements
|
17
|
+
|
18
|
+
* None.
|
19
|
+
|
20
|
+
##### Bug Fixes
|
21
|
+
|
22
|
+
* Fix parse errors crashing when attempting to show context when the error
|
23
|
+
occurs on the first character in the plist.
|
24
|
+
[Samuel Giddins](https://github.com/segiddins)
|
25
|
+
|
26
|
+
|
27
|
+
## 0.2.5 (2018-04-04)
|
28
|
+
|
29
|
+
##### Enhancements
|
30
|
+
|
31
|
+
* None.
|
32
|
+
|
33
|
+
##### Bug Fixes
|
34
|
+
|
35
|
+
* Fix parsing arrays that contain a comment after a trailing comma.
|
36
|
+
[Samuel Giddins](https://github.com/segiddins)
|
37
|
+
[#26](https://github.com/CocoaPods/Nanaimo/issues/26)
|
38
|
+
|
39
|
+
|
40
|
+
## 0.2.4 (2018-03-22)
|
41
|
+
|
42
|
+
##### Enhancements
|
43
|
+
|
44
|
+
* Enable frozen string literals to improve performance.
|
45
|
+
[Samuel Giddins](https://github.com/segiddins)
|
46
|
+
|
47
|
+
##### Bug Fixes
|
48
|
+
|
49
|
+
* None.
|
50
|
+
|
51
|
+
|
52
|
+
## 0.2.3 (2016-11-30)
|
53
|
+
|
54
|
+
##### Enhancements
|
55
|
+
|
56
|
+
* None.
|
57
|
+
|
58
|
+
##### Bug Fixes
|
59
|
+
|
60
|
+
* Quote the empty string `nil` is implicitly written as in non-strict mode.
|
61
|
+
[Samuel Giddins](https://github.com/segiddins)
|
62
|
+
[Xcodeproj#453](https://github.com/CocoaPods/Xcodeproj/issues/453)
|
63
|
+
|
64
|
+
|
3
65
|
## 0.2.2 (2016-11-04)
|
4
66
|
|
5
67
|
##### Enhancements
|
data/Gemfile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in nanaimo.gemspec
|
4
6
|
gemspec
|
5
7
|
|
6
8
|
group :development do
|
7
|
-
gem '
|
9
|
+
gem 'rake', '~> 12.0'
|
10
|
+
gem 'rspec'
|
11
|
+
gem 'rubocop', install_if: RUBY_VERSION >= '2.1'
|
8
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nanaimo (0.
|
4
|
+
nanaimo (0.3.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
ast (2.
|
10
|
-
diff-lcs (1.
|
11
|
-
|
12
|
-
|
9
|
+
ast (2.4.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
parallel (1.12.1)
|
12
|
+
parser (2.5.0.2)
|
13
|
+
ast (~> 2.4.0)
|
13
14
|
powerpack (0.1.1)
|
14
|
-
rainbow (
|
15
|
-
rake (
|
16
|
-
rspec (3.
|
17
|
-
rspec-core (~> 3.
|
18
|
-
rspec-expectations (~> 3.
|
19
|
-
rspec-mocks (~> 3.
|
20
|
-
rspec-core (3.
|
21
|
-
rspec-support (~> 3.
|
22
|
-
rspec-expectations (3.
|
15
|
+
rainbow (3.0.0)
|
16
|
+
rake (12.3.3)
|
17
|
+
rspec (3.9.0)
|
18
|
+
rspec-core (~> 3.9.0)
|
19
|
+
rspec-expectations (~> 3.9.0)
|
20
|
+
rspec-mocks (~> 3.9.0)
|
21
|
+
rspec-core (3.9.1)
|
22
|
+
rspec-support (~> 3.9.1)
|
23
|
+
rspec-expectations (3.9.1)
|
23
24
|
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.
|
25
|
-
rspec-mocks (3.
|
25
|
+
rspec-support (~> 3.9.0)
|
26
|
+
rspec-mocks (3.9.1)
|
26
27
|
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.
|
28
|
-
rspec-support (3.
|
29
|
-
rubocop (0.
|
30
|
-
|
28
|
+
rspec-support (~> 3.9.0)
|
29
|
+
rspec-support (3.9.2)
|
30
|
+
rubocop (0.52.1)
|
31
|
+
parallel (~> 1.10)
|
32
|
+
parser (>= 2.4.0.2, < 3.0)
|
31
33
|
powerpack (~> 0.1)
|
32
|
-
rainbow (>=
|
34
|
+
rainbow (>= 2.2.2, < 4.0)
|
33
35
|
ruby-progressbar (~> 1.7)
|
34
36
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
35
|
-
ruby-progressbar (1.
|
36
|
-
unicode-display_width (1.
|
37
|
+
ruby-progressbar (1.9.0)
|
38
|
+
unicode-display_width (1.3.0)
|
37
39
|
|
38
40
|
PLATFORMS
|
39
41
|
ruby
|
@@ -41,9 +43,9 @@ PLATFORMS
|
|
41
43
|
DEPENDENCIES
|
42
44
|
bundler (~> 1.12)
|
43
45
|
nanaimo!
|
44
|
-
rake (~>
|
45
|
-
rspec
|
46
|
+
rake (~> 12.0)
|
47
|
+
rspec
|
46
48
|
rubocop
|
47
49
|
|
48
50
|
BUNDLED WITH
|
49
|
-
1.
|
51
|
+
1.17.3
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
47
47
|
|
48
48
|
## Contributing
|
49
49
|
|
50
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/CocoaPods/nanaimo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
51
51
|
|
52
52
|
|
53
53
|
## License
|
data/Rakefile
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
|
-
require 'rubocop/rake_task'
|
4
5
|
|
5
6
|
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
RuboCop::RakeTask.new
|
7
7
|
|
8
|
-
task default: [:spec
|
8
|
+
task default: [:spec]
|
9
|
+
|
10
|
+
if RUBY_VERSION >= '2.1'
|
11
|
+
require 'rubocop/rake_task'
|
12
|
+
RuboCop::RakeTask.new
|
13
|
+
task default: :rubocop
|
14
|
+
end
|
9
15
|
|
10
16
|
task :generate_nextstep_mappings do
|
11
17
|
require 'net/http'
|
data/bin/console
CHANGED
data/lib/nanaimo.rb
CHANGED
data/lib/nanaimo/object.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Nanaimo
|
2
4
|
# An object that belongs to a plist.
|
3
5
|
#
|
@@ -73,7 +75,7 @@ module Nanaimo
|
|
73
75
|
#
|
74
76
|
class Data < Object
|
75
77
|
def initialize(value, annotation)
|
76
|
-
value &&= value.force_encoding(Encoding::BINARY)
|
78
|
+
value &&= value.dup.force_encoding(Encoding::BINARY)
|
77
79
|
super(value, annotation)
|
78
80
|
end
|
79
81
|
|
data/lib/nanaimo/plist.rb
CHANGED
data/lib/nanaimo/reader.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
|
+
|
2
3
|
module Nanaimo
|
3
4
|
# Transforms plist strings into Plist objects.
|
4
5
|
#
|
@@ -123,8 +124,8 @@ module Nanaimo
|
|
123
124
|
# TODO
|
124
125
|
end
|
125
126
|
|
126
|
-
def parse_object
|
127
|
-
_comment = skip_to_non_space_matching_annotations
|
127
|
+
def parse_object(already_parsed_comment: false)
|
128
|
+
_comment = skip_to_non_space_matching_annotations unless already_parsed_comment
|
128
129
|
start_pos = @scanner.pos
|
129
130
|
raise_parser_error ParseError, 'Unexpected end of string while parsing' if @scanner.eos?
|
130
131
|
if @scanner.skip(/\{/)
|
@@ -162,10 +163,10 @@ module Nanaimo
|
|
162
163
|
def parse_array
|
163
164
|
objects = []
|
164
165
|
until @scanner.eos?
|
165
|
-
|
166
|
+
_comment = skip_to_non_space_matching_annotations
|
166
167
|
break if @scanner.skip(/\)/)
|
167
168
|
|
168
|
-
objects << parse_object
|
169
|
+
objects << parse_object(already_parsed_comment: true)
|
169
170
|
|
170
171
|
eat_whitespace!
|
171
172
|
break if @scanner.skip(/\)/)
|
@@ -180,10 +181,10 @@ module Nanaimo
|
|
180
181
|
def parse_dictionary
|
181
182
|
objects = {}
|
182
183
|
until @scanner.eos?
|
183
|
-
skip_to_non_space_matching_annotations
|
184
|
+
_comment = skip_to_non_space_matching_annotations
|
184
185
|
break if @scanner.skip(/}/)
|
185
186
|
|
186
|
-
key = parse_object
|
187
|
+
key = parse_object(already_parsed_comment: true)
|
187
188
|
eat_whitespace!
|
188
189
|
unless @scanner.skip(/=/)
|
189
190
|
raise_parser_error ParseError, "Dictionary missing value for key #{key.as_ruby.inspect}, expected '=' and found #{current_character.inspect}"
|
@@ -262,8 +263,6 @@ module Nanaimo
|
|
262
263
|
next
|
263
264
|
end
|
264
265
|
|
265
|
-
eat_whitespace!
|
266
|
-
|
267
266
|
break
|
268
267
|
end
|
269
268
|
annotation
|
@@ -273,6 +272,7 @@ module Nanaimo
|
|
273
272
|
pos = scanner.charpos
|
274
273
|
line = scanner.string[0..scanner.charpos].scan(NEWLINE).size + 1
|
275
274
|
column = pos - (scanner.string.rindex(NEWLINE, pos - 1) || -1)
|
275
|
+
column = [1, column].max
|
276
276
|
[line, column]
|
277
277
|
end
|
278
278
|
|
data/lib/nanaimo/unicode.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen-string-literal: true
|
2
|
+
|
2
3
|
require 'nanaimo/unicode/next_step_mapping'
|
3
4
|
require 'nanaimo/unicode/quote_maps'
|
4
5
|
module Nanaimo
|
@@ -11,7 +12,7 @@ module Nanaimo
|
|
11
12
|
module_function
|
12
13
|
|
13
14
|
def quotify_string(string)
|
14
|
-
string.gsub(QUOTE_REGEXP
|
15
|
+
string.gsub(QUOTE_REGEXP, QUOTE_MAP)
|
15
16
|
end
|
16
17
|
|
17
18
|
ESCAPE_PREFIXES = %W(
|
@@ -82,7 +83,7 @@ module Nanaimo
|
|
82
83
|
XML_STRING_ESCAPE_REGEXP = Regexp.union(XML_STRING_ESCAPES.keys)
|
83
84
|
|
84
85
|
def xml_escape_string(string)
|
85
|
-
string.to_s.gsub(XML_STRING_ESCAPE_REGEXP
|
86
|
+
string.to_s.gsub(XML_STRING_ESCAPE_REGEXP, XML_STRING_ESCAPES)
|
86
87
|
end
|
87
88
|
end
|
88
89
|
end
|
data/lib/nanaimo/version.rb
CHANGED
data/lib/nanaimo/writer.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Nanaimo
|
2
4
|
# Transforms native ruby objects or Plist objects into their ASCII Plist
|
3
5
|
# string representation.
|
@@ -25,7 +27,7 @@ module Nanaimo
|
|
25
27
|
#
|
26
28
|
UTF8 = "// !$*UTF8*$!\n".freeze
|
27
29
|
|
28
|
-
# @param plist [Plist,String,Hash,Array] The plist
|
30
|
+
# @param plist [Plist,String,Hash,Array] The plist object to write
|
29
31
|
# @param pretty [Boolean] Whether to serialize annotations and add
|
30
32
|
# spaces and newlines to make output more legible
|
31
33
|
# @param output [#<<] The output stream to write the plist to
|
@@ -74,7 +76,7 @@ module Nanaimo
|
|
74
76
|
write_array(object)
|
75
77
|
when Dictionary, ::Hash
|
76
78
|
write_dictionary(object)
|
77
|
-
when QUOTED_STRING_REGEXP, QuotedString
|
79
|
+
when QUOTED_STRING_REGEXP, QuotedString
|
78
80
|
write_quoted_string(object)
|
79
81
|
when String, ::String, Symbol
|
80
82
|
write_string(object)
|
@@ -88,7 +90,7 @@ module Nanaimo
|
|
88
90
|
output
|
89
91
|
end
|
90
92
|
|
91
|
-
QUOTED_STRING_REGEXP = %r{[^\w\./]}
|
93
|
+
QUOTED_STRING_REGEXP = %r{\A\z|[^\w\./]|\A___}
|
92
94
|
private_constant :QUOTED_STRING_REGEXP
|
93
95
|
|
94
96
|
def write_string_quoted_if_necessary(object)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Nanaimo
|
2
4
|
class Writer
|
3
5
|
# Transforms native ruby objects or Plist objects into their ASCII Plist
|
@@ -7,8 +9,8 @@ module Nanaimo
|
|
7
9
|
ISA = String.new('isa', '')
|
8
10
|
private_constant :ISA
|
9
11
|
|
10
|
-
def initialize(
|
11
|
-
super
|
12
|
+
def initialize(plist, **args)
|
13
|
+
super(plist, **args)
|
12
14
|
@objects_section = false
|
13
15
|
end
|
14
16
|
|
@@ -26,7 +28,7 @@ module Nanaimo
|
|
26
28
|
write_newline
|
27
29
|
output << "/* Begin #{isa} section */"
|
28
30
|
write_newline
|
29
|
-
sort_dictionary(kvs).each do |k, v|
|
31
|
+
sort_dictionary(kvs, key_can_be_isa: false).each do |k, v|
|
30
32
|
write_dictionary_key_value_pair(k, v)
|
31
33
|
end
|
32
34
|
output << "/* End #{isa} section */"
|
@@ -38,31 +40,34 @@ module Nanaimo
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def write_dictionary_key_value_pair(k, v)
|
41
|
-
|
43
|
+
# since the objects section is always at the top-level,
|
44
|
+
# we can avoid checking if we're starting the 'objects'
|
45
|
+
# section if we're further "indented" (aka deeper) in the project
|
46
|
+
@objects_section = true if indent == 1 && value_for(k) == 'objects'
|
47
|
+
|
42
48
|
super
|
43
49
|
end
|
44
50
|
|
45
|
-
def sort_dictionary(dictionary)
|
51
|
+
def sort_dictionary(dictionary, key_can_be_isa: true)
|
46
52
|
hash = value_for(dictionary)
|
47
|
-
hash.
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
key2 = value_for(k2)
|
55
|
-
next -1 if key1 == 'isa'
|
56
|
-
next 1 if key2 == 'isa'
|
57
|
-
key1 <=> key2
|
53
|
+
hash.sort_by do |k, _v|
|
54
|
+
k = value_for(k)
|
55
|
+
if key_can_be_isa
|
56
|
+
k == 'isa' ? '' : k
|
57
|
+
else
|
58
|
+
k
|
59
|
+
end
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
def isa_for(dictionary)
|
62
64
|
dictionary = value_for(dictionary)
|
63
65
|
return unless dictionary.is_a?(Hash)
|
64
|
-
isa = dictionary
|
65
|
-
|
66
|
+
if isa = dictionary['isa']
|
67
|
+
value_for(isa)
|
68
|
+
elsif isa = dictionary[ISA]
|
69
|
+
value_for(isa)
|
70
|
+
end
|
66
71
|
end
|
67
72
|
|
68
73
|
def flat_dictionary?(dictionary)
|
data/lib/nanaimo/writer/xml.rb
CHANGED
data/nanaimo.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path('../lib', __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require 'nanaimo/version'
|
@@ -19,6 +21,6 @@ Gem::Specification.new do |spec|
|
|
19
21
|
spec.require_paths = ['lib']
|
20
22
|
|
21
23
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
24
|
+
spec.add_development_dependency 'rake', '~> 12.3'
|
23
25
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanaimo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danielle Tomlinson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '12.3'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '12.3'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,8 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
|
110
|
-
rubygems_version: 2.6.7
|
109
|
+
rubygems_version: 3.0.3
|
111
110
|
signing_key:
|
112
111
|
specification_version: 4
|
113
112
|
summary: A library for (de)serialization of ASCII Plists.
|