Class: Flowdock::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/flowdock/git.rb,
lib/flowdock/git/builder.rb

Defined Under Namespace

Classes: Builder, Commit

Constant Summary collapse

TokenError =
Class.new(StandardError)
DEFAULT_PERMANENT_REFS =
[
  Regexp.new('refs/heads/master')
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ref, from, to, options = {}) ⇒ Git

Returns a new instance of Git.

Raises:


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/flowdock/git.rb', line 19

def initialize(ref, from, to, options = {})
  raise TokenError.new("Flowdock API token not found") unless options[:token]

  @ref = ref
  @from = from
  @to = to
  @options = options
  @token = options[:token]
  @commit_url = options[:commit_url]
  @diff_url = options[:diff_url]
  @repo_url = options[:repo_url]
  @repo_name = options[:repo_name]
  @permanent_refs = options.fetch(:permanent_refs, DEFAULT_PERMANENT_REFS)
end

Class Method Details

.post(ref, from, to, options = {}) ⇒ Object


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

def post(ref, from, to, options = {})
  Git.new(ref, from, to, options).post
end

Instance Method Details

#postObject

Send git push notification to Flowdock


35
36
37
38
39
# File 'lib/flowdock/git.rb', line 35

def post
  messages.each do |message|
    Flowdock::Client.new(flow_token: @token).post_to_thread(message)
  end
end

#repoObject


41
42
43
# File 'lib/flowdock/git.rb', line 41

def repo
  @options[:repo]
end