require 'P4' class LocalhostProjects def initialize end def projects(user, authtoken) begin p4 = P4.new p4.port = 'localhost:1666' p4.user = user p4.password = authtoken p4.connect # puts p4.inspect # puts p4.run_info # puts p4.run_user('-o') projects = [] # now get all of the mainline streams under called main p4.run_streams('-F', 'Type=mainline', '//*/main').each { |streamDesc| projects << { 'id' => "#{streamDesc['Name']}", 'name' => streamDesc['Name'].gsub('~20',' '), 'url' => "http://localhost:3000/projects/#{streamDesc['Name']}/", 'server' => p4.port, 'P4CHARSET' => ENV['P4CHARSET'] || 'none', 'stream' => "#{streamDesc['Stream']}", } } return projects rescue P4Exception => e puts e.message raise e end end end