nanaimo 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5c776733dc2e81f8c653f7825a5313a7cb1c0e8588f76c6bc07178ee6dc1486
4
- data.tar.gz: fe1b3fdacf28874194c37fc0c112202f972c251979e444fa31832f04fbd266d8
3
+ metadata.gz: c1081493a2517a57bb1e78617df2d88f088ab01a5d67b349ca6bdb7a1b0abfc5
4
+ data.tar.gz: 7a654acc8e0e8f792a584d3dab347a29fc6cb6e18d8a79e55d0a83cfbf6574ff
5
5
  SHA512:
6
- metadata.gz: b40376d8b00dc4cbed495c40503f0b5f7b99b1bb8f68f383eab8de510940db9277d3704e6ee5cdb85159124f22938c32412430099813aff25f14118e4e9757e1
7
- data.tar.gz: 3047fc03c205700b4408f3efa7e4ae7b286daa5d139bb6a12f8539e6a55c497c9d0781c36027fe4d512dc26975cb0157a8a4678ead8350d6f132d23777bbaa4b
6
+ metadata.gz: 51b9aabdc0d52b41745e9d212d5ab11b682ac84a62d4a164099b98a21049e8029c378621c8ee8b82a55b7ab6eb5f548372ea84cd2381270f8a3ba30d508a6523
7
+ data.tar.gz: 866422ae0447fc661d5fa9dc551f62b31aba0094c0a1acdedaeb90a69523260ff765794f1197112b157fe093b6e8e17e401615c5b258ff20826b522070e1aac7
@@ -1,5 +1,18 @@
1
1
  # Nanaimo Changelog
2
2
 
3
+ ## 0.2.6 (2018-07-01)
4
+
5
+ ##### Enhancements
6
+
7
+ * None.
8
+
9
+ ##### Bug Fixes
10
+
11
+ * Fix parse errors crashing when attempting to show context when the error
12
+ occurs on the first character in the plist.
13
+ [Samuel Giddins](https://github.com/segiddins)
14
+
15
+
3
16
  ## 0.2.5 (2018-04-04)
4
17
 
5
18
  ##### Enhancements
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nanaimo (0.2.5)
4
+ nanaimo (0.2.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  rubocop
49
49
 
50
50
  BUNDLED WITH
51
- 1.16.1
51
+ 1.16.2
@@ -272,6 +272,7 @@ module Nanaimo
272
272
  pos = scanner.charpos
273
273
  line = scanner.string[0..scanner.charpos].scan(NEWLINE).size + 1
274
274
  column = pos - (scanner.string.rindex(NEWLINE, pos - 1) || -1)
275
+ column = [1, column].max
275
276
  [line, column]
276
277
  end
277
278
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanaimo
4
- VERSION = '0.2.5'.freeze
4
+ VERSION = '0.2.6'.freeze
5
5
  end
@@ -28,7 +28,7 @@ module Nanaimo
28
28
  write_newline
29
29
  output << "/* Begin #{isa} section */"
30
30
  write_newline
31
- sort_dictionary(kvs).each do |k, v|
31
+ sort_dictionary(kvs, key_can_be_isa: false).each do |k, v|
32
32
  write_dictionary_key_value_pair(k, v)
33
33
  end
34
34
  output << "/* End #{isa} section */"
@@ -40,31 +40,34 @@ module Nanaimo
40
40
  end
41
41
 
42
42
  def write_dictionary_key_value_pair(k, v)
43
- @objects_section = true if value_for(k) == 'objects'
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
+
44
48
  super
45
49
  end
46
50
 
47
- def sort_dictionary(dictionary)
51
+ def sort_dictionary(dictionary, key_can_be_isa: true)
48
52
  hash = value_for(dictionary)
49
- hash.to_a.sort do |(k1, v1), (k2, v2)|
50
- v2_isa = isa_for(v2)
51
- v1_isa = v2_isa && isa_for(v1)
52
- comp = v1_isa <=> v2_isa
53
- next comp if !comp.zero? && v1_isa
54
-
55
- key1 = value_for(k1)
56
- key2 = value_for(k2)
57
- next -1 if key1 == 'isa'
58
- next 1 if key2 == 'isa'
59
- 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
60
60
  end
61
61
  end
62
62
 
63
63
  def isa_for(dictionary)
64
64
  dictionary = value_for(dictionary)
65
65
  return unless dictionary.is_a?(Hash)
66
- isa = dictionary.values_at('isa', ISA).map(&method(:value_for)).compact.first
67
- isa && value_for(isa)
66
+ if isa = dictionary['isa']
67
+ value_for(isa)
68
+ elsif isa = dictionary[ISA]
69
+ value_for(isa)
70
+ end
68
71
  end
69
72
 
70
73
  def flat_dictionary?(dictionary)
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.2.5
4
+ version: 0.2.6
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: 2018-04-04 00:00:00.000000000 Z
12
+ date: 2018-07-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  requirements: []
109
109
  rubyforge_project:
110
- rubygems_version: 2.7.6
110
+ rubygems_version: 2.7.7
111
111
  signing_key:
112
112
  specification_version: 4
113
113
  summary: A library for (de)serialization of ASCII Plists.