Sha256: 70ced0cbca960b3497bcd19bd7ec252a87ca13d9fc3be53cf51fd64ebc5ee0ac
Contents?: true
Size: 827 Bytes
Versions: 11
Compression:
Stored size: 827 Bytes
Contents
# encoding: utf-8 class SimpleTemplater module ArgvParsingMixin def parse! self.inject(Hash.new) do |options, argument| case argument when /^--no-([^=]+)$/ # --no-git-repository options[$1.gsub("-", "_").to_sym] = false when /^--([^=]+)$/ # --git-repository options[$1.gsub("-", "_").to_sym] = true when /^--([^=]+)=([^,]+)$/ # --controller=post key, value = $1, $2 options[key.gsub("-", "_").to_sym] = value.dup when /^--([^=]+)=(.+)$/ # --controllers=posts,comments key, value = $1, $2 options[key.gsub("-", "_").to_sym] = value.split(",") else raise "Parsing failed on: #{argument}" end options end end end end ARGV.extend(SimpleTemplater::ArgvParsingMixin)
Version data entries
11 entries across 11 versions & 2 rubygems