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

View File

@ -185,26 +185,9 @@ module Apache
self.instance_eval(&block) if env.include?(APACHE_ENV)
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
def blockify(tag_name, name, &block)
self + [ '', "<#{[ tag_name, blockify_name(name) ].compact * ' '}>" ]
self + [ '', "<#{[ tag_name, name.blockify ].compact * ' '}>" ]
@line_indent += 1
self.instance_eval(&block)
@line_indent -= 1

View File

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

View File

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