Class: Pronto::RakeTask::TravisPullRequest

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/pronto/rake_task/travis_pull_request.rb

Overview

Provides a custom rake task to use with Travis.

require ‘rubocop/rake/travis_pull_request’ Pronto::Rake::TravisPullRequest.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &task_block) ⇒ TravisPullRequest

Returns a new instance of TravisPullRequest.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pronto/rake_task/travis_pull_request.rb', line 15

def initialize(*args, &task_block)
  setup_ivars(args)

  unless ::Rake.application.last_comment
    desc 'Run Pronto on Travis Pull Request'
  end

  task(name, *args) do |_, task_args|
    RakeFileUtils.send(:verbose, verbose) do
      if task_block
        task_block.call(*[self, task_args].slice(0, task_block.arity))
      end
      run_task(verbose)
    end
  end
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



12
13
14
# File 'lib/pronto/rake_task/travis_pull_request.rb', line 12

def name
  @name
end

#verboseObject

Returns the value of attribute verbose.



13
14
15
# File 'lib/pronto/rake_task/travis_pull_request.rb', line 13

def verbose
  @verbose
end

Instance Method Details

#run_task(verbose) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pronto/rake_task/travis_pull_request.rb', line 32

def run_task(verbose)
  return if pull_id.nil? || pull_id == 'false'

  client = Octokit::Client.new

  pull_request = client.pull_request(repo_slug, pull_id)
  formatter = ::Pronto::Formatter::GithubFormatter.new

  ::Pronto.gem_names.each { |gem_name| require "pronto/#{gem_name}" }
  ::Pronto.run(pull_request.base.sha, '.', formatter)
end