pronto 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1fa95ec101ccf2570dbe2092aa71d0153f3128c
4
- data.tar.gz: 82de58f6378b124f8e12093f20ca43678bd999a4
3
+ metadata.gz: ccb63635760620106d5ff1d436d22ca6b13848fc
4
+ data.tar.gz: c4a6efc7cba539d3834515f014dac0345822199b
5
5
  SHA512:
6
- metadata.gz: a5fe03a1de231b2188dae91205b74a1912dd68c1fc849a8145039af8ca920fb0e190315ead426a25c3f0a384f470f84b671edc933d1a18b9bf94b319a6b19b8e
7
- data.tar.gz: a5792d5886aa4ad19361d20075ae3d47334d1590fc89b089a1a3788c5823c4c87e9bb27e46e4f06c3869b5da8304389cda8b960925086ca542088c01b9985674
6
+ metadata.gz: 0b938196c2df754b0a3f193047a54a8f36f016c6759e2ba3434fff04baf7292410d18bc1cd24ffdb48fd2dfedb688887679a6fdd68fc49b6fdb1aab9b24a4dc1
7
+ data.tar.gz: 5883eb8f88031f6568dc086ccbe30064f8a8768a4097386f73031765a2ae1ba1193429daa14d8b5e4e1c11cf9b29b8a96cf39920ac3947c5ef915a62d8ed0ca3
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/mmozuras/pronto.png)](https://codeclimate.com/github/mmozuras/pronto)
4
4
  [![Build Status](https://secure.travis-ci.org/mmozuras/pronto.png)](http://travis-ci.org/mmozuras/pronto)
5
+ [![Gem Version](https://badge.fury.io/rb/pronto.png)](http://badge.fury.io/rb/pronto)
5
6
  [![Dependency Status](https://gemnasium.com/mmozuras/pronto.png)](https://gemnasium.com/mmozuras/pronto)
6
7
 
7
8
  ## Usage
@@ -53,3 +54,4 @@ Currently available runners:
53
54
  * [pronto-rubocop](https://github.com/mmozuras/pronto-rubocop)
54
55
  * [pronto-flay](https://github.com/mmozuras/pronto-flay)
55
56
  * [pronto-brakeman](https://github.com/mmozuras/pronto-brakeman)
57
+ * [pronto-rails_best_practices](https://github.com/mmozuras/pronto-rails_best_practices)
data/lib/pronto.rb CHANGED
@@ -20,7 +20,7 @@ require 'pronto/formatter/formatter'
20
20
  module Pronto
21
21
  def self.run(commit = 'master', repo_path = '.', formatter = nil)
22
22
  patches = diff(repo_path, commit)
23
- result = run_all_runners(patches)
23
+ result = run_all_runners(patches, commit)
24
24
 
25
25
  formatter ||= default_formatter
26
26
  formatter.format(result)
@@ -50,9 +50,9 @@ module Pronto
50
50
  repo.diff(merge_base, repo.head.target)
51
51
  end
52
52
 
53
- def self.run_all_runners(patches)
53
+ def self.run_all_runners(patches, commit)
54
54
  Runner.runners.map do |runner|
55
- runner.new.run(patches)
55
+ runner.new.run(patches, commit)
56
56
  end.flatten.compact
57
57
  end
58
58
 
data/lib/pronto/cli.rb CHANGED
@@ -5,7 +5,14 @@ module Pronto
5
5
  require 'pronto'
6
6
  require 'pronto/version'
7
7
 
8
- desc 'exec', 'Run Pronto'
8
+ class << self
9
+ def is_thor_reserved_word?(word, type)
10
+ return false if word == 'run'
11
+ super
12
+ end
13
+ end
14
+
15
+ desc 'run', 'Run Pronto'
9
16
 
10
17
  method_option :commit,
11
18
  type: :string,
@@ -25,7 +32,7 @@ module Pronto
25
32
  aliases: '-f',
26
33
  banner: "Pick output formatter. Available: #{::Pronto::Formatter.names.join(', ')}"
27
34
 
28
- def exec
35
+ def run
29
36
  gem_names = options[:runner].any? ? options[:runner] : ::Pronto.gem_names
30
37
  gem_names.each do |gem_name|
31
38
  require "pronto/#{gem_name}"
@@ -6,7 +6,7 @@ module Pronto
6
6
  def format(messages)
7
7
  commit_messages = messages.map do |message|
8
8
  repo = github_slug(message)
9
- sha = message.line.commit_sha
9
+ sha = message.commit_sha
10
10
  position = message.line.commit_line.position
11
11
  path = message.path
12
12
  body = message.msg
@@ -5,12 +5,13 @@ module Pronto
5
5
  class JsonFormatter
6
6
  def format(messages)
7
7
  messages.map do |message|
8
- {
9
- path: message.path,
10
- line: message.line.new_lineno,
11
- level: message.level[0].upcase,
12
- message: message.msg
13
- }
8
+ lineno = message.line.new_lineno if message.line
9
+
10
+ result = { level: message.level[0].upcase, message: message.msg }
11
+ result[:path] = message.path if message.path
12
+ result[:line] = lineno if lineno
13
+ result[:commit_sha] = message.commit_sha if message.commit_sha
14
+ result
14
15
  end.to_json
15
16
  end
16
17
  end
@@ -5,7 +5,12 @@ module Pronto
5
5
  messages.map do |message|
6
6
  level = message.level[0].upcase
7
7
  line = message.line
8
- "#{message.path}:#{line.new_lineno} #{level}: #{message.msg}"
8
+ lineno = line.new_lineno if line
9
+ path = message.path
10
+ commit_sha = message.commit_sha[0..6] if message.commit_sha
11
+
12
+ location = (path.nil? && lineno.nil?) ? commit_sha : "#{path}:#{lineno}"
13
+ "#{location} #{level}: #{message.msg}"
9
14
  end
10
15
  end
11
16
  end
@@ -1,15 +1,20 @@
1
1
  module Pronto
2
2
  class Message
3
- attr_reader :path, :line, :level, :msg
3
+ attr_reader :path, :line, :level, :msg, :commit_sha
4
4
 
5
5
  LEVELS = [:info, :warning, :error, :fatal]
6
6
 
7
- def initialize(path, line, level, msg)
7
+ def initialize(path, line, level, msg, commit_sha = nil)
8
8
  unless LEVELS.include?(level)
9
9
  raise ::ArgumentError, "level should be set to one of #{LEVELS}"
10
10
  end
11
11
 
12
- @path, @line, @level, @msg = path, line, level, msg
12
+ @path = path
13
+ @line = line
14
+ @level = level
15
+ @msg = msg
16
+ @commit_sha = commit_sha
17
+ @commit_sha ||= line.commit_sha if line
13
18
  end
14
19
 
15
20
  def repo
@@ -26,13 +26,14 @@ module Rugged
26
26
 
27
27
  def commit_line
28
28
  @commit_line ||= begin
29
- commit_patch = commit.show.patches.find do |p|
29
+ diff = commit.show
30
+ patches = diff ? diff.patches : []
31
+ commit_patch = patches.find do |p|
30
32
  patch.new_file_full_path == p.new_file_full_path
31
33
  end
32
34
 
33
- result = commit_patch.lines.find do |l|
34
- blameline.lineno == l.new_lineno
35
- end
35
+ lines = commit_patch ? commit_patch.lines : []
36
+ result = lines.find { |l| blameline.lineno == l.new_lineno }
36
37
 
37
38
  result || self # no commit_line means that it was just added
38
39
  end
@@ -1,3 +1,3 @@
1
1
  module Pronto
2
- VERSION = '0.1.7'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindaugas Mozūras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-08 00:00:00.000000000 Z
11
+ date: 2013-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged
@@ -94,34 +94,6 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: 2.14.0
97
- - !ruby/object:Gem::Dependency
98
- name: pronto-rubocop
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ~>
102
- - !ruby/object:Gem::Version
103
- version: 0.1.0
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ~>
109
- - !ruby/object:Gem::Version
110
- version: 0.1.0
111
- - !ruby/object:Gem::Dependency
112
- name: pronto-flay
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: 0.1.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ~>
123
- - !ruby/object:Gem::Version
124
- version: 0.1.0
125
97
  description:
126
98
  email: mindaugas.mozuras@gmail.com
127
99
  executables:
@@ -171,8 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
143
  version: 1.3.6
172
144
  requirements: []
173
145
  rubyforge_project:
174
- rubygems_version: 2.0.6
146
+ rubygems_version: 2.0.7
175
147
  signing_key:
176
148
  specification_version: 4
177
149
  summary: Pronto runs analysis quickly by checking only the introduced changes
178
150
  test_files: []
151
+ has_rdoc: