class Dockerfiroonga::Command
Constants
- USAGE
Public Class Methods
new(arguments)
click to toggle source
# File lib/dockerfiroonga/command.rb, line 23 def initialize(arguments) @options = parse_options(arguments) @platform_name = arguments[0] begin @platform = Platform.new(@platform_name) rescue ArgumentError $stderr.puts("This platform is not supported yet: <#{@platform_name}>") $stderr.puts(USAGE) exit(false) end @_roonga = arguments[1] || "groonga" unless @platform.respond_to?("installation_#{@_roonga}") $stderr.puts("This Xroonga is not supported yet: <#{@_roonga}>") $stderr.puts(USAGE) exit(false) end @maintainer = @options[:maintainer] || "Masafumi Yokoyama <yokoyama@clear-code.com>" end
run(arguments)
click to toggle source
# File lib/dockerfiroonga/command.rb, line 19 def self.run(arguments) new(arguments).run end
Public Instance Methods
run()
click to toggle source
# File lib/dockerfiroonga/command.rb, line 46 def run puts <<-END_OF_FILE FROM #{@platform_name} MAINTAINER #{@maintainer} #{@platform.__send__("installation_#{@_roonga}")} CMD ["groonga", "--version"] END_OF_FILE end
Private Instance Methods
parse_options(arguments)
click to toggle source
# File lib/dockerfiroonga/command.rb, line 56 def parse_options(arguments) options = {} parser = OptionParser.new(<<-END_OF_BANNER) #{USAGE.chomp} OPTIONS: END_OF_BANNER parser.version = VERSION parser.on("-h", "--help", "Show usage") do |boolean| puts(parser.help) exit(true) end parser.on("--maintainer=NAME", "Set maintainer") do |name| options[:maintainer] = name end parser.parse!(arguments) if arguments.empty? puts(parser.help) exit(true) end options end