Sha256: 3d26a47084cf7f11b62bdbf9155222190db3b35845f698c85d1a7bd2985fcf19

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

require 'optparse'
require 'fileutils'
require 'css_inliner'

opt = OptionParser.new
Version = CSSInliner::VERSION
options = {}

opt.on('-o', '--output=OUTPUTFILE', 'file name to output result HTML') {|v| options[:output] = v}
opt.on('-i [SUFFIX]', '--in-place', '--overwrite', 'inplace editing') do |v|
  options[:'in-place'] = true
  options[:suffix] = v
end
opt.on('-e ELEMENT', '--element', 'element name to extract as root') {|v| options[:element] = v}

opt.parse! ARGV
processed = CSSInliner.process File.read(ARGV[0]), File.dirname(ARGV[0]), options[:element]
if options[:'in-place']
  FileUtils.cp(ARGV[0], ARGV[0] + options[:suffix]) if options[:suffix]
  File.open(ARGV[0], 'w') {|f| f.write processed}
elsif options[:output]
  File.open(options[:output], 'w') {|f| f.write processed}
else
  $stdout.write processed
end

exit 0

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
css_inliner-0.1.1 bin/css-inliner
css_inliner-0.1.0 bin/css-inliner