more reek work, shifting things arond

This commit is contained in:
John Bintz 2010-05-18 13:20:49 -04:00
parent f383d35a80
commit 55c44f079c
4 changed files with 18 additions and 24 deletions

View File

@ -34,6 +34,8 @@ class String
def quoteize def quoteize
%{"#{self}"} %{"#{self}"}
end end
alias :blockify :quoteize
end end
# Ruby symbols # Ruby symbols
@ -48,12 +50,18 @@ class Symbol
end end
def quoteize def quoteize
to_s.gsub('_', ' ') self.to_s.gsub('_', ' ')
end
def blockify
self.to_s
end end
end end
class Fixnum # Ruby everything
def quoteize; to_s; end class Object
alias :quoteize :to_s
alias :blockify :to_s
end end
# Ruby arrays # Ruby arrays
@ -71,5 +79,9 @@ class Array
self.collect!(&:quoteize) self.collect!(&:quoteize)
end end
def blockify
self.quoteize * " "
end
alias :commentize :to_a alias :commentize :to_a
end end

View File

@ -185,26 +185,9 @@ module Apache
self.instance_eval(&block) if env.include?(APACHE_ENV) self.instance_eval(&block) if env.include?(APACHE_ENV)
end end
# Blockify the second parameter of a block
#
# The name is processed differently based on input object type:
# * String - the name is quoteized
# * Array - all of the array members are quoteized
# * Symbol - the name is to_s
def blockify_name(name)
case name
when String
name.quoteize.first
when Array
name.quoteize * " "
when Symbol
name.to_s
end
end
# Handle the blockification of a provided block # Handle the blockification of a provided block
def blockify(tag_name, name, &block) def blockify(tag_name, name, &block)
self + [ '', "<#{[ tag_name, blockify_name(name) ].compact * ' '}>" ] self + [ '', "<#{[ tag_name, name.blockify ].compact * ' '}>" ]
@line_indent += 1 @line_indent += 1
self.instance_eval(&block) self.instance_eval(&block)
@line_indent -= 1 @line_indent -= 1

View File

@ -1,8 +1,7 @@
module Apache module Apache
module SSL module SSL
def enable_ssl_engine(options = {}) def enable_ssl_engine(options = {})
self << "" self + [ '', "SSLEngine on" ]
self << "SSLEngine on"
options.each do |key, value| options.each do |key, value|
value = quoteize(value).first value = quoteize(value).first
case key case key

View File

@ -57,7 +57,7 @@ describe Apache::Config, "builds configurations" do
[ :part, 'part' ], [ :part, 'part' ],
[ [ 'part', 'part2' ], '"part" "part2"' ] [ [ 'part', 'part2' ], '"part" "part2"' ]
].each do |name, attribute| ].each do |name, attribute|
apache.blockify_name(name).should == attribute name.blockify.should == attribute
end end
end end