rubocop-markdown_formatter 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 516b2809ec44509b1c700e09128c5a238b9b643d
4
+ data.tar.gz: 66d9ff086cfaa508a3b8b8e7aada54607466df87
5
+ SHA512:
6
+ metadata.gz: f9a8f8f5f78fe7f9670ddb5248c0557f8783c652d202df70a56e5c9f6852ab5405a769062afa5508e713b7a9548beab26b4bb11ef1f59db184b3d859d5a54f0f
7
+ data.tar.gz: 0761fa892d71d2c4ef05bba07f8dda4f78a177d6c16aaa67ab56dacb8da2d13933ddeb038e6cf669e7f0fd970d3c817c2b2df6a111d830a277ab97706fd6a2e5
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Martin Manelli
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # RuboCop Markdown Formatter (WIP)
2
+
3
+ A formatter for [RuboCop](https://github.com/bbatsov/rubocop) that spits [Markdown](http://commonmark.org/).
4
+ It requires RuboCop version 0.23.0 or above.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'rubocop-markdown_formatter'
11
+
12
+ And then execute:
13
+
14
+ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ gem install rubocop-markdown_formatter
19
+
20
+ ## Usage
21
+
22
+ rubocop --require rubocop/formatter/markdown_formatter --format RuboCop::Formatter::MarkdownFormatter
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rspec/core'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubocop/formatter/text_util'
4
+
5
+ module RuboCop
6
+ module Formatter
7
+ # This formatter outputs in Markdown format
8
+ # See: http://spec.commonmark.org/
9
+ class MarkdownFormatter < BaseFormatter
10
+ include PathUtil, TextUtil
11
+
12
+ def started(_target_files)
13
+ @report = {}
14
+ end
15
+
16
+ def file_finished(file, offenses)
17
+ @report[file] = offenses
18
+ end
19
+
20
+ def finished(inspected_files)
21
+ return if inspected_files.empty?
22
+ render_markdown(@report)
23
+ end
24
+
25
+ private
26
+
27
+ def render_markdown(report)
28
+ report.each do |file, offenses|
29
+ output.puts file_offenses(file, offenses)
30
+ offenses.each do |offense|
31
+ output.puts line_offense(offense)
32
+ output.puts markdown_code(offense)
33
+ end
34
+ output.puts '---'
35
+ output.puts
36
+ end
37
+ end
38
+
39
+ def file_offenses(file, offenses)
40
+ offenses_count = pluralize(offenses.count, 'offense', no_for_zero: true)
41
+
42
+ "### #{smart_path(file)} - #{offenses_count}"
43
+ end
44
+
45
+ def line_offense(offense)
46
+ severity = offense.severity.name.capitalize
47
+
48
+ # http://spec.commonmark.org/0.21/#backslash-escapes
49
+ message = offense.message.gsub(/\p{S}/u, '\\\1')
50
+
51
+ "#### Line ##{offense.line} - **#{severity}:** _#{message}_"
52
+ end
53
+
54
+ def markdown_code(offense)
55
+ source_line = offense.location.source_line
56
+ return if source_line.empty?
57
+
58
+ "```\n#{source_line}\n```"
59
+ end
60
+
61
+ def smart_path(path)
62
+ path.start_with?(Dir.pwd) ? relative_path(path) : path
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'rubocop-markdown_formatter'
5
+ s.version = '0.0.1.pre'
6
+ s.summary = 'A RuboCop formatter that outputs in Markdown'
7
+ s.author = 'Martin Manelli'
8
+ s.email = 'manelli.ml@gmail.com'
9
+ s.homepage = 'http://github.com/manelli/rubocop-markdown_formatter'
10
+ s.license = 'MIT'
11
+
12
+ s.files = %w(
13
+ lib/rubocop/formatter/markdown_formatter.rb
14
+ spec/rubocop/formatter/markdown_formatter_spec.rb
15
+ Rakefile
16
+ LICENSE
17
+ README.md
18
+ rubocop-markdown_formatter.gemspec
19
+ )
20
+
21
+ s.add_dependency 'rubocop', '>= 0.23.0'
22
+ s.add_development_dependency 'rake', '~> 10.1'
23
+ s.add_development_dependency 'rspec', '~> 3.2.0'
24
+
25
+ s.required_ruby_version = '>= 1.9.3'
26
+ end
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubocop'
4
+ require_relative '../../../lib/rubocop/formatter/markdown_formatter'
5
+
6
+ module RuboCop
7
+ module Formatter
8
+ describe MarkdownFormatter do
9
+ # TODO
10
+ skip
11
+ end
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-markdown_formatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Martin Manelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubocop
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.23.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.23.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 3.2.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.0
55
+ description:
56
+ email: manelli.ml@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - Rakefile
64
+ - lib/rubocop/formatter/markdown_formatter.rb
65
+ - rubocop-markdown_formatter.gemspec
66
+ - spec/rubocop/formatter/markdown_formatter_spec.rb
67
+ homepage: http://github.com/manelli/rubocop-markdown_formatter
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 1.9.3
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">"
83
+ - !ruby/object:Gem::Version
84
+ version: 1.3.1
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.6
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: A RuboCop formatter that outputs in Markdown
91
+ test_files: []