pronto-docslint 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 904dd389bf8771794aa839c1db9fc4932d0282aeb41dc512f18b385f5af63486
4
+ data.tar.gz: ed7ee25312757f7bed05d9b7635137701198ed8bb72c99c98f16fbf6b86c07bf
5
+ SHA512:
6
+ metadata.gz: 75461c40447727e1033d7a7428b1a6c540f7238f86b66001c641260d1c42ec2063302530fd687c8d1b64b88b83d3dbb0f86c785d78ee24e2700407eb39c6ea01
7
+ data.tar.gz: 6e50a5c552f1c6d4de9fbf913b195fe19a8f467e68d3015ff4fe2d1001faf324eded08900ded7e44236fd4819a65b25bdb5f2c872c862fcaacdb60462bdf85a6
@@ -0,0 +1,29 @@
1
+ # Pronto Docslint
2
+
3
+ [![Build Status](https://travis-ci.org/samesystem/pronto-docslint.svg?branch=master)](https://travis-ci.org/samesystem/pronto-docslints)
4
+ [![codecov](https://codecov.io/gh/samesystem/pronto-docslint/branch/master/graph/badge.svg)](https://codecov.io/gh/samesystem/pronto-docslint)
5
+
6
+ Pronto runner for documentation checker
7
+
8
+ ## Example configuration:
9
+
10
+ ```yaml
11
+ # .pronto_docslint.yml
12
+ additions_treshold: 2
13
+ deletions_treshold: 2
14
+ watched_file_extensions:
15
+ - rb
16
+ - js
17
+ ```
18
+
19
+ ## Contributing
20
+
21
+ Bug reports and pull requests are welcome on GitHub at https://github.com/samesystem/pronto-docslint. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
22
+
23
+ ## License
24
+
25
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
26
+
27
+ ## Code of Conduct
28
+
29
+ Everyone interacting in the pronto-docslint project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/samesystem/pronto-docslint/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,71 @@
1
+ require 'pronto'
2
+ require 'shellwords'
3
+
4
+ module Pronto
5
+ class Docslint < Runner
6
+ CONFIG_FILE = '.pronto_docslint.yml'.freeze
7
+ CONFIG_KEYS = %w[watched_file_extensions additions_treshold deletions_treshold]
8
+
9
+ attr_reader :watched_file_extensions, :additions_treshold, :deletions_treshold
10
+
11
+ def run
12
+ return [] if no_patches? || documentation_exists?
13
+
14
+ prepare_config
15
+ meaningful_patches.map { |patch| new_message(patch) }.compact
16
+ end
17
+
18
+ private
19
+
20
+ def no_patches?
21
+ !@patches || @patches.count.zero?
22
+ end
23
+
24
+ def documentation_exists?
25
+ @patches.any? { |patch| patch.delta.new_file[:path].match?(/\.md$/) }
26
+ end
27
+
28
+ def meaningful_patches
29
+ extentions = /^app\/.*\.(#{watched_file_extensions.join('|')})$/
30
+ @patches
31
+ .select { |patch| !patch.delta.deleted? }
32
+ .select { |patch| patch.additions > additions_treshold || patch.deletions > deletions_treshold }
33
+ .select { |patch| patch.delta.new_file[:path].match?(extentions) }
34
+ end
35
+
36
+ def new_message(patch)
37
+ path = patch.delta.new_file[:path]
38
+ watched_extensions = watched_file_extensions.map { |ext| "`#{ext}`" }.join(',')
39
+ offence = "Changes on #{watched_extensions} files requires documentation changes.."
40
+ line = patch.added_lines.first || patch.deleted_lines.first
41
+ Message.new(path, line, :warning, offence, nil, self.class)
42
+ end
43
+
44
+ def prepare_config
45
+ read_config
46
+ fill_empty_settings_with_default_values
47
+ end
48
+
49
+ def read_config
50
+ config_file = File.join(git_repo_path, CONFIG_FILE)
51
+ return unless File.exist?(config_file)
52
+
53
+ config = YAML.load_file(config_file)
54
+
55
+ CONFIG_KEYS.each do |config_key|
56
+ next unless config[config_key]
57
+ instance_variable_set("@#{config_key}", config[config_key])
58
+ end
59
+ end
60
+
61
+ def fill_empty_settings_with_default_values
62
+ @watched_file_extensions ||= %w[js rb]
63
+ @additions_treshold ||= 1
64
+ @deletions_treshold ||= 1
65
+ end
66
+
67
+ def git_repo_path
68
+ @git_repo_path ||= Rugged::Repository.discover(File.expand_path(Dir.pwd)).workdir
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module DocslintVersion
3
+ VERSION = '0.0.7'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-docslint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Justinas Matulevicius
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-04-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.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.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.23.0
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '0.24'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.23.0
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.24'
47
+ description:
48
+ email: justinas@samesystem.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.md
53
+ files:
54
+ - README.md
55
+ - lib/pronto/docslint.rb
56
+ - lib/pronto/docslint/version.rb
57
+ homepage: https://github.com/samesystem/pronto-docslint
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.0.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.7.8
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Pronto runner for documentation existance.
81
+ test_files: []