CFPropertyList 2.1.2 → 2.2.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.
- data/lib/rbBinaryCFPropertyList.rb +1 -1
- data/lib/rbCFPropertyList.rb +6 -15
- data/lib/rbCFTypes.rb +8 -4
- metadata +2 -4
- data/lib/lala.plist +0 -0
- data/lib/my_test.rb +0 -11
| @@ -214,7 +214,7 @@ module CFPropertyList | |
| 214 214 |  | 
| 215 215 | 
             
                # Convert the given string from one charset to another
         | 
| 216 216 | 
             
                def Binary.charset_convert(str,from,to="UTF-8")
         | 
| 217 | 
            -
                  return str. | 
| 217 | 
            +
                  return str.dup.force_encoding(from).encode(to) if str.respond_to?("encode")
         | 
| 218 218 | 
             
                  Iconv.conv(to,from,str)
         | 
| 219 219 | 
             
                end
         | 
| 220 220 |  | 
    
        data/lib/rbCFPropertyList.rb
    CHANGED
    
    | @@ -73,19 +73,6 @@ module CFPropertyList | |
| 73 73 | 
             
            end
         | 
| 74 74 |  | 
| 75 75 | 
             
            class String
         | 
| 76 | 
            -
              unless("".respond_to?(:blob) && "".respond_to?(:blob=)) then
         | 
| 77 | 
            -
                # The blob status of this string (to set to true if a binary string)
         | 
| 78 | 
            -
                attr_accessor :blob
         | 
| 79 | 
            -
              end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
              unless("".respond_to?(:blob?)) then
         | 
| 82 | 
            -
                # Returns whether or not +str+ is a blob.
         | 
| 83 | 
            -
                # @return [true,false] If true, this string contains binary data. If false, its a regular string
         | 
| 84 | 
            -
                def blob?
         | 
| 85 | 
            -
                  blob
         | 
| 86 | 
            -
                end
         | 
| 87 | 
            -
              end
         | 
| 88 | 
            -
             | 
| 89 76 | 
             
              unless("".respond_to?(:bytesize)) then
         | 
| 90 77 | 
             
                def bytesize
         | 
| 91 78 | 
             
                  self.length
         | 
| @@ -148,8 +135,11 @@ module CFPropertyList | |
| 148 135 | 
             
                when Float                 then CFReal.new(object)
         | 
| 149 136 | 
             
                when TrueClass, FalseClass then CFBoolean.new(object)
         | 
| 150 137 |  | 
| 138 | 
            +
                when Blob
         | 
| 139 | 
            +
                  CFData.new(object, CFData::DATA_RAW)
         | 
| 140 | 
            +
             | 
| 151 141 | 
             
                when String
         | 
| 152 | 
            -
                   | 
| 142 | 
            +
                  CFString.new(object)
         | 
| 153 143 |  | 
| 154 144 | 
             
                when Time, DateTime, Date  then CFDate.new(object)
         | 
| 155 145 |  | 
| @@ -296,7 +286,7 @@ module CFPropertyList | |
| 296 286 |  | 
| 297 287 | 
             
                    prsr = nil
         | 
| 298 288 | 
             
                    if filetype == "bplist" then
         | 
| 299 | 
            -
                      raise CFFormatError.new(" | 
| 289 | 
            +
                      raise CFFormatError.new("Wrong file version #{version}") unless version == "00"
         | 
| 300 290 | 
             
                      prsr = Binary.new
         | 
| 301 291 | 
             
                    else
         | 
| 302 292 | 
             
                      prsr = CFPropertyList.xml_parser_interface.new
         | 
| @@ -323,6 +313,7 @@ module CFPropertyList | |
| 323 313 |  | 
| 324 314 | 
             
                  when List::FORMAT_AUTO then # what we now do is ugly, but neccessary to recognize the file format
         | 
| 325 315 | 
             
                    magic_number = IO.read(file,8)
         | 
| 316 | 
            +
                    raise IOError.new("File #{file} is empty.") unless magic_number
         | 
| 326 317 | 
             
                    filetype = magic_number[0..5]
         | 
| 327 318 | 
             
                    version = magic_number[6..7]
         | 
| 328 319 |  | 
    
        data/lib/rbCFTypes.rb
    CHANGED
    
    | @@ -10,6 +10,13 @@ | |
| 10 10 | 
             
            require 'base64'
         | 
| 11 11 |  | 
| 12 12 | 
             
            module CFPropertyList
         | 
| 13 | 
            +
              ##
         | 
| 14 | 
            +
              # Blob is intended to distinguish between a Ruby String instance that should
         | 
| 15 | 
            +
              # be converted to a CFString type and a Ruby String instance that should be
         | 
| 16 | 
            +
              # converted to a CFData type
         | 
| 17 | 
            +
              class Blob < String
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 13 20 | 
             
              # This class defines the base class for all CFType classes
         | 
| 14 21 | 
             
              #
         | 
| 15 22 | 
             
              class CFType
         | 
| @@ -163,7 +170,6 @@ module CFPropertyList | |
| 163 170 | 
             
                def initialize(value=nil,format=DATA_BASE64)
         | 
| 164 171 | 
             
                  if(format == DATA_RAW)
         | 
| 165 172 | 
             
                    @raw_value = value
         | 
| 166 | 
            -
                    @raw_value.blob = true
         | 
| 167 173 | 
             
                  else
         | 
| 168 174 | 
             
                    @value = value
         | 
| 169 175 | 
             
                  end
         | 
| @@ -176,9 +182,7 @@ module CFPropertyList | |
| 176 182 |  | 
| 177 183 | 
             
                # get base64 decoded value
         | 
| 178 184 | 
             
                def decoded_value
         | 
| 179 | 
            -
                  @raw_value ||=  | 
| 180 | 
            -
                  @raw_value.blob = true
         | 
| 181 | 
            -
                  @raw_value
         | 
| 185 | 
            +
                  @raw_value ||= Blob.new(Base64.decode64(@value))
         | 
| 182 186 | 
             
                end
         | 
| 183 187 |  | 
| 184 188 | 
             
                # convert to XML
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: CFPropertyList
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.2.0
         | 
| 5 5 | 
             
              prerelease: 
         | 
| 6 6 | 
             
            platform: ruby
         | 
| 7 7 | 
             
            authors:
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2012-12- | 
| 12 | 
            +
            date: 2012-12-14 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: rake
         | 
| @@ -36,8 +36,6 @@ extra_rdoc_files: | |
| 36 36 | 
             
            - README
         | 
| 37 37 | 
             
            files:
         | 
| 38 38 | 
             
            - lib/cfpropertylist.rb
         | 
| 39 | 
            -
            - lib/lala.plist
         | 
| 40 | 
            -
            - lib/my_test.rb
         | 
| 41 39 | 
             
            - lib/rbBinaryCFPropertyList.rb
         | 
| 42 40 | 
             
            - lib/rbCFPlistError.rb
         | 
| 43 41 | 
             
            - lib/rbCFPropertyList.rb
         | 
    
        data/lib/lala.plist
    DELETED
    
    | Binary file | 
    
        data/lib/my_test.rb
    DELETED
    
    | @@ -1,11 +0,0 @@ | |
| 1 | 
            -
            $:.push('.')
         | 
| 2 | 
            -
            require 'rbCFPropertyList'
         | 
| 3 | 
            -
            ahash = {"SALTED-SHA512"=> "\214\351\005 \250\224\204\2510M\231\004\312YH\336yk\v\372\313\v\236\372u\255g\177\343\234$wh\221\001\220@/\343:\227\270\203\214g\320\361%'\315J/\t\317\354\275\017\000\241\225\302\322G\026& \205\344"}
         | 
| 4 | 
            -
            ahash["SALTED-SHA512"].blob = true
         | 
| 5 | 
            -
            bpl = CFPropertyList::List.new
         | 
| 6 | 
            -
            bpl.value = CFPropertyList.guess(ahash)
         | 
| 7 | 
            -
            results = bpl.to_str
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            fd = File.open("lala.plist", "wb")
         | 
| 10 | 
            -
            fd.write results
         | 
| 11 | 
            -
            fd.close
         |