Class: Rummage::Github::Network

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rummage.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ Network

Parsing input string



14
15
16
# File 'lib/rummage.rb', line 14

def initialize uri
  @user, @repo = URI.parse(uri).path.split('/').delete_if(&:empty?)
end

Instance Method Details

#drawObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rummage.rb', line 30

def draw
  meta    = network_meta
  users   = meta.users
  commits = network_data_chunk(meta.nethash)

  users.each do |user|
    user.heads.each do |head|
      head.commits = []

      commit = commits.select { |e| e.id == head.id }.first

      loop do
        head.commits.push commit
        # проверка на head'овость этого коммита в другом своем head'e
        if !commit.parents.empty? && commit.parents.first[2] == commit.space && !user.heads.map(&:id).include?(commit.parents.first[0])
          commit = commits.select { |e| e.id == commit.parents.first[0] }.first
        else
          break
        end
      end

    end
  end
  users
end

#network_data_chunk(nethash, options = {}) ⇒ Object

Get repo network data chunk github.com/rgrove/sanitize/network_data_chunk



26
27
28
# File 'lib/rummage.rb', line 26

def network_data_chunk nethash, options = {}
  get( urlize(@user, @repo, "network_data_chunk"), :query => options.merge(:nethash => nethash) ).commits
end

#network_metaObject



20
21
22
# File 'lib/rummage.rb', line 20

def network_meta
  get( urlize(@user, @repo, "network_meta") )
end