Class: MetaProject::Project::XForge::XForgeBase
- Defined in:
- lib/meta_project/project/xforge/xforge_base.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#group_id ⇒ Object
The group_id of this project.
- #group_id_uri(path, postfix = "") ⇒ Object
-
#home_page ⇒ Object
The home page of this project.
-
#initialize(host, unix_name, cvs_mod) ⇒ XForgeBase
constructor
A new instance of XForgeBase.
-
#login(user_name, password) ⇒ Object
Logs in and returns a Session.
- #project_uri ⇒ Object
- #to_yaml_properties ⇒ Object
Constructor Details
#initialize(host, unix_name, cvs_mod) ⇒ XForgeBase
Returns a new instance of XForgeBase.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 10 def initialize(host, unix_name, cvs_mod) @host = host @unix_name = unix_name @tracker = tracker_class.new(group_id_uri("tracker"), self) unless(cvs_mod.nil?) @scm = create_cvs(unix_name, cvs_mod) @scm_web = create_view_cvs(unix_name, cvs_mod) end end |
Instance Method Details
#group_id ⇒ Object
The group_id of this project
45 46 47 48 49 50 51 52 53 |
# File 'lib/meta_project/project/xforge/xforge_base.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
59 60 61 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 59 def group_id_uri(path, postfix="") "http://#{@host}/#{path}/?group_id=#{group_id}#{postfix}" end |
#home_page ⇒ Object
The home page of this project
64 65 66 67 68 69 70 71 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 64 def home_page unless(@home_page) html = open(project_uri) { |data| data.read } @home_page = html[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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 27 def login(user_name, password) http = Net::HTTP.new(@host, 80) 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
55 56 57 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 55 def project_uri "http://#{@host}/projects/#{@unix_name}/" end |
#to_yaml_properties ⇒ Object
22 23 24 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 22 def to_yaml_properties ["@host", "@unix_name"] end |