Class: Plasmoid::Generator::Options
- Inherits:
-
Hash
- Object
- Hash
- Plasmoid::Generator::Options
- Defined in:
- lib/plasmoid/generator/options.rb
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(args) ⇒ Options
constructor
A new instance of Options.
Constructor Details
#initialize(args) ⇒ Options
Returns a new instance of Options.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/plasmoid/generator/options.rb', line 8 def initialize(args) super() self[:generator] = Plasmoid::WebkitGenerator @argv = args.clone @parser = OptionParser.new do |o| o. = "Usage: #{File.basename($0)} [options] name\ne.g. #{File.basename($0)} weba" o.on('--directory [DIRECTORY]', 'specify the directory to generate into') do |directory| self[:directory] = directory end o.on("--ruby", "generate ruby plasmoid") do |o| self[:generator] = Plasmoid::RubyGenerator end o.on("--python", "generate python plasmoid") do |o| self[:generator] = Plasmoid::PythonGenerator end o.separator "Webkit Options:" o.on("--webkit", "generate webkit plasmoid") do |o| self[:generator] = Plasmoid::WebkitGenerator end o.on('--haml', 'enable haml') do |o| self[:use_haml] = true end o.on('--jquery', 'enable jquery') do |o| self[:use_jquery] = true end o.on('--jquery-ui', 'enable jquery ui') do |o| self[:use_jquery_ui] = true end o.separator "" o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary| self[:summary] = summary end o.on('--description [DESCRIPTION]', 'specify a description of the project') do |description| self[:description] = description end o.separator "" o.on('--user-name [USER_NAME]', "the user's name, ie that is credited in the LICENSE") do |user_name| self[:user_name] = user_name end o.on('--user-email [USER_EMAIL]', "the user's email, ie that is credited in the Gem specification") do |user_email| self[:user_email] = user_email end o.separator "" o.on('--homepage [HOMEPAGE]', "the homepage for your project") do |homepage| self[:homepage] = homepage end o.separator "" o.on_tail('-h', '--help', 'display this help and exit') do self[:show_help] = true end end begin @parser.parse!(args) self[:project_name] = args.shift rescue OptionParser::InvalidOption => e self[:invalid_argument] = e. end end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
6 7 8 |
# File 'lib/plasmoid/generator/options.rb', line 6 def argv @argv end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
6 7 8 |
# File 'lib/plasmoid/generator/options.rb', line 6 def parser @parser end |