diff options
author | Ben Bleything <ben@bleything.net> | 2010-02-16 17:05:28 -0800 |
---|---|---|
committer | Ben Bleything <ben@bleything.net> | 2010-02-16 17:05:28 -0800 |
commit | d67ed75fbc6030032aceef2e52ee268ba159eedb (patch) | |
tree | 743e9eb3d52a4f5bb5c43c9b33d52011ea34c76f | |
parent | f51aa926cf381d9c1dde3c81c00ac00b7eb5c1ee (diff) | |
download | plist-d67ed75fbc6030032aceef2e52ee268ba159eedb.tar.gz |
excise a bunch of unnecessary @@ variables
-rw-r--r-- | lib/plist/generator.rb | 9 | ||||
-rw-r--r-- | test/test_data_elements.rb | 21 |
2 files changed, 16 insertions, 14 deletions
diff --git a/lib/plist/generator.rb b/lib/plist/generator.rb index fd9fd32..5197210 100644 --- a/lib/plist/generator.rb +++ b/lib/plist/generator.rb @@ -167,11 +167,10 @@ module Plist::Emit class IndentedString #:nodoc: attr_accessor :indent_string - @@indent_level = 0 - def initialize(str = "\t") @indent_string = str @contents = '' + @indent_level = 0 end def to_s @@ -179,11 +178,11 @@ module Plist::Emit end def raise_indent - @@indent_level += 1 + @indent_level += 1 end def lower_indent - @@indent_level -= 1 if @@indent_level > 0 + @indent_level -= 1 if @indent_level > 0 end def <<(val) @@ -194,7 +193,7 @@ module Plist::Emit else # if it's already indented, don't bother indenting further unless val =~ /\A#{@indent_string}/ - indent = @indent_string * @@indent_level + indent = @indent_string * @indent_level @contents << val.gsub(/^/, indent) else diff --git a/test/test_data_elements.rb b/test/test_data_elements.rb index ec0062b..584f9e5 100644 --- a/test/test_data_elements.rb +++ b/test/test_data_elements.rb @@ -13,7 +13,10 @@ class MarshalableObject end class TestDataElements < Test::Unit::TestCase - @@result = Plist::parse_xml('test/assets/test_data_elements.plist') + + def setup + @result = Plist.parse_xml( 'test/assets/test_data_elements.plist' ) + end def test_marshal expected = <<END @@ -28,9 +31,9 @@ END assert_equal expected.chomp, Plist::Emit.dump(mo, false).chomp - assert_instance_of MarshalableObject, @@result['marshal'] + assert_instance_of MarshalableObject, @result['marshal'] - assert_equal mo.foo, @@result['marshal'].foo + assert_equal mo.foo, @result['marshal'].foo end def test_generator_io_and_file @@ -52,14 +55,14 @@ END assert_equal expected, Plist::Emit.dump(io, false).chomp assert_equal expected, Plist::Emit.dump(f, false).chomp - assert_instance_of StringIO, @@result['io'] - assert_instance_of StringIO, @@result['file'] + assert_instance_of StringIO, @result['io'] + assert_instance_of StringIO, @result['file'] io.rewind f.rewind - assert_equal io.read, @@result['io'].read - assert_equal f.read, @@result['file'].read + assert_equal io.read, @result['io'].read + assert_equal f.read, @result['file'].read io.close f.close @@ -76,10 +79,10 @@ END assert_equal expected.chomp, Plist::Emit.dump(sio, false).chomp - assert_instance_of StringIO, @@result['stringio'] + assert_instance_of StringIO, @result['stringio'] sio.rewind - assert_equal sio.read, @@result['stringio'].read + assert_equal sio.read, @result['stringio'].read end # this functionality is credited to Mat Schaffer, |