Sha256: a387fe1caae317c763fb20a884119de265c58726362dc2b5eb7b17e07bbcdacf

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

#!/usr/bin/env ruby
# encoding: UTF-8

$:.unshift File.expand_path('../../lib', __FILE__)

require 'image_optim'

README_FILE = File.expand_path('../../README.markdown', __FILE__)
BEGIN_MARKER = '<!---<worker-options>-->'
END_MARKER = '<!---</worker-options>-->'

def worker_options
  io = StringIO.new

  ImageOptim::Worker.klasses.each_with_index do |klass, i|
    io.puts "### :#{klass.bin_sym} =>"
    if klass.option_definitions.empty?
      io.puts 'Worker has no options'
    else
      klass.option_definitions.each do |option_definition|
        io.puts "* `:#{option_definition.name}` — #{option_definition.description} *(defaults to `#{option_definition.default.inspect}`)*"
      end
    end
    io.puts
  end

  io.string
end

readme = File.read(README_FILE)

if readme.sub!(/#{Regexp.escape(BEGIN_MARKER)}.*#{Regexp.escape(END_MARKER)}/m, "#{BEGIN_MARKER}\n\n#{worker_options.strip}\n\n#{END_MARKER}")
  File.open(README_FILE, 'w') do |f|
    f.write readme
  end
else
  abort "Did not update worker options"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
image_optim-0.12.1 script/update_worker_options_in_readme