nixenvironment 0.0.118 → 0.0.119

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.
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'rexml/document'
4
+
5
+ module CFPropertyList228
6
+ # XML parser
7
+ class ReXMLParser < ParserInterface
8
+ # read a XML file
9
+ # opts::
10
+ # * :file - The filename of the file to load
11
+ # * :data - The data to parse
12
+ def load(opts)
13
+
14
+ doc = nil
15
+ if(opts.has_key?(:file)) then
16
+ File.open(opts[:file], "rb") { |fd| doc = REXML::Document.new(fd) }
17
+ else
18
+ doc = REXML::Document.new(opts[:data])
19
+ end
20
+
21
+ if doc
22
+ root = doc.root.elements[1]
23
+ return import_xml(root)
24
+ end
25
+ rescue REXML::ParseException => e
26
+ raise CFFormatError.new('invalid XML: ' + e.message)
27
+ end
28
+
29
+ # serialize CFPropertyList228 object to XML
30
+ # opts = {}:: Specify options: :formatted - Use indention and line breaks
31
+ def to_str(opts={})
32
+ doc = REXML::Document.new
33
+ @doc = doc
34
+
35
+ doc.context[:attribute_quote] = :quote
36
+
37
+ doc.add_element 'plist', {'version' => '1.0'}
38
+ doc.root << opts[:root].to_xml(self)
39
+
40
+ formatter = if opts[:formatted] then
41
+ f = REXML::Formatters::Pretty.new(2)
42
+ f.compact = true
43
+ f
44
+ else
45
+ REXML::Formatters::Default.new
46
+ end
47
+
48
+ str = formatter.write(doc.root, "")
49
+ str1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" + str + "\n"
50
+ str1.force_encoding('UTF-8') if str1.respond_to?(:force_encoding)
51
+
52
+ return str1
53
+ end
54
+
55
+ def new_node(name)
56
+ REXML::Element.new(name)
57
+ end
58
+
59
+ def new_text(val)
60
+ val
61
+ end
62
+
63
+ def append_node(parent, child)
64
+ if child.is_a?(String) then
65
+ parent.add_text child
66
+ else
67
+ parent.elements << child
68
+ end
69
+ parent
70
+ end
71
+
72
+ protected
73
+
74
+ # get the value of a DOM node
75
+ def get_value(n)
76
+ content = n.text
77
+
78
+ content.force_encoding('UTF-8') if content.respond_to?(:force_encoding)
79
+ content
80
+ end
81
+
82
+ # import the XML values
83
+ def import_xml(node)
84
+ ret = nil
85
+
86
+ case node.name
87
+ when 'dict'
88
+ hsh = Hash.new
89
+ key = nil
90
+
91
+ if node.has_elements? then
92
+ node.elements.each do |n|
93
+ next if n.name == '#text' # avoid a bug of libxml
94
+ next if n.name == '#comment'
95
+
96
+ if n.name == "key" then
97
+ key = get_value(n)
98
+ key = '' if key.nil? # REXML returns nil if key is empty
99
+ else
100
+ raise CFFormatError.new("Format error!") if key.nil?
101
+ hsh[key] = import_xml(n)
102
+ key = nil
103
+ end
104
+ end
105
+ end
106
+
107
+ if hsh['CF$UID'] and hsh.keys.length == 1
108
+ ret = CFUid.new(hsh['CF$UID'].value)
109
+ else
110
+ ret = CFDictionary.new(hsh)
111
+ end
112
+
113
+ when 'array'
114
+ ary = Array.new
115
+
116
+ if node.has_elements? then
117
+ node.elements.each do |n|
118
+ next if n.name == '#text' # avoid a bug of libxml
119
+ ary.push import_xml(n)
120
+ end
121
+ end
122
+
123
+ ret = CFArray.new(ary)
124
+
125
+ when 'true'
126
+ ret = CFBoolean.new(true)
127
+ when 'false'
128
+ ret = CFBoolean.new(false)
129
+ when 'real'
130
+ ret = CFReal.new(get_value(node).to_f)
131
+ when 'integer'
132
+ ret = CFInteger.new(get_value(node).to_i)
133
+ when 'string'
134
+ ret = CFString.new(get_value(node))
135
+ ret.value = '' if ret.value.nil? # REXML returns nil for empty elements' .text attribute
136
+ when 'data'
137
+ ret = CFData.new(get_value(node))
138
+ when 'date'
139
+ ret = CFDate.new(CFDate.parse_date(get_value(node)))
140
+ end
141
+
142
+ return ret
143
+ end
144
+ end
145
+ end
146
+
147
+ # eof
@@ -1,25 +1,26 @@
1
- require 'cfpropertylist'
1
+ require_relative 'CFPropertyList228/lib/cfpropertylist'
2
+ require_relative 'CFPropertyList228/lib/cfpropertylist/rbCFPropertyList'
2
3
 
3
4
  module Nixenvironment
4
5
  class Plist
5
- FORMAT_BINARY = CFPropertyList::List::FORMAT_BINARY
6
- FORMAT_XML = CFPropertyList::List::FORMAT_XML
7
- FORMAT_PLAIN = CFPropertyList::List::FORMAT_PLAIN
8
- FORMAT_AUTO = CFPropertyList::List::FORMAT_AUTO
6
+ FORMAT_BINARY = CFPropertyList228::List::FORMAT_BINARY
7
+ FORMAT_XML = CFPropertyList228::List::FORMAT_XML
8
+ # FORMAT_PLAIN = CFPropertyList228::List::FORMAT_PLAIN
9
+ FORMAT_AUTO = CFPropertyList228::List::FORMAT_AUTO
9
10
 
10
11
  def self.from_file(path)
11
- new(CFPropertyList::List.new(:file => path, :format => ENV['UNITY_BUILD'].present? ? FORMAT_XML : FORMAT_AUTO))
12
+ new(CFPropertyList228::List.new(:file => path))
12
13
  end
13
14
 
14
15
  def self.from_hash(hash)
15
- plist = CFPropertyList::List.new
16
- plist.value = CFPropertyList.guess(hash)
16
+ plist = CFPropertyList228::List.new
17
+ plist.value = CFPropertyList228.guess(hash)
17
18
  plist.format = FORMAT_XML
18
19
  new(plist)
19
20
  end
20
21
 
21
22
  def self.from_str(str)
22
- plist = CFPropertyList::List.new
23
+ plist = CFPropertyList228::List.new
23
24
  plist.load_str(str)
24
25
  new(plist)
25
26
  end
@@ -27,7 +28,7 @@ module Nixenvironment
27
28
  def initialize(plist)
28
29
  @plist = plist
29
30
  @path = @plist.filename
30
- @data = CFPropertyList.native_types(@plist.value)
31
+ @data = CFPropertyList228.native_types(@plist.value)
31
32
  end
32
33
 
33
34
  def [](key)
@@ -36,7 +37,7 @@ module Nixenvironment
36
37
 
37
38
  def []=(key, value)
38
39
  @data[key] = value
39
- @plist.value = CFPropertyList.guess(@data, :convert_unknown_to_string => true)
40
+ @plist.value = CFPropertyList228.guess(@data, :convert_unknown_to_string => true)
40
41
  end
41
42
 
42
43
  def save(path = nil, format = nil, formatted = true)
@@ -1,3 +1,3 @@
1
1
  module Nixenvironment
2
- VERSION = '0.0.118'
2
+ VERSION = '0.0.119'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nixenvironment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.118
4
+ version: 0.0.119
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen
@@ -276,6 +276,15 @@ files:
276
276
  - legacy/UnityBuildAutomationScripts/NIXBuilder.cs
277
277
  - legacy/UnityBuildEnvVars.py
278
278
  - lib/nixenvironment.rb
279
+ - lib/nixenvironment/CFPropertyList228/README
280
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist.rb
281
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbBinaryCFPropertyList.rb
282
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFPlistError.rb
283
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFPropertyList.rb
284
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbCFTypes.rb
285
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbLibXMLParser.rb
286
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbNokogiriParser.rb
287
+ - lib/nixenvironment/CFPropertyList228/lib/cfpropertylist/rbREXMLParser.rb
279
288
  - lib/nixenvironment/archiver.rb
280
289
  - lib/nixenvironment/build_env_vars_loader.rb
281
290
  - lib/nixenvironment/cmd_executor.rb