Class: MetaProject::Project::XForge::XForgeBase
- Defined in:
- lib/meta_project/project/xforge/xforge_base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#unix_name ⇒ Object
readonly
Returns the value of attribute unix_name.
Attributes inherited from Base
#name, #scm, #scm_web, #tracker
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
TODO: hash based constructor (big now).
-
#login(user_name, password) ⇒ Object
Logs in and returns a Session.
- #to_yaml_properties ⇒ Object
- #xforge_project_url ⇒ Object
Constructor Details
#initialize(host, unix_name, cvs_mod) ⇒ XForgeBase
TODO: hash based constructor (big now)
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 9 def initialize(host, unix_name, cvs_mod) @host = host @unix_name = unix_name @name = unix_name @cvs_mod = cvs_mod @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 Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 6 def host @host end |
#unix_name ⇒ Object (readonly)
Returns the value of attribute unix_name.
6 7 8 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 6 def unix_name @unix_name end |
Instance Method Details
#group_id ⇒ Object
The group_id of this project
50 51 52 53 54 55 56 57 58 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 50 def group_id unless(@group_id) html = better_open(xforge_project_url).read group_id_pattern = /project\/memberlist.php\?group_id=(\d+)/ @group_id = html[group_id_pattern, 1] raise "Couldn't get group_id from #{xforge_project_url}. I was looking for /#{group_id_pattern.source}/" unless @group_id end @group_id end |
#group_id_uri(path, postfix = "") ⇒ Object
64 65 66 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 64 def group_id_uri(path, postfix="") "http://#{@host}/#{path}/?group_id=#{group_id}#{postfix}" end |
#home_page ⇒ Object
The home page of this project
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 69 def home_page unless(@home_page) html = better_open(xforge_project_url).read @home_page = html[home_page_regexp, 1] unless @home_page STDERR.puts "WARNING: Couldn't get home_page from #{xforge_project_url}. I was looking for /#{home_page_regexp.source}/" STDERR.puts "Will use #{xforge_project_url} as home page instead." @home_page = xforge_project_url end end @home_page end |
#login(user_name, password) ⇒ Object
Logs in and returns a Session
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 28 def login(user_name, password) url = "/account/login.php" data = [ "return_to=", "login=Login", "form_loginname=#{user_name}", "form_pw=#{password}" ].join("&") http = Net::HTTP.new(@host, 80) login_response, body = http.start do |http| http.post(url, data, DEFAULT_POST_OPTIONS) end = login_response["set-cookie"] unless raise "Login failed.\nURL:#{url}\nParams:#{data}\nResponse:#{login_response.to_hash.inspect}" end Session.new(@host, self, ) end |
#to_yaml_properties ⇒ Object
23 24 25 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 23 def to_yaml_properties ["@host", "@unix_name"] end |
#xforge_project_url ⇒ Object
60 61 62 |
# File 'lib/meta_project/project/xforge/xforge_base.rb', line 60 def xforge_project_url "http://#{@host}/projects/#{@unix_name}/" end |