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.
17 18 19 20 21 22 23 |
# File 'lib/dev.rb', line 17 def initialize(env = nil) @env = Environment.new(env) if !env.nil? && env.is_a?(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.
15 16 17 |
# File 'lib/dev.rb', line 15 def commands @commands end |
#env ⇒ Object
Returns the value of attribute env.
15 16 17 |
# File 'lib/dev.rb', line 15 def env @env end |
#projects ⇒ Object
Returns the value of attribute projects.
15 16 17 |
# File 'lib/dev.rb', line 15 def projects @projects end |
Instance Method Details
#execute(args) ⇒ Object
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/dev.rb', line 25 def execute(args) args = args.split(" ") if args.is_a?(String) # parse arguments that are of the form KEY=VALUE args.each do |arg| next unless arg.include?("=") words = arg.split("=") ENV[words[0]] = words[1] if words.length == 2 end if args.length.zero? usage else subcommand = args[0] if args.length.positive? = [] = 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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/dev.rb', line 58 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 |