Sha256: 869f4a83cf94e8a627168f06ffd8d945c9e89be0ac408c3c54743f1a52e22530
Contents?: true
Size: 810 Bytes
Versions: 1
Compression:
Stored size: 810 Bytes
Contents
module JSBeauty class Command PATH = File.expand_path("../../../ext/js-beautifier/js-beautifier", __FILE__) def initialize(files, options = {}) @files = files @options = options if @files.empty? raise ArgumentError, "missing file" end end def run system("#{PATH} #{options_for_cmd} #{files_for_cmd}") end private def options_for_cmd str = "" @options.each do |opt, value| if value == true str << " --#{opt.to_s.gsub("_", "-")}" elsif value.nil? || value == false str << " " else str << " --#{opt.to_s.gsub("_", "-")} '#{value}'" end end str end def files_for_cmd @files.map do |f| "'#{f}'" end.join(' ') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jsbeauty-0.0.1 | lib/jsbeauty/command.rb |