Sha256: 5dbb8d44083c36a9d6602b61198cee91cdacbc15f7997769507fb34f809164c1

Contents?: true

Size: 905 Bytes

Versions: 12

Compression:

Stored size: 905 Bytes

Contents

module PatternPark
  
  class Generate
    
    def self.new(args)
      begin
        if(args.size == 0)
          raise UsageError.new('[ERROR] Generate requires at least one argument')
        end
        name = args.shift
        path = Generate.command_path(name)
        require path
        cmd = eval(name.capitalize + "Command").new(args)
        Log.flush
        return cmd
      rescue UsageError => e
        puts e.to_s
      end
    end
    
    def self.command_path(name)
      file = name + "_command.rb"
      path = File.join(Sprout.project_path, 'script', 'command', file)
      if(File.exists?(path))
        return path
      end
      path = File.join(Sprout.cache, 'command', file)
      puts "trying: " + path
      if(File.exists?(path))
        return path
      end
      raise UsageError.new("[ERROR] Generate could not find command named '#{file}'")
    end
    
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
sprout-0.5.11 lib/generate.rb
sprout-0.3.35 lib/generate.rb
sprout-0.5.0 lib/generate.rb
sprout-0.5.10 lib/generate.rb
sprout-0.5.13 lib/generate.rb
sprout-0.3.36 lib/generate.rb
sprout-0.5.15 lib/generate.rb
sprout-0.5.23 lib/generate.rb
sprout-0.5.25 lib/generate.rb
sprout-0.5.9 lib/generate.rb
sprout-0.5.29 lib/generate.rb
sprout-0.5.19 lib/generate.rb