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 +4 -4
- data/README.md +2 -0
- data/lib/pronto.rb +3 -3
- data/lib/pronto/cli.rb +9 -2
- data/lib/pronto/formatter/github_formatter.rb +1 -1
- data/lib/pronto/formatter/json_formatter.rb +7 -6
- data/lib/pronto/formatter/text_formatter.rb +6 -1
- data/lib/pronto/message.rb +8 -3
- data/lib/pronto/rugged/diff/line.rb +5 -4
- data/lib/pronto/version.rb +1 -1
- metadata +4 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccb63635760620106d5ff1d436d22ca6b13848fc
|
4
|
+
data.tar.gz: c4a6efc7cba539d3834515f014dac0345822199b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
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}"
|
@@ -5,12 +5,13 @@ module Pronto
|
|
5
5
|
class JsonFormatter
|
6
6
|
def format(messages)
|
7
7
|
messages.map do |message|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
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
|
data/lib/pronto/message.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
34
|
-
|
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
|
data/lib/pronto/version.rb
CHANGED
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.
|
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-
|
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.
|
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:
|