kballard-osx-plist 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,12 @@
1
+ == 1.0.3 / 2009-09-21
2
+ * Add two new methods OSX::PropertyList.load_file and OSX::PropertyList.dump_file
3
+ * Clean up the RDoc documentation
4
+
5
+ == 1.0.2 / 2009-09-17
6
+ * Build properly under Mac OS X 10.6
7
+
8
+ == 1.0.1 / 2009-02-05
9
+ * Ruby 1.9.1 compatibility
10
+
1
11
  == 1.0 / 2008-04-25
2
12
  * First public release
@@ -4,6 +4,7 @@ README.txt
4
4
  Rakefile
5
5
  ext/plist/extconf.rb
6
6
  ext/plist/plist.c
7
+ lib/osx/plist.rb
7
8
  test/fixtures/xml_plist
8
9
  test/suite.rb
9
10
  test/test_plist.rb
data/README.txt CHANGED
@@ -1,11 +1,11 @@
1
- == osx/plist
1
+ == osx-plist
2
2
 
3
3
  * http://github.com/kballard/osx-plist
4
4
  * by Kevin Ballard
5
5
 
6
6
  == DESCRIPTION:
7
7
 
8
- osx/plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X.
8
+ osx-plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X.
9
9
 
10
10
  == REQUIREMENTS:
11
11
 
@@ -18,7 +18,7 @@ osx/plist is a Ruby library for manipulating Property Lists natively using the b
18
18
 
19
19
  == SOURCE:
20
20
 
21
- osx/plist's git repo is available on GitHub, which can be browsed at:
21
+ osx-plist's git repo is available on GitHub, which can be browsed at:
22
22
 
23
23
  http://github.com/kballard/osx-plist
24
24
 
data/Rakefile CHANGED
@@ -3,7 +3,14 @@ require 'hoe'
3
3
 
4
4
  Hoe.spec 'osx-plist' do
5
5
  developer("Kevin Ballard", "kevin@sb.org")
6
- self.version = "1.0.2"
6
+ self.version = "1.0.3"
7
7
  self.summary = "Property List manipulation for OS X"
8
8
  self.spec_extras = {:extensions => "ext/plist/extconf.rb"}
9
9
  end
10
+
11
+ # override Hoe's default :test task
12
+ Rake::Task["test"].clear
13
+ desc "Run the unit tests"
14
+ task :test do
15
+ ruby "test/test_plist.rb"
16
+ end
@@ -2,4 +2,4 @@
2
2
  require 'mkmf'
3
3
  $LDFLAGS += ' -framework CoreFoundation -undefined suppress -flat_namespace'
4
4
  $LIBRUBYARG_SHARED=""
5
- create_makefile("osx/plist")
5
+ create_makefile("osx/plist/ext/plist")
@@ -43,19 +43,6 @@
43
43
  *
44
44
  */
45
45
 
46
- /*
47
- * Document-class: PropertyList
48
- *
49
- * The PropertyList module provides a means of converting a
50
- * Ruby Object to a Property List.
51
- *
52
- * The various Objects that can be converted are the ones
53
- * with an equivalent in CoreFoundation. This includes: String,
54
- * Integer, Float, Boolean, Time, Hash, and Array.
55
- *
56
- * See also: String#blob?, String#blob=, and Object#to_plist
57
- */
58
-
59
46
  #include <ruby.h>
60
47
  #if HAVE_RUBY_ST_H
61
48
  #include <ruby/st.h>
@@ -117,14 +104,13 @@ void raiseError(CFStringRef error) {
117
104
  }
118
105
 
119
106
  /* call-seq:
120
- * PropertyList.load(obj) -> object
121
- * PropertyList.load(obj, format) -> [object, format]
107
+ * load(obj, format = false)
122
108
  *
123
109
  * Loads a property list from an IO stream or a String and creates
124
110
  * an equivalent Object from it.
125
111
  *
126
- * If +format+ is provided, it returns one of
127
- * <tt>:xml1</tt>, <tt>:binary1</tt>, or <tt>:openstep</tt>.
112
+ * If +format+ is +true+, it returns an array of <tt>[object, format]</tt>
113
+ * where +format+ is one of <tt>:xml1</tt>, <tt>:binary1</tt>, or <tt>:openstep</tt>.
128
114
  */
129
115
  VALUE plist_load(int argc, VALUE *argv, VALUE self) {
130
116
  VALUE io, retFormat;
@@ -331,8 +317,7 @@ VALUE convertPlistToString(CFPropertyListRef plist, CFPropertyListFormat format)
331
317
  }
332
318
 
333
319
  /* call-seq:
334
- * PropertyList.dump(io, obj) -> Integer
335
- * PropertyList.dump(io, obj, format) -> Integer
320
+ * dump(io, obj, format = :xml1)
336
321
  *
337
322
  * Writes the property list representation of +obj+
338
323
  * to the IO stream (must be open for writing).
@@ -375,8 +360,7 @@ VALUE plist_dump(int argc, VALUE *argv, VALUE self) {
375
360
  }
376
361
 
377
362
  /* call-seq:
378
- * object.to_plist -> String
379
- * object.to_plist(format) -> String
363
+ * object.to_plist(format = :xml1)
380
364
  *
381
365
  * Converts the object to a property list representation
382
366
  * and returns it as a string.
@@ -534,7 +518,7 @@ CFDateRef convertTime(VALUE obj) {
534
518
  }
535
519
 
536
520
  /* call-seq:
537
- * str.blob? -> Boolean
521
+ * str.blob?
538
522
  *
539
523
  * Returns whether or not +str+ is a blob.
540
524
  */
@@ -548,7 +532,7 @@ VALUE str_blob(VALUE self) {
548
532
  }
549
533
 
550
534
  /* call-seq:
551
- * str.blob = bool -> bool
535
+ * str.blob = bool
552
536
  *
553
537
  * Sets the blob status of +str+.
554
538
  */
@@ -561,8 +545,25 @@ VALUE str_setBlob(VALUE self, VALUE b) {
561
545
  }
562
546
  }
563
547
 
564
- /* Bridge to CoreFoundation for reading/writing Property Lists.
565
- * Only works when CoreFoundation is available.
548
+ /*
549
+ * Document-module: OSX
550
+ */
551
+
552
+ /*
553
+ * Document-module: OSX::PropertyList
554
+ *
555
+ * The PropertyList module provides a means of converting a
556
+ * Ruby Object to a Property List.
557
+ *
558
+ * The various Objects that can be converted are the ones
559
+ * with an equivalent in CoreFoundation. This includes: String,
560
+ * Integer, Float, Boolean, Time, Hash, and Array.
561
+ *
562
+ * See also: String#blob?, String#blob=, and Object#to_plist
563
+ */
564
+
565
+ /*
566
+ * Document-class: OSX::PropertyListError
566
567
  */
567
568
  void Init_plist() {
568
569
  mOSX = rb_define_module("OSX");
@@ -575,6 +576,7 @@ void Init_plist() {
575
576
  ePropertyListError = rb_define_class_under(mOSX, "PropertyListError", rb_eStandardError);
576
577
  id_gm = rb_intern("gm");
577
578
  timeEpoch = rb_funcall(rb_cTime, id_gm, 1, INT2FIX(2001));
579
+ /* Time.gm(2001): The Cocoa epoch of January 1st, 2001*/
578
580
  rb_define_const(mPlist, "EPOCH", timeEpoch);
579
581
  id_plus = rb_intern("+");
580
582
  id_minus = rb_intern("-");
@@ -0,0 +1,18 @@
1
+ require "#{File.dirname(__FILE__)}/plist/ext/plist"
2
+
3
+ module OSX
4
+ module PropertyList
5
+ # Loads a property list from the file at +filepath+ using OSX::PropertyList.load.
6
+ def self.load_file(filepath, format = false)
7
+ File.open(filepath, "r") do |f|
8
+ OSX::PropertyList.load(f, format)
9
+ end
10
+ end
11
+ # Writes the property list representation of +obj+ to the file at +filepath+ using OSX::PropertyList.dump.
12
+ def self.dump_file(filepath, obj, format = :xml1)
13
+ File.open(filepath, "w") do |f|
14
+ OSX::PropertyList.dump(f, obj, format)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'osx/plist'
3
3
  require 'stringio'
4
+ require 'tempfile'
4
5
  require 'test/unit'
5
6
 
6
7
  class TestPlist < Test::Unit::TestCase
@@ -66,4 +67,22 @@ class TestPlist < Test::Unit::TestCase
66
67
  hash = setup_hash()
67
68
  assert_equal(hash, OSX::PropertyList.load(hash.to_plist))
68
69
  end
70
+
71
+ def test_load_file
72
+ plist, format = OSX::PropertyList.load_file("#{File.dirname(__FILE__)}/fixtures/xml_plist", true)
73
+
74
+ hash = setup_hash
75
+
76
+ assert_equal(hash, plist)
77
+ assert_equal(:xml1, format)
78
+ end
79
+
80
+ def test_dump_file
81
+ hash = setup_hash
82
+ Tempfile.open("test_plist") do |temp|
83
+ OSX::PropertyList.dump_file(temp.path, hash)
84
+ hash2 = OSX::PropertyList.load_file(temp.path)
85
+ assert_equal(hash, hash2)
86
+ end
87
+ end
69
88
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kballard-osx-plist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ballard
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-17 00:00:00 -07:00
12
+ date: 2009-09-21 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.3.3
24
24
  version:
25
- description: osx/plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X.
25
+ description: osx-plist is a Ruby library for manipulating Property Lists natively using the built-in support in OS X.
26
26
  email:
27
27
  - kevin@sb.org
28
28
  executables: []
@@ -40,10 +40,11 @@ files:
40
40
  - Rakefile
41
41
  - ext/plist/extconf.rb
42
42
  - ext/plist/plist.c
43
+ - lib/osx/plist.rb
43
44
  - test/fixtures/xml_plist
44
45
  - test/suite.rb
45
46
  - test/test_plist.rb
46
- has_rdoc: true
47
+ has_rdoc: false
47
48
  homepage: http://github.com/kballard/osx-plist
48
49
  licenses:
49
50
  post_install_message:
@@ -51,6 +52,7 @@ rdoc_options:
51
52
  - --main
52
53
  - README.txt
53
54
  require_paths:
55
+ - lib
54
56
  - ext
55
57
  required_ruby_version: !ruby/object:Gem::Requirement
56
58
  requirements:
@@ -69,7 +71,7 @@ requirements: []
69
71
  rubyforge_project: osx-plist
70
72
  rubygems_version: 1.3.5
71
73
  signing_key:
72
- specification_version: 2
74
+ specification_version: 3
73
75
  summary: Property List manipulation for OS X
74
76
  test_files:
75
77
  - test/test_plist.rb