File: README.md

package info (click to toggle)
ruby-cfpropertylist 4.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 160 kB
  • sloc: ruby: 1,428; makefile: 2
file content (79 lines) | stat: -rw-r--r-- 1,545 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
CFPropertyList implementation
class to read, manipulate and write both XML and binary property list
files (plist(5)) as defined by Apple. Have a look at CFPropertyList::List
for more documentation.

# Caution!

In version 3.0.0 we dropped Ruby 1.8 compatibility. If you are using
Ruby 1.8 consider to update Ruby; if you can't upgrade, don't upgrade
CFPropertyList.

# Installation

You could either use ruby gems and install it via
    
```bash
gem install CFPropertyList
```

or you could clone this repository and place it somewhere in your load path.

Example:
```ruby
require 'cfpropertylist'
```

If you're using Rails, you can add it into your Gemfile

```ruby
gem 'CFPropertyList'
```

# Usage

  ## create a arbitrary data structure of basic data types
  
```ruby
data = {
  'name' => 'John Doe',
  'missing' => true,
  'last_seen' => Time.now,
  'friends' => ['Jane Doe','Julian Doe'],
  'likes' => {
    'me' => false
  }
}
```

## create CFPropertyList::List object
  
```ruby
plist = CFPropertyList::List.new
```

## call CFPropertyList.guess() to create corresponding CFType values

```ruby  
plist.value = CFPropertyList.guess(data)
```

## write plist to file
```ruby
plist.save("example.plist", CFPropertyList::List::FORMAT_BINARY)
```

## … later, read it again
```ruby  
plist = CFPropertyList::List.new(:file => "example.plist")
data = CFPropertyList.native_types(plist.value)
```

# Author and license

**Author:**    Christian Kruse (mailto:cjk@wwwtech.de)

**Copyright:** Copyright (c) 2010

**License:**   MIT License