Class: MetaProject::Tracker::XForge::XForgeTracker::SubTracker

Inherits:
Object
  • Object
show all
Includes:
HTTP::Multipart
Defined in:
lib/meta_project/tracker/xforge/xforge_tracker.rb

Constant Summary collapse

OPEN =

Issue modification constants

1
CLOSED =
2
DELETED =
3

Constants included from HTTP::Multipart

HTTP::Multipart::BOUNDARY

Instance Method Summary collapse

Methods included from HTTP::Multipart

#post_data, #post_multipart

Constructor Details

#initialize(tracker, atid) ⇒ SubTracker

Returns a new instance of SubTracker.



46
47
48
49
50
51
52
# File 'lib/meta_project/tracker/xforge/xforge_tracker.rb', line 46

def initialize(tracker, atid)
  @tracker = tracker
  @atid = atid
  # FIXME: This will only show open items.
  @baseurl = "#{tracker.overview}&atid=#{atid}"
  @overview = "#{@baseurl}&func=browse"
end

Instance Method Details

#close(issue, user_name, password) ⇒ Object



91
92
93
# File 'lib/meta_project/tracker/xforge/xforge_tracker.rb', line 91

def close(issue, user_name, password)
  modify(issue, user_name, password, CLOSED)
end

#create(issue, user_name, password) ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/meta_project/tracker/xforge/xforge_tracker.rb', line 67

def create(issue, user_name, password)
  session = @tracker.project.(user_name, password)
  
  Net::HTTP.start(@tracker.project.host, 80) do |http|
    query_hash = {
      "func" => "postadd",
      "category_id" => "100", # seems to be standard for all trackers
      "artifact_group_id" => "100", # seems to be standard for all trackers
      "summary" => issue.summary,
      "details" => issue.detail,
      "user_email" => "",
    }

    target = "/news/submit.php" #TODO: use this?
    response = post_multipart(http, @baseurl, query_hash, session.request_headers)
    
    # the post brings us back to the overview page, where the new issue is the last one
    response.body.scan(/aid=([\d]+)/) do |a|
      issue.attributes[:identifier] = a[0]
    end
  end
  issue
end

#delete(issue, user_name, password) ⇒ Object



95
96
97
# File 'lib/meta_project/tracker/xforge/xforge_tracker.rb', line 95

def delete(issue, user_name, password)
  modify(issue, user_name, password, DELETE)
end

#issue(identifier) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/meta_project/tracker/xforge/xforge_tracker.rb', line 54

def issue(identifier)
  html = better_open(@overview).read

  issue_summary_pattern = @tracker.issue_summary_pattern(identifier)
  if(html =~ issue_summary_pattern)
    issue_url = @tracker.project.group_id_uri("tracker/index.php", "&atid=#{@atid}&func=detail&aid=#{identifier}")
    issue_summary = $1.strip
    return Issue.new(self, :identifier => identifier,:summary => issue_summary, :url => issue_url)
  else
    nil
  end
end