Class: GithubIssueImporter::Launchpad

Inherits:
Object
  • Object
show all
Defined in:
lib/github-issue-importer/launchpad.rb

Instance Method Summary collapse

Constructor Details

#initializeLaunchpad

Returns a new instance of Launchpad.



7
8
9
# File 'lib/github-issue-importer/launchpad.rb', line 7

def initialize
  @owners = Hash.new
end

Instance Method Details

#get(url) ⇒ Object



59
60
61
# File 'lib/github-issue-importer/launchpad.rb', line 59

def get(url)
  JSON.parse open(url).read
end

#get_bug(id) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/github-issue-importer/launchpad.rb', line 26

def get_bug(id)
  if id.is_a? Hash
    bug_link = id['bug_link']
  else
    bug_link = "https://api.launchpad.net/1.0/bugs/#{id}"
  end
  get bug_link
end

#get_bug_comments(id) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/github-issue-importer/launchpad.rb', line 35

def get_bug_comments(id)
  if id.is_a? Hash
    bug_comments_link = id['messages_collection_link']
  else
    bug_comments_link = "https://api.launchpad.net/1.0/bugs/#{id}/comments"
  end
  comments = get bug_comments_link
  comments['entries']
end

#get_bug_entries(project) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/github-issue-importer/launchpad.rb', line 11

def get_bug_entries(project)
  entries = []

  url = "https://api.launchpad.net/1.0/#{project}?ws.op=searchTasks"
  loop do
    bugs = get url
    entries += bugs['entries']

    url = bugs['next_collection_link']
    break unless url
  end

  entries
end

#get_owner(id) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/github-issue-importer/launchpad.rb', line 45

def get_owner(id)
  if id.is_a? Hash
    owner_link = id['owner_link']
  else
    owner_link = "https://api.launchpad.net/1.0/~#{id}"
  end

  if @owners[owner_link].nil?
    @owners[owner_link] = get owner_link
  end

  @owners[owner_link]
end