summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Bleything <ben@bleything.net>2006-09-21 04:09:29 +0000
committerBen Bleything <ben@bleything.net>2006-09-21 04:09:29 +0000
commitca31d928391c0225fd496dab76259f4d71476ba7 (patch)
tree45c2ffb5165b1956b163332714083bc1f6e6bd7c
parent3156c20b98812a80cda2e0a5365fcb241f1d67df (diff)
downloadplist-ca31d928391c0225fd496dab76259f4d71476ba7.tar.gz
move IndentedString inside Plist::Emit
-rw-r--r--CHANGELOG3
-rw-r--r--lib/plist/generator.rb65
2 files changed, 35 insertions, 33 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 9e9094e..002d782 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,8 @@
= plist - All-purpose Property List manipulation library
+2006-09-20 (r76):
+ * move IndentedString inside Plist::Emit and :nodoc: it
+
2006-09-19 (r73 - r75):
* Really fix the rakefile this time (apparently I deleted some code that I needed...)
* alter the fix_whitespace rake task to ignore the assets directory
diff --git a/lib/plist/generator.rb b/lib/plist/generator.rb
index 9a0a057..c37d5a0 100644
--- a/lib/plist/generator.rb
+++ b/lib/plist/generator.rb
@@ -162,48 +162,47 @@ module Plist
raise "Don't know about this data type... something must be wrong!"
end
end
- end
+ private
+ class IndentedString #:nodoc:
+ attr_accessor :indent_string
- private
- class IndentedString
- attr_accessor :indent_string
+ @@indent_level = 0
- @@indent_level = 0
+ def initialize(str = "\t")
+ @indent_string = str
+ @contents = ''
+ end
- def initialize(str = "\t")
- @indent_string = str
- @contents = ''
- end
+ def to_s
+ return @contents
+ end
- def to_s
- return @contents
- end
+ def raise_indent
+ @@indent_level += 1
+ end
- def raise_indent
- @@indent_level += 1
- end
+ def lower_indent
+ @@indent_level -= 1 if @@indent_level > 0
+ end
- def lower_indent
- @@indent_level -= 1 if @@indent_level > 0
- end
+ def <<(val)
+ if val.is_a? Array
+ val.each do |f|
+ self << f
+ end
+ else
+ # if it's already indented, don't bother indenting further
+ unless val =~ /\A#{@indent_string}/
+ indent = @indent_string * @@indent_level
- def <<(val)
- if val.is_a? Array
- val.each do |f|
- self << f
- end
- else
- # if it's already indented, don't bother indenting further
- unless val =~ /\A#{@indent_string}/
- indent = @indent_string * @@indent_level
+ @contents << val.gsub(/^/, indent)
+ else
+ @contents << val
+ end
- @contents << val.gsub(/^/, indent)
- else
- @contents << val
+ # it already has a newline, don't add another
+ @contents << "\n" unless val =~ /\n$/
end
-
- # it already has a newline, don't add another
- @contents << "\n" unless val =~ /\n$/
end
end
end