Class: Rpack::Parser
- Inherits:
-
Object
- Object
- Rpack::Parser
- Defined in:
- lib/parser.rb
Instance Attribute Summary collapse
-
#basedir ⇒ Object
Returns the value of attribute basedir.
-
#full_options ⇒ Object
readonly
Returns the value of attribute full_options.
-
#inflections ⇒ Object
Returns the value of attribute inflections.
-
#options ⇒ Object
Returns the value of attribute options.
-
#package ⇒ Object
Returns the value of attribute package.
-
#parser ⇒ Object
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Parser
constructor
A new instance of Parser.
- #unpack? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(argv) ⇒ Parser
Returns a new instance of Parser.
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 |
# File 'lib/parser.rb', line 8 def initialize(argv) @options = [] @parser = nil @valid = true @unpack = false @full_options = %w(controller model view helper mailer migration unit functional integration performance fixture route) begin OptionParser.new do |opts| @parser = opts opts. = "Usage: rpack <name> [options]" opts.on("-a","--all") { @options = @full_options } opts.on("-c","--controller") { @options << "controller" } opts.on("-m","--model") { @options << "model" } opts.on("-v","--view") { @options << "view" } opts.on("-h","--helper") { @options << "helper" } opts.on("-l","--mailer") { @options << "mailer" } opts.on("-g","--migration") { @options << "migration" } opts.on("-u","--unit") { @options << "unit" } opts.on("-f","--functional") { @options << "functional" } opts.on("-i","--integration") { @options << "integration"} opts.on("-o","--performance") { @options << "performance"} opts.on("-x","--fixture") { @options << "fixture" } opts.on("-r","--route") { @options << "route" } opts.on("-k","--unpack") do @unpack = true end opts.on("-t","--inflections FILE") do |file| @inflections = File.(file.strip) end opts.on("-d","--dir DIR") do |dir| @basedir = dir.strip end opts.on("-p","--package FILE") do |file| @package = File.(file.strip) end end.parse! argv @options = @full_options if @options.size<1 rescue => e puts "Error: #{e}" puts @parser @valid = false end end |
Instance Attribute Details
#basedir ⇒ Object
Returns the value of attribute basedir.
5 6 7 |
# File 'lib/parser.rb', line 5 def basedir @basedir end |
#full_options ⇒ Object (readonly)
Returns the value of attribute full_options.
6 7 8 |
# File 'lib/parser.rb', line 6 def @full_options end |
#inflections ⇒ Object
Returns the value of attribute inflections.
5 6 7 |
# File 'lib/parser.rb', line 5 def inflections @inflections end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'lib/parser.rb', line 5 def @options end |
#package ⇒ Object
Returns the value of attribute package.
5 6 7 |
# File 'lib/parser.rb', line 5 def package @package end |
#parser ⇒ Object
Returns the value of attribute parser.
5 6 7 |
# File 'lib/parser.rb', line 5 def parser @parser end |
Instance Method Details
#unpack? ⇒ Boolean
62 63 64 |
# File 'lib/parser.rb', line 62 def unpack? @unpack end |
#valid? ⇒ Boolean
58 59 60 |
# File 'lib/parser.rb', line 58 def valid? @valid end |