Class: Dev
- Inherits:
-
Object
- Object
- Dev
- Defined in:
- lib/dev.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
Returns the value of attribute commands.
-
#env ⇒ Object
Returns the value of attribute env.
-
#projects ⇒ Object
Returns the value of attribute projects.
Instance Method Summary collapse
- #execute(args) ⇒ Object
-
#initialize(env = nil) ⇒ Dev
constructor
A new instance of Dev.
- #usage ⇒ Object
Constructor Details
#initialize(env = nil) ⇒ Dev
Returns a new instance of Dev.
11 12 13 14 15 16 17 |
# File 'lib/dev.rb', line 11 def initialize env=nil @env=Environment.new(env) if !env.nil? && env.kind_of?(Hash) @env=Environment.new() if @env.nil? @projects=Projects.new(@env) @commands=Commands.new(@env) @output='' end |
Instance Attribute Details
#commands ⇒ Object
Returns the value of attribute commands.
9 10 11 |
# File 'lib/dev.rb', line 9 def commands @commands end |
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/dev.rb', line 9 def env @env end |
#projects ⇒ Object
Returns the value of attribute projects.
9 10 11 |
# File 'lib/dev.rb', line 9 def projects @projects end |
Instance Method Details
#execute(args) ⇒ Object
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 |
# File 'lib/dev.rb', line 19 def execute args args=args.split(' ') if(args.kind_of?(String)) # parse arguments that are of the form KEY=VALUE args.each{|arg| if(arg.include?('=')) words=arg.split('=') if(words.length==2) ENV[words[0]]=words[1] end end } if args.length == 0 return usage else subcommand=args[0] if args.length > 0 =Array.new =args[1,args.length-1] if args.length > 1 return projects.add() if subcommand=='add' return projects.clobber() if subcommand=='clobber' return projects.import() if subcommand=='import' return projects.list() if subcommand=='list' return projects.make() if subcommand=='make' return projects.info() if subcommand=='info' return projects.remove() if subcommand=='remove' return projects.work() if subcommand=='work' return projects.update() if subcommand=='update' @env.out "unknown command: '#{subcommand}'" 1 end end |
#usage ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dev.rb', line 54 def usage return 0 @env.out 'usage: dev <subcommand> [options]' @env.out '' @env.out 'available subcommands' @env.out ' help' @env.out ' list' @env.out ' make' @env.out ' info' @env.out ' work' @env.out '' @env.out "Type 'dev help <subcommand>' for help on a specific subcommand.'" 0 end |