Class: Flowdock::Git
- Inherits:
-
Object
- Object
- Flowdock::Git
- Defined in:
- lib/flowdock/git.rb,
lib/flowdock/git/builder.rb
Defined Under Namespace
Classes: Builder, Commit, TokenError
Class Method Summary collapse
Instance Method Summary collapse
-
#background_post ⇒ Object
Create and post notification in background process.
-
#initialize(ref, from, to, options = {}) ⇒ Git
constructor
A new instance of Git.
-
#post ⇒ Object
Send git push notification to Flowdock.
- #repo ⇒ Object
Constructor Details
#initialize(ref, from, to, options = {}) ⇒ Git
Returns a new instance of Git.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/flowdock/git.rb', line 20 def initialize(ref, from, to, = {}) @ref = ref @from = from @to = to @options = @token = [:token] || config["flowdock.token"] || raise(TokenError.new("Flowdock API token not found")) @commit_url = [:commit_url] || config["flowdock.commit-url-pattern"] || nil @diff_url = [:diff_url] || config["flowdock.diff-url-pattern"] || nil @repo_url = [:repo_url] || config["flowdock.repository-url"] || nil @repo_name = [:repo_name] || config["flowdock.repository-name"] || nil @permanent_refs = [:permanent_refs] || (config["flowdock.permanent-references"] || "refs/heads/master") .split(",") .map(&:strip) .map {|exp| Regexp.new(exp) } end |
Class Method Details
Instance Method Details
#background_post ⇒ Object
Create and post notification in background process. Avoid blocking the push notification.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/flowdock/git.rb', line 45 def background_post pid = Process.fork if pid.nil? Grit::Git.with_timeout(600) do post end else Process.detach(pid) # Parent end end |
#post ⇒ Object
Send git push notification to Flowdock
38 39 40 41 42 |
# File 'lib/flowdock/git.rb', line 38 def post .each do || Flowdock::Client.new(flow_token: @token).post_to_thread() end end |
#repo ⇒ Object
56 57 58 |
# File 'lib/flowdock/git.rb', line 56 def repo @repo ||= Grit::Repo.new(@options[:repo] || Dir.pwd) end |