Class: Blend::CLI::Github

Inherits:
Thor
  • Object
show all
Defined in:
lib/blend/cli/github.rb

Instance Method Summary collapse

Instance Method Details

#add_hipchat(repo, room) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/blend/cli/github.rb', line 27

def add_hipchat( repo, room )
  client.add_hook( repo, "hipchat", { 
    auth_token: Blend::Client::get_token( :hipchat ), 
    notify: "1",
    restrict_to_branch: "",
    room: room } )
  Blend::Client::hipchat_client.post_message room, "#{repo} commit hook now added"
end

#collaborators(repo) ⇒ Object



64
65
66
67
68
# File 'lib/blend/cli/github.rb', line 64

def collaborators( repo )
  client.list_collaborators( repo ).each do |collaborator|
    puts collaborator['login']
  end
end

#hooks(repo) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/blend/cli/github.rb', line 5

def hooks( repo )
  puts
  printf "%-20s %-60s\n".blue.underline, 'Name', 'Config'
  client.list_hooks( repo ).each do |hook|
    printf "%-20s", hook.name
    cfg = hook.config.collect{|k,v| [k,v]}
    if hook.config.count > 0
      cfg.each_with_index do |(k,v),i|
        if i>0
          printf "%-20s %-20s: %-20s\n", '', k, v.inspect
        else
          printf " %-20s: %-20s\n", k, v.inspect
        end
      end
    else
      puts "\n"
    end
    puts
  end
end

#repo_create(team, name) ⇒ Object



57
58
59
60
# File 'lib/blend/cli/github.rb', line 57

def repo_create( team, name )
  client.repo_create( team, name )
  team( team )
end

#repo_search(name) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/blend/cli/github.rb', line 47

def repo_search( name )
  puts
  printf "%-50s %-40s\n".blue.underline, 'Name', 'Description'
  client.list_repos(name).each do |repo|
    printf "%-50s %-40s\n", repo['full_name'], repo['description']
  end
  puts
end

#reposObject



37
38
39
40
41
42
43
44
# File 'lib/blend/cli/github.rb', line 37

def repos
  puts
  printf "%-50s %-40s\n".blue.underline, 'Name', 'Description'
  client.list_repos.each do |repo|
    printf "%-50s %-40s\n", repo['full_name'], repo['description']
  end
  puts
end

#team(team) ⇒ Object



88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/blend/cli/github.rb', line 88

def team( team )  
  puts
  printf "%-40s %-40s\n".blue.underline, 'Repo name', 'Description'
  client.list_team_repos( team ).each do |repo|
    printf "%-40s %s\n", repo['full_name'], repo['description']
  end
  puts
  printf "%-30s\n".blue.underline, 'Github users'
  client.list_team_members( team ).each do |user|
    printf "%s\n", user['login']
  end
  puts
end

#team_add(team, user) ⇒ Object



109
110
111
112
# File 'lib/blend/cli/github.rb', line 109

def team_add( team, user )
  client.add_team_member( team, user )
  team( team )
end

#team_create(team) ⇒ Object



103
104
105
106
# File 'lib/blend/cli/github.rb', line 103

def team_create( team )
  client.create_team( team )
  team( team )
end

#team_repo_add(team, repo) ⇒ Object



121
122
123
124
# File 'lib/blend/cli/github.rb', line 121

def team_repo_add( team, repo )
  client.add_team_repo( team, repo )
  team( team )
end

#team_repo_rm(team, repo) ⇒ Object



127
128
129
130
# File 'lib/blend/cli/github.rb', line 127

def team_repo_rm( team, repo )
  client.remove_team_repo( team, repo )
  team( team )
end

#team_repos(team) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/blend/cli/github.rb', line 78

def team_repos( team )
  puts
  printf "%-40s %-40s\n".blue.underline, 'Name', 'Description'
  client.list_team_repos( team ).each do |repo|
    printf "%-40s %-40s\n", repo['full_name'], repo['description']
  end
  puts
end

#team_rm(team, user) ⇒ Object



115
116
117
118
# File 'lib/blend/cli/github.rb', line 115

def team_rm( team, user)
  client.remove_team_member( team, user )
  team( team )
end

#teamsObject



71
72
73
74
75
# File 'lib/blend/cli/github.rb', line 71

def teams
  client.list_teams.each do |team|
    puts team.name
  end
end