giteaucrat 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/MIT-LICENSE +20 -0
- data/README.md +2 -0
- data/config/giteaucrat.yml +2 -1
- data/lib/giteaucrat/author.rb +1 -1
- data/lib/giteaucrat/common.rb +1 -1
- data/lib/giteaucrat/file.rb +15 -66
- data/lib/giteaucrat/formatters/coffee_formatter.rb +22 -0
- data/lib/giteaucrat/formatters/formatter.rb +126 -0
- data/lib/giteaucrat/formatters/java_formatter.rb +37 -0
- data/lib/giteaucrat/formatters/python_formatter.rb +15 -0
- data/lib/giteaucrat/formatters/ruby_formatter.rb +58 -0
- data/lib/giteaucrat/formatters/sass_formatter.rb +25 -0
- data/lib/giteaucrat/formatters.rb +40 -0
- data/lib/giteaucrat/repo.rb +14 -3
- data/lib/giteaucrat/runner.rb +6 -1
- data/lib/giteaucrat/version.rb +2 -2
- data/lib/giteaucrat.rb +2 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDljY2ZhYWJmNTMxNmJiYzJhN2UwMGIyYzU0YmExYTY1Njc4MmQ0Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDQyZWVlN2RlMjg2ZjU0OTFjZTI3ZDIwMDYwODY2ZThhMDFjMTlmYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzU3MWI4YTkzMzE3MWYzYTY5NWFmNmEwMzhhYWIyZGYyMjBiNjYxYTU3ZDA5
|
10
|
+
NDkxNDI4YWUyMzZiZTZiNGJkZDYyNzM3NjQyN2Y2MTU5N2NhODAxOGVkODYx
|
11
|
+
ZDg2ZjM0Y2M2M2ZhMGEwNGE5NGFmNGM3YjA4Mjk1YzdlZjdjNDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2U1OGU3NzkxYzY2YWRkMWE4NTdiOTJiZTkxMjQ2Y2IyODU1NTVhZjcxZDRj
|
14
|
+
ZTI5ZjU2NmM0MTNlMDMyYzA1MjE4NjA3NGRmMWI0NGQ5OGIzMzdhMTMxMzQ2
|
15
|
+
YjhhOGVhMjkzZmQ1NWI1YTUyMjRhZTc4YWU2ZWJjNGM0N2Q3ZDc=
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
© Alexander Semyonov, 2013
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
data/config/giteaucrat.yml
CHANGED
data/lib/giteaucrat/author.rb
CHANGED
data/lib/giteaucrat/common.rb
CHANGED
data/lib/giteaucrat/file.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
################################################
|
4
|
-
# © Alexander Semyonov, 2013—2013
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
5
|
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
6
|
################################################
|
7
7
|
|
8
8
|
require 'giteaucrat'
|
9
9
|
require 'grit'
|
10
10
|
require 'core_ext/grit/blame'
|
11
|
+
require 'giteaucrat/formatters'
|
11
12
|
|
12
13
|
module Giteaucrat
|
13
14
|
class File
|
@@ -24,7 +25,7 @@ module Giteaucrat
|
|
24
25
|
blame = repo.git_repo.blame(name)
|
25
26
|
lines = blame.lines
|
26
27
|
commits = lines.map { |line| line.commit }.uniq.find_all do |commit|
|
27
|
-
!ignored_commit?(commit)
|
28
|
+
!repo.ignored_commit?(commit)
|
28
29
|
end
|
29
30
|
commits.inject(Set.new) do |authors, commit|
|
30
31
|
author = Author.find_by_git_person(commit.author)
|
@@ -34,78 +35,26 @@ module Giteaucrat
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
middle = Regexp.escape(middle)
|
41
|
-
last = Regexp.escape(last)
|
42
|
-
contents = ::File.read(name)
|
43
|
-
ruler = "(#{first}(#{middle})*#{last}\n)"
|
44
|
-
coding = "\\A(#{first}\s*.*coding:\s*utf-8\s*\n+)?"
|
45
|
-
header = /#{coding}#{ruler}(#{first}.*#{last}\n)*\2\n*/m
|
46
|
-
if repo.include_encoding?
|
47
|
-
contents.sub!(header, '')
|
48
|
-
contents.sub!(/#{coding}/, '')
|
49
|
-
contents = "#{copyright}\n\n#{contents}"
|
50
|
-
else
|
51
|
-
contents.sub!(/(#{coding})/, "\1#{copyright}\n\n")
|
38
|
+
def owner
|
39
|
+
@owner ||= begin
|
40
|
+
Author.find_by_git_person(repo.git_repo.log(name).last.author)
|
52
41
|
end
|
53
|
-
::File.write(name, contents)
|
54
42
|
end
|
55
43
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
lines << repo.copyright_label
|
60
|
-
|
61
|
-
if authors.size > 0
|
62
|
-
authors_label = (authors.size > 1) ? 'Authors: ' : 'Author: '
|
63
|
-
author_names = self.authors.map { |a| a.identifier }.sort
|
64
|
-
prepend = ' ' * authors_label.size
|
65
|
-
lines << "#{authors_label}#{author_names.shift}"
|
66
|
-
author_names.each do |author|
|
67
|
-
lines << "#{prepend}#{author}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
first, middle, last = self.comment
|
72
|
-
|
73
|
-
max_line_size = lines.max { |a, b| a.size <=> b.size }.size
|
74
|
-
max_line_size += 1 if max_line_size.odd?
|
75
|
-
|
76
|
-
width = first.size + 1 + max_line_size + 1 + last.size
|
77
|
-
ruler = "#{first}#{middle * ((width / middle.size - first.size - last.size))}#{last}"
|
78
|
-
lines = lines.map do |line|
|
79
|
-
blank = ' ' * (max_line_size - line.size) if line.size < max_line_size
|
80
|
-
"#{first} #{line}#{blank} #{last}"
|
81
|
-
end
|
44
|
+
def read_contents
|
45
|
+
::File.read(name)
|
46
|
+
end
|
82
47
|
|
83
|
-
|
84
|
-
|
85
|
-
if repo.include_encoding?
|
86
|
-
lines.unshift("#{first} coding: utf-8\n")
|
87
|
-
end
|
88
|
-
lines.join("\n")
|
89
|
-
end
|
48
|
+
def write_contents(contents)
|
49
|
+
::File.write(name, contents)
|
90
50
|
end
|
91
51
|
|
92
|
-
|
93
|
-
|
94
|
-
repo.ignored_commit?(commit)
|
52
|
+
def formatter
|
53
|
+
@formatter ||= Formatters.formatter_for(self)
|
95
54
|
end
|
96
55
|
|
97
|
-
|
98
|
-
|
99
|
-
case ::File.extname(name)
|
100
|
-
when '.rb', '.coffee', '.sass'
|
101
|
-
%w(# # #)
|
102
|
-
when '.js', '.css', '.scss'
|
103
|
-
%w(/* * */)
|
104
|
-
when '.erl'
|
105
|
-
%w(% % %)
|
106
|
-
else
|
107
|
-
raise 'Unknown file type'
|
108
|
-
end
|
56
|
+
def write_copyright!
|
57
|
+
formatter.write_copyright!
|
109
58
|
end
|
110
59
|
end
|
111
60
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters/ruby_formatter'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
class CoffeeFormatter < RubyFormatter
|
13
|
+
def include_encoding?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_copyright!
|
18
|
+
@contents = [format_copyright, contents].join("\n\n")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters'
|
9
|
+
require 'delegate'
|
10
|
+
|
11
|
+
module Giteaucrat
|
12
|
+
module Formatters
|
13
|
+
class Formatter < SimpleDelegator
|
14
|
+
# @return [String]
|
15
|
+
def format_copyright
|
16
|
+
first, _, last = comment_parts
|
17
|
+
lines = copyright_lines
|
18
|
+
|
19
|
+
max_line_size = lines.max { |a, b| a.size <=> b.size }.size
|
20
|
+
max_line_size += 1 if max_line_size.odd?
|
21
|
+
|
22
|
+
lines = lines.map do |line|
|
23
|
+
blank = ' ' * (max_line_size - line.size) if line.size < max_line_size
|
24
|
+
"#{line}#{blank}"
|
25
|
+
end
|
26
|
+
|
27
|
+
line_width = first.size + 1 + max_line_size + 1 + last.size
|
28
|
+
|
29
|
+
formatted = []
|
30
|
+
formatted << header_ruler(line_width)
|
31
|
+
formatted << lines.map { |line| format_line(line) }
|
32
|
+
formatted << footer_ruler(line_width)
|
33
|
+
formatted.join("\n")
|
34
|
+
end
|
35
|
+
|
36
|
+
def comment_parts
|
37
|
+
self.class.const_get(:COMMENT_PARTS)
|
38
|
+
end
|
39
|
+
|
40
|
+
def header_ruler(line_width)
|
41
|
+
ruler(line_width)
|
42
|
+
end
|
43
|
+
|
44
|
+
def footer_ruler(line_width)
|
45
|
+
ruler(line_width)
|
46
|
+
end
|
47
|
+
|
48
|
+
def ruler(line_width)
|
49
|
+
first, middle, last = comment_parts
|
50
|
+
ruler_width = (line_width - first.size - last.size) / middle.size
|
51
|
+
"#{first}#{middle * ruler_width}#{last}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def format_line(line)
|
55
|
+
" #{line} "
|
56
|
+
end
|
57
|
+
|
58
|
+
def remove_copyright!
|
59
|
+
contents.sub!(self.class.const_get(:COPYRIGHT_REGEXP), '')
|
60
|
+
if $~ && $~[:comment]
|
61
|
+
parse_comment($~[:comment])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def parse_comment(comment)
|
66
|
+
@comment_lines = comment.split("\n")
|
67
|
+
@copyright_lines = nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def comment_lines
|
71
|
+
@comment_lines
|
72
|
+
end
|
73
|
+
|
74
|
+
def comment?
|
75
|
+
!!@comment_lines
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String]
|
79
|
+
def write_copyright!
|
80
|
+
remove_copyright!
|
81
|
+
add_copyright!
|
82
|
+
write_contents(contents)
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_copyright!
|
86
|
+
@contents = [format_copyright, contents].join("\n\n")
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def copyright_lines
|
92
|
+
@copyright_lines ||= begin
|
93
|
+
lines = []
|
94
|
+
|
95
|
+
lines << repo.copyright_label
|
96
|
+
|
97
|
+
if owner || authors.size > 0
|
98
|
+
authors_label = (authors.size > 1) ? 'Authors: ' : 'Author: '
|
99
|
+
author_names = (authors - [owner]).map { |a| a.identifier }.sort
|
100
|
+
prepend = ' ' * authors_label.size
|
101
|
+
lines << "#{authors_label}#{owner.identifier}"
|
102
|
+
author_names.each do |author|
|
103
|
+
lines << "#{prepend}#{author}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if comment?
|
108
|
+
lines << ''
|
109
|
+
lines += comment_lines
|
110
|
+
end
|
111
|
+
|
112
|
+
lines
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# @return [Giteaucrat::File]
|
117
|
+
def file
|
118
|
+
__getobj__
|
119
|
+
end
|
120
|
+
|
121
|
+
def contents
|
122
|
+
@contents ||= read_contents
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters/formatter'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
class JavaFormatter < Formatter
|
13
|
+
COMMENT_PARTS = %w(/* * */)
|
14
|
+
|
15
|
+
COPYRIGHT_REGEXP = %r{/\*(?<ruler>\*+)\n(?<copyrights>(\s\*\s*[^\s\*]+.*\n)+)(\s\*\s*\*?\n(?<comment>(\s\*\s?.*\*?\n)+))?(\s\g<ruler>\**/\n+)}
|
16
|
+
|
17
|
+
def format_line(line)
|
18
|
+
" * #{line} *"
|
19
|
+
end
|
20
|
+
|
21
|
+
def header_ruler(line_width)
|
22
|
+
"/*#{'*' * (line_width - 3)}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def footer_ruler(line_width)
|
26
|
+
" #{'*' * (line_width - 3)}*/"
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse_comment(comment)
|
30
|
+
comment_lines = comment.split("\n").map do |line|
|
31
|
+
line.sub(/\A\s\*\s?/, '').sub(/\s*\*\s*\Z/, '')
|
32
|
+
end
|
33
|
+
@comment_lines = comment_lines
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters/ruby_formatter'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
class PythonFormatter < RubyFormatter
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters/formatter'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
class RubyFormatter < Formatter
|
13
|
+
COMMENT_PARTS = %w(# # #)
|
14
|
+
|
15
|
+
# @return [String]
|
16
|
+
CODING_REGEXP = /\A(#\s*.*coding:\s*utf-8\s*\n+)?/
|
17
|
+
COPYRIGHT_REGEXP = /(?<ruler>##+#\n)(?<copyright>(#\s*[^\s#]+.*\s#\n)+)(#\s+#?\n(?<comment>(#\s*.*#?\n)+))?\k<ruler>\n+/
|
18
|
+
|
19
|
+
def format_copyright
|
20
|
+
copyright = super
|
21
|
+
copyright = "# coding: utf-8\n\n#{copyright}" if include_encoding?
|
22
|
+
copyright
|
23
|
+
end
|
24
|
+
|
25
|
+
def format_line(line)
|
26
|
+
first, _, last = comment_parts
|
27
|
+
"#{first} #{line} #{last}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def remove_copyright!
|
31
|
+
super
|
32
|
+
contents.sub!(CODING_REGEXP, '') if include_encoding?
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_copyright!
|
36
|
+
if !include_encoding? && !!(contents =~ CODING_REGEXP)
|
37
|
+
lines = contents.split(/\n/).to_a
|
38
|
+
lines.insert(1, format_copyright)
|
39
|
+
@contents = lines.join("\n")
|
40
|
+
else
|
41
|
+
super
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_comment(comment)
|
46
|
+
middle = Regexp.escape(comment_parts[1])
|
47
|
+
comment_lines = comment.split("\n").map do |line|
|
48
|
+
line.sub(/\A#{middle}\s?/, '').sub(/\s*#{middle}\s*\Z/, '')
|
49
|
+
end
|
50
|
+
@comment_lines = comment_lines
|
51
|
+
end
|
52
|
+
|
53
|
+
def include_encoding?
|
54
|
+
repo.include_encoding?
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat/formatters/ruby_formatter'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
class SassFormatter < RubyFormatter
|
13
|
+
COMMENT_PARTS = %w(// // //)
|
14
|
+
COPYRIGHT_REGEXP = %r{(?<ruler>//+\n)(?<copyright>(//\s*[^\s/]+.*\s//\n)+)(//\s+//?\n(?<comment>(//\s*.*//?\n)+))?\k<ruler>\n+}
|
15
|
+
|
16
|
+
def include_encoding?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_copyright!
|
21
|
+
@contents = [format_copyright, contents].join("\n\n")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
################################################
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
|
+
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
|
+
################################################
|
7
|
+
|
8
|
+
require 'giteaucrat'
|
9
|
+
|
10
|
+
module Giteaucrat
|
11
|
+
module Formatters
|
12
|
+
UnknownFormatError = Class.new(StandardError)
|
13
|
+
|
14
|
+
EXTENSIONS = {
|
15
|
+
'.rb' => :RubyFormatter,
|
16
|
+
'.java' => :JavaFormatter,
|
17
|
+
'.py' => :PythonFormatter,
|
18
|
+
'.sass' => :SassFormatter,
|
19
|
+
'.scss' => :SassFormatter,
|
20
|
+
'.coffee' => :CoffeeFormatter,
|
21
|
+
}
|
22
|
+
|
23
|
+
module_function
|
24
|
+
|
25
|
+
def formatter_for(file)
|
26
|
+
extension = ::File.extname(file.name)
|
27
|
+
formatter = EXTENSIONS[extension]
|
28
|
+
raise(UnknownFormatError, extension) unless formatter
|
29
|
+
const_get(formatter).new(file)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'giteaucrat/formatters/formatter'
|
35
|
+
|
36
|
+
require 'giteaucrat/formatters/coffee_formatter'
|
37
|
+
require 'giteaucrat/formatters/java_formatter'
|
38
|
+
require 'giteaucrat/formatters/python_formatter'
|
39
|
+
require 'giteaucrat/formatters/ruby_formatter'
|
40
|
+
require 'giteaucrat/formatters/sass_formatter'
|
data/lib/giteaucrat/repo.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
################################################
|
4
|
-
# © Alexander Semyonov, 2013—2013
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
5
|
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
6
|
################################################
|
7
7
|
|
@@ -42,8 +42,8 @@ module Giteaucrat
|
|
42
42
|
def files
|
43
43
|
@files ||= begin
|
44
44
|
Dir.chdir(path) do
|
45
|
-
|
46
|
-
files + Dir[
|
45
|
+
patterns.inject([]) do |files, pattern|
|
46
|
+
files + Dir[pattern]
|
47
47
|
end.map do |file_name|
|
48
48
|
File.new(name: file_name, repo: self)
|
49
49
|
end
|
@@ -57,6 +57,17 @@ module Giteaucrat
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
# @return [<String>]
|
61
|
+
def patterns
|
62
|
+
@patterns || %w(app/**/*.rb lib/**/*.rb script/**/*.rb spec/**/*.rb test/**/*.rb)
|
63
|
+
end
|
64
|
+
|
65
|
+
attr_writer :patterns
|
66
|
+
|
67
|
+
def patterns=(patterns)
|
68
|
+
@patterns = patterns
|
69
|
+
end
|
70
|
+
|
60
71
|
def timeout
|
61
72
|
Grit::Git.git_timeout
|
62
73
|
end
|
data/lib/giteaucrat/runner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
################################################
|
4
|
-
# © Alexander Semyonov, 2013—2013
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
5
|
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
6
|
################################################
|
7
7
|
|
@@ -52,6 +52,11 @@ module Giteaucrat
|
|
52
52
|
aliases: %w(-c),
|
53
53
|
desc: 'Commit updated copyrights',
|
54
54
|
group: :giteaucrat
|
55
|
+
class_option :patterns,
|
56
|
+
type: :array,
|
57
|
+
aliases: %w(-f),
|
58
|
+
desc: 'Files to copyright',
|
59
|
+
group: :giteaucrat
|
55
60
|
|
56
61
|
desc 'copyrights', 'Update copyright information in files'
|
57
62
|
|
data/lib/giteaucrat/version.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
################################################
|
4
|
-
# © Alexander Semyonov, 2013—2013
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
5
|
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
6
|
################################################
|
7
7
|
|
8
8
|
module Giteaucrat
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.3'
|
10
10
|
end
|
data/lib/giteaucrat.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
################################################
|
4
|
-
# © Alexander Semyonov, 2013—2013
|
4
|
+
# © Alexander Semyonov, 2013—2013, MIT License #
|
5
5
|
# Author: Alexander Semyonov <al@semyonov.us> #
|
6
6
|
################################################
|
7
7
|
|
@@ -11,6 +11,7 @@ module Giteaucrat
|
|
11
11
|
autoload :Author, 'giteaucrat/author'
|
12
12
|
autoload :Common, 'giteaucrat/common'
|
13
13
|
autoload :File, 'giteaucrat/file'
|
14
|
+
autoload :Formatters, 'giteaucrat/formatters'
|
14
15
|
autoload :Repo, 'giteaucrat/repo'
|
15
16
|
autoload :Runner, 'giteaucrat/runner'
|
16
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giteaucrat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Semyonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- .gitignore
|
78
78
|
- Gemfile
|
79
79
|
- LICENSE.txt
|
80
|
+
- MIT-LICENSE
|
80
81
|
- README.md
|
81
82
|
- Rakefile
|
82
83
|
- bin/giteaucrat
|
@@ -87,6 +88,13 @@ files:
|
|
87
88
|
- lib/giteaucrat/author.rb
|
88
89
|
- lib/giteaucrat/common.rb
|
89
90
|
- lib/giteaucrat/file.rb
|
91
|
+
- lib/giteaucrat/formatters.rb
|
92
|
+
- lib/giteaucrat/formatters/coffee_formatter.rb
|
93
|
+
- lib/giteaucrat/formatters/formatter.rb
|
94
|
+
- lib/giteaucrat/formatters/java_formatter.rb
|
95
|
+
- lib/giteaucrat/formatters/python_formatter.rb
|
96
|
+
- lib/giteaucrat/formatters/ruby_formatter.rb
|
97
|
+
- lib/giteaucrat/formatters/sass_formatter.rb
|
90
98
|
- lib/giteaucrat/repo.rb
|
91
99
|
- lib/giteaucrat/runner.rb
|
92
100
|
- lib/giteaucrat/version.rb
|