lib/hyde/utils.rb in hydeweb-0.0.4 vs lib/hyde/utils.rb in hydeweb-0.0.5
- old
+ new
@@ -8,18 +8,23 @@
haystack.inject(false) do |a, match|
a ||= same_file?(needle, match)
end
end
- def force_file_open(filepath)
+ def force_file_open(filepath, &blk)
require 'fileutils'
FileUtils.mkdir_p File.dirname(filepath)
- File.new filepath, 'w'
+
+ if block_given?
+ File.open filepath, 'w', &blk
+ else
+ File.new filepath, 'w'
+ end
end
# Returns all helper classes under the Hyde::Helpers module.
def get_helpers
- Hyde::Helpers.constants.inject([]) do |a, constant|
+ Hyde::Helpers.constants.inject([Hyde::Helpers]) do |a, constant|
mod = Hyde::Helpers.const_get(constant)
a << mod if mod.is_a? Module
a
end
end