Class: BP::Github

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

Constant Summary collapse

HOOKS =
{
  'campfire' => {
    :events => %w{push issues issue_comment commit_comment pull_request watch fork fork_apply},
    :config => {
      :subdomain => 'fingertips', :room => 'Brighter Planet',
      :token => CAMPFIRE_TOKEN, :play_sound => 1,
    }
  },
#      'travis_ci' => {
#        :events => %w{push},
#        :config => {
#          :domain => 'travis-ci.org',
#          :token => TRAVIS_CI_TOKEN
#        }
#      }
}

Instance Method Summary collapse

Instance Method Details

#configure_hooks(repo_name = nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bp/github.rb', line 37

def configure_hooks(repo_name = nil)
   = options[:account] || 'brighterplanet'
  repo_name ||= BP.github_repo_name
  say "Configuring hooks for #{}/#{repo_name}"

  HOOKS.each do |hook_name, hook_data|
    config = hook_data[:config]
    config.merge!(:user => ) if hook_name == 'travis_ci'
    puts "Creating #{hook_name} hook"
    github.repos.hooks.create , repo_name,
      :name => hook_name, :active => true,
      :events => hook_data[:events],
      :config => config
  end
  say 'Done!'
end

#create_repo(repo) ⇒ Object



28
29
30
31
32
33
# File 'lib/bp/github.rb', line 28

def create_repo(repo)
   = options[:account] || 'brighterplanet'
  say "Creating repository #{repo} on GitHub"
  github.repos.create_repo :name => repo, :org => , :public => !options[:private]
  say 'Done!'
end

#reset_hooks(repo_name = nil) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/bp/github.rb', line 56

def reset_hooks(repo_name = nil)
   = options[:account] || 'brighterplanet'
  repo_name ||= BP.github_repo_name
  say "Resetting hooks for #{}/#{repo_name}"

  HOOKS.each do |hook_name, hook_data|
    config = hook_data[:config]
    config.merge!(:user => ) if hook_name == 'travis_ci'
    github.repos.hooks.all(, repo_name).each do |hook|
      github.repos.hooks.delete , repo_name, hook['id']
    end
  end
  say 'Done!'
  configure_hooks repo_name
end