Class: Bananajour::Bonjour::RepositoryBrowser

Inherits:
Object
  • Object
show all
Defined in:
lib/bananajour/bonjour/repository_browser.rb

Instance Method Summary collapse

Constructor Details

#initializeRepositoryBrowser

Returns a new instance of RepositoryBrowser.



4
5
6
# File 'lib/bananajour/bonjour/repository_browser.rb', line 4

def initialize
  @browser = Browser.new('_git._tcp,_bananajour')
end

Instance Method Details

#other_repositoriesObject



23
24
25
# File 'lib/bananajour/bonjour/repository_browser.rb', line 23

def other_repositories
  repositories.reject {|r| Bananajour.repositories.any? {|my_rep| my_rep.name == r.name}}
end

#repositoriesObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bananajour/bonjour/repository_browser.rb', line 8

def repositories
  @browser.replies.map do |reply|
    Repository.new(
      reply.text_record["name"],
      reply.text_record["uri"],
      Person.new(
        reply.text_record["bjour-name"],
        reply.text_record["bjour-email"],
        reply.text_record["bjour-uri"],
        reply.text_record["bjour-gravatar"]
      )
    )
  end
end

#repositories_for(person) ⇒ Object



31
32
33
# File 'lib/bananajour/bonjour/repository_browser.rb', line 31

def repositories_for(person)
  repositories.select {|r| r.person == person}
end

#repositories_similar_to(repository) ⇒ Object



27
28
29
# File 'lib/bananajour/bonjour/repository_browser.rb', line 27

def repositories_similar_to(repository)
  repositories.select {|r| r.name == repository.name}
end