lib/omnibus/templating.rb in omnibus-5.4.0 vs lib/omnibus/templating.rb in omnibus-5.5.0
- old
+ new
@@ -12,11 +12,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-require 'erb'
+require "erb"
module Omnibus
module Templating
def self.included(base)
# This module also requires logging
@@ -38,11 +38,11 @@
# the mode of the rendered file
# @option options [Hash] :variables (default: +{}+)
# the list of variables to pass to the template
#
def render_template(source, options = {})
- destination = options.delete(:destination) || source.chomp('.erb')
+ destination = options.delete(:destination) || source.chomp(".erb")
mode = options.delete(:mode) || 0644
variables = options.delete(:variables) || {}
log.info(log_key) { "Rendering `#{source}' to `#{destination}'" }
@@ -50,21 +50,21 @@
unless options.empty?
raise ArgumentError,
"Unknown option(s): #{options.keys.map(&:inspect).join(', ')}"
end
- template = ERB.new(File.read(source), nil, '-')
+ template = ERB.new(File.read(source), nil, "-")
struct =
if variables.empty?
Struct.new("Empty")
else
Struct.new(*variables.keys).new(*variables.values)
end
- result = template.result(struct.instance_eval { binding })
+ result = template.result(struct.instance_eval { binding })
- File.open(destination, 'w', mode) do |file|
+ File.open(destination, "w", mode) do |file|
file.write(result)
end
true
end