Class: XForge::Project
- Inherits:
-
Object
- Object
- XForge::Project
- Defined in:
- lib/xforge/project.rb
Overview
A Project is an interface to a hosted project.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#unix_name ⇒ Object
readonly
Returns the value of attribute unix_name.
Instance Method Summary collapse
-
#group_id ⇒ Object
The group_id of this project.
- #group_id_uri(path, postfix = "") ⇒ Object
-
#home_page_uri ⇒ Object
The home page of this project.
-
#initialize(host, unix_name) ⇒ Project
constructor
A new instance of Project.
-
#login(user_name, password) ⇒ Object
Logs in and returns a Session.
- #project_uri ⇒ Object
-
#scm_web ⇒ Object
The scm browser of this project.
- #tracker ⇒ Object
Constructor Details
#initialize(host, unix_name) ⇒ Project
Returns a new instance of Project.
12 13 14 15 |
# File 'lib/xforge/project.rb', line 12 def initialize(host, unix_name) @host = host @unix_name = unix_name end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
10 11 12 |
# File 'lib/xforge/project.rb', line 10 def host @host end |
#unix_name ⇒ Object (readonly)
Returns the value of attribute unix_name.
10 11 12 |
# File 'lib/xforge/project.rb', line 10 def unix_name @unix_name end |
Instance Method Details
#group_id ⇒ Object
The group_id of this project
45 46 47 48 49 50 51 52 53 |
# File 'lib/xforge/project.rb', line 45 def group_id unless(@group_id) regexp = /stats\/[?&]group_id=(\d+)/ html = open(project_uri) { |data| data.read } @group_id = html[regexp, 1] raise "Couldn't get group_id" unless @group_id end @group_id end |
#group_id_uri(path, postfix = "") ⇒ Object
64 65 66 |
# File 'lib/xforge/project.rb', line 64 def group_id_uri(path, postfix="") "http://#{@host.name}/#{path}/?group_id=#{group_id}#{postfix}" end |
#home_page_uri ⇒ Object
The home page of this project
69 70 71 72 73 74 75 76 |
# File 'lib/xforge/project.rb', line 69 def home_page_uri unless(@home_page) html = open(project_uri) { |data| data.read } @home_page = html[@host.home_page_regexp, 1] raise "Couldn't get home_page" unless @home_page end @home_page end |
#login(user_name, password) ⇒ Object
Logs in and returns a Session
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 |
# File 'lib/xforge/project.rb', line 18 def login(user_name, password) http = Net::HTTP.new(@host.name, host.login_port) # Can't get this to work, so login doesn't work on SourceForge yet! # http://www.ruby-lang.org/ja/man/index.cgi?cmd=view;name=net%2Fhttps.rb if(host.login_port == 443) http.use_ssl = true http.ca_file = '/usr/share/ssl/cert.pem' http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.verify_depth = 5 end login_response = http.start do |http| data = [ "login=1", "form_loginname=#{user_name}", "form_pw=#{password}" ].join("&") http.post("/account/login.php", data) end = login_response["set-cookie"] raise "Login failed" unless Session.new(@host, self, ) end |
#project_uri ⇒ Object
60 61 62 |
# File 'lib/xforge/project.rb', line 60 def project_uri "http://#{@host.name}/projects/#{@unix_name}/" end |
#scm_web ⇒ Object
The scm browser of this project
56 57 58 |
# File 'lib/xforge/project.rb', line 56 def scm_web @scm_web ||= host.scm_web(self) end |
#tracker ⇒ Object
78 79 80 |
# File 'lib/xforge/project.rb', line 78 def tracker @tracker ||= @host.tracker(self) end |