pronto-commentator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +8 -0
- data/Guardfile +14 -0
- data/LICENSE +21 -0
- data/README.md +41 -0
- data/Rakefile +7 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/pronto/commentator.rb +52 -0
- data/lib/pronto/commentator/version.rb +6 -0
- data/pronto-commentator.gemspec +32 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 565081e14422215f0f4f0f491575d51f726bf6aa
|
4
|
+
data.tar.gz: c7b7dc603202b7747d15def4bfac39a92454d7e1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93a8334864aee8f83fe9f56034bfb624081915007598e01a426428e7c2740dddb45507304b3cc3877b5921bdec8c38fd1d83b01ad5e262a44736daef417ae08e
|
7
|
+
data.tar.gz: c043749154e243595636c7d9b27a85318e8aee6c97b394d4f50b486378723b1a18aa1ecb5fe9fa6f09e1485ddd1437f46a11de25406197492ffc43df798af6b5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
3
|
+
require 'guard/rspec/dsl'
|
4
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
5
|
+
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Rainforest QA, Inc.
|
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,41 @@
|
|
1
|
+
# Pronto Commentator [![Circle CI](https://circleci.com/gh/rainforestapp/pronto-commentator.svg?style=svg)](https://circleci.com/gh/rainforestapp/pronto-commentator)
|
2
|
+
|
3
|
+
Pronto Commentator a very simple runner for
|
4
|
+
[Pronto](https://github.com/mozuras/pronto) that outputs arbitrary comments
|
5
|
+
based on filename matching. It's good for tagging specific people to review
|
6
|
+
specific kinds of changes (for instance, tagging your security team if
|
7
|
+
auth-related files change), and probably other things as well.
|
8
|
+
|
9
|
+
## Configuration
|
10
|
+
|
11
|
+
The main configuration file should be located at `.commentator/config.yml` in
|
12
|
+
your repo root. Pronto Commentator won't do anything unless the config file is
|
13
|
+
present. The configuration is pretty simple: it needs a root `files` key,
|
14
|
+
followed by associations of filename patterns to message file names. Here's an
|
15
|
+
example:
|
16
|
+
|
17
|
+
```yaml
|
18
|
+
files:
|
19
|
+
app/lib/auth*.rb:
|
20
|
+
ping_bob.md
|
21
|
+
"doc/chapters/[1-3].txt":
|
22
|
+
ping_real_writers.md
|
23
|
+
```
|
24
|
+
|
25
|
+
The file names should point to files in the `.commentator` directory. For
|
26
|
+
example, `.commentator/ping_bob.md` could look something like this:
|
27
|
+
|
28
|
+
```
|
29
|
+
@bob looks like someone's trying to change the auth logic again, better take a
|
30
|
+
look!
|
31
|
+
```
|
32
|
+
|
33
|
+
(Files don't have to be Markdown, but if you're using Github it's kinda nice).
|
34
|
+
|
35
|
+
File name matching uses
|
36
|
+
[Glob syntax](http://ruby-doc.org/core-2.3.0/Dir.html#method-c-glob).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at
|
41
|
+
https://github.com/rainforestapp/pronto-commentator.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pronto/commentator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'pronto'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Pronto
|
6
|
+
class Commentator < Runner
|
7
|
+
class ConfigError < StandardError; end
|
8
|
+
|
9
|
+
CONFIG_DIR = '.commentator'
|
10
|
+
|
11
|
+
def run
|
12
|
+
return [] unless config && file_patches
|
13
|
+
return ConfigError, "Commentator config does not contain the 'files' key" unless config['files'].is_a? Hash
|
14
|
+
|
15
|
+
file_patches.flat_map do |patch|
|
16
|
+
config.fetch('files').map do |pattern, msg_file|
|
17
|
+
if File.fnmatch? pattern, patch.delta.new_file[:path], File::FNM_PATHNAME
|
18
|
+
new_message patch, msg_file
|
19
|
+
end
|
20
|
+
end.compact
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def file_patches
|
27
|
+
@file_patches ||=
|
28
|
+
@patches.select { |patch| patch.additions > 0 }
|
29
|
+
.uniq(&:new_file_full_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def new_message(patch, msg_file)
|
33
|
+
msg = File.read File.join(CONFIG_DIR, msg_file)
|
34
|
+
|
35
|
+
Message.new(patch.delta.new_file[:path], patch.added_lines.first, :info, msg)
|
36
|
+
rescue Errno::ENOENT
|
37
|
+
raise ConfigError, "#{msg_file} does not exist in the commentator config dir."
|
38
|
+
end
|
39
|
+
|
40
|
+
def repo_path
|
41
|
+
file_patches.first.repo.path
|
42
|
+
end
|
43
|
+
|
44
|
+
def config
|
45
|
+
conf_file = File.join CONFIG_DIR, 'config.yml'
|
46
|
+
|
47
|
+
@config ||= YAML.load(File.read(conf_file))
|
48
|
+
rescue Errno::ENOENT
|
49
|
+
nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# coding: utf-8
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'pronto/commentator/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'pronto-commentator'
|
9
|
+
spec.version = Pronto::CommentatorVersion::VERSION
|
10
|
+
spec.authors = ['Emanuel Evans']
|
11
|
+
spec.email = ['emanuel@rainforestqa.com']
|
12
|
+
|
13
|
+
spec.summary = 'A simple code review tool for Pronto.'
|
14
|
+
spec.description = <<-EOS
|
15
|
+
A simple runner for Pronto that adds pre-defined comments based on which files have changed.
|
16
|
+
EOS
|
17
|
+
spec.homepage = 'https://github.com/rainforestapp/pronto-commentator'
|
18
|
+
spec.license = 'MIT'
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'pronto', '~> 0.6.0'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '>= 1.9'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec'
|
30
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.6.5'
|
31
|
+
spec.add_development_dependency 'awesome_print'
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-commentator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emanuel Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-04-12 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.6.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.6.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.6.5
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.6.5
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: awesome_print
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: " A simple runner for Pronto that adds pre-defined comments based
|
98
|
+
on which files have changed.\n"
|
99
|
+
email:
|
100
|
+
- emanuel@rainforestqa.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".rubocop.yml"
|
108
|
+
- ".travis.yml"
|
109
|
+
- Gemfile
|
110
|
+
- Guardfile
|
111
|
+
- LICENSE
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- bin/console
|
115
|
+
- bin/setup
|
116
|
+
- lib/pronto/commentator.rb
|
117
|
+
- lib/pronto/commentator/version.rb
|
118
|
+
- pronto-commentator.gemspec
|
119
|
+
homepage: https://github.com/rainforestapp/pronto-commentator
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 2.5.1
|
140
|
+
signing_key:
|
141
|
+
specification_version: 4
|
142
|
+
summary: A simple code review tool for Pronto.
|
143
|
+
test_files: []
|