giteaucrat 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 576669d8685ed74eb31ac2081ac4e3c8bd4f67d2
4
- data.tar.gz: d54cc4d9539caff931fcb0c0702f8076fa47ee1e
3
+ metadata.gz: 79157ad2066d45d9c600c86afbd578d553eb0512
4
+ data.tar.gz: 6f5b2f2eab777ba7600cfd441c90ed5d20d6cf9a
5
5
  SHA512:
6
- metadata.gz: 64058c19b1ff22d391317779fd363bf4e498eb5a641cb72219ca0bcd8e00ec50498ece45d63ad1cd1dbe4d6cf22bcd9f88875ef9b669baa1a1ff5a7ce2790763
7
- data.tar.gz: 48c704f4a754f8521922b4acfa0c89ba594605a3f8e2604bd7039dde017c57ae096177458763b0add6d7bdeb549b75cb104fd6acae48606910e80bc4d1fd6060
6
+ metadata.gz: 5ea12ea22ce3afc00f0841e72f886288f79bc32143493ee1faec614ee0c2930619386063d99ebb83dd40ec0884f5112aec28231a0d7713677952faacb070349e
7
+ data.tar.gz: a250b3663e2ccd9db331f3e5c199cf527736b8ef9bd16dc1cab04350f0f45dc50c45751bcfe02f64e0ddc554d7d03a607ff59e9220c1527a75f554c1b9ae94ce
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .ruby-version
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ sudo: false
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.3.0
6
+ script: bundle exec ./bin/giteaucrat
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in giteaucrat.gemspec
data/README.md CHANGED
@@ -29,3 +29,7 @@ You can see all available options using:
29
29
  5. Create new Pull Request
30
30
 
31
31
  © Alexander Semyonov, 2013. See MIT-LICENSE for details
32
+
33
+
34
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/alsemyonov/giteaucrat/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
35
+
data/Rakefile CHANGED
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
data/bin/bundler ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundler' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('bundler', 'bundler')
data/bin/htmldiff ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'htmldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'ldiff' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('diff-lcs', 'ldiff')
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'posix-spawn-benchmark' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('posix-spawn', 'posix-spawn-benchmark')
data/bin/rake ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('rake', 'rake')
data/bin/thor ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'thor' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require 'pathname'
12
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ require 'rubygems'
16
+ require 'bundler/setup'
17
+
18
+ load Gem.bin_path('thor', 'thor')
@@ -1,6 +1,17 @@
1
1
  ---
2
2
  commit_keyword: "#giteaucrat"
3
- copyright_owner: Alexander Semyonov
3
+ copyright_owner: Alex Semyonov
4
4
  copyright_format: "© %{owner}, %{years}, %{license}"
5
5
  include_encoding: true
6
6
  license: MIT License
7
+ authors:
8
+ - name: Alex Semyonov
9
+ email: alex@semyonov.us
10
+ names:
11
+ - Alex Semyonov
12
+ - Alexander Semyonov
13
+ emails:
14
+ - alex@semyonov.us
15
+ - al@semyonov.us
16
+ - name: Sergey Ukustov
17
+ email: sergey@ukstv.me
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'giteaucrat'
4
4
  require 'giteaucrat/runner'
5
5
 
6
6
  Giteaucrat::Runner.start
data/giteaucrat.gemspec CHANGED
@@ -1,26 +1,28 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  lib = File.expand_path('../lib', __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require 'giteaucrat/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = 'giteaucrat'
8
- spec.version = Giteaucrat::VERSION
9
- spec.authors = ['Alexander Semyonov']
10
- spec.email = %w(al@semyonov.us)
11
- spec.description = %q{Automatically update copyright messages using git}
12
- spec.summary = %q{The Git bureaucrat}
13
- spec.homepage = 'http://github.com/alsemyonov/giteaucrat'
14
- spec.license = 'MIT'
9
+ spec.name = 'giteaucrat'
10
+ spec.version = Giteaucrat::VERSION
11
+ spec.authors = ['Alexander Semyonov']
12
+ spec.email = %w[al@semyonov.us]
13
+ spec.description = 'Automatically update copyright messages using git'
14
+ spec.summary = 'The Git bureaucrat'
15
+ spec.homepage = 'http://github.com/alsemyonov/giteaucrat'
16
+ spec.license = 'MIT'
15
17
 
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = %w(lib)
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
20
+ spec.require_paths = %w[lib]
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
22
 
21
- spec.add_dependency 'thor'
22
23
  spec.add_dependency 'grit'
24
+ spec.add_dependency 'thor'
23
25
 
24
26
  spec.add_development_dependency 'bundler', '~> 1.3'
25
- spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'rake', '~> 12.0'
26
28
  end
@@ -1,26 +1,36 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
2
8
 
3
9
  require 'grit/blame'
4
10
 
5
11
  module Grit
6
12
  class Blame
7
13
  def process_raw_blame(output)
8
- lines, final = [], []
9
- info, commits = {}, {}
14
+ lines = []
15
+ final = []
16
+ info = {}
17
+ commits = {}
10
18
 
11
19
  # process the output
12
20
  output.split("\n").each do |line|
13
21
  if line[0, 1] == "\t"
14
22
  lines << line[1, line.size]
15
23
  elsif m = /^(\w{40}) (\d+) (\d+)/.match(line)
16
- commit_id, old_lineno, lineno = m[1], m[2].to_i, m[3].to_i
17
- commits[commit_id] = nil if !commits.key?(commit_id)
24
+ commit_id = m[1]
25
+ old_lineno = m[2].to_i
26
+ lineno = m[3].to_i
27
+ commits[commit_id] = nil unless commits.key?(commit_id)
18
28
  info[lineno] = [commit_id, old_lineno]
19
29
  end
20
30
  end
21
31
 
22
32
  # load all commits in single call
23
- @repo.batch(*(commits.keys - ['0'*40])).each do |commit|
33
+ @repo.batch(*(commits.keys - ['0' * 40])).each do |commit|
24
34
  commits[commit.id] = commit if commit
25
35
  end
26
36
 
data/lib/giteaucrat.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/version'
9
10
 
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat'
9
10
  require 'set'
@@ -42,9 +43,7 @@ module Giteaucrat
42
43
  end
43
44
 
44
45
  def self.to_yaml
45
- all.map do |author|
46
- author.to_hash
47
- end.sort { |a, b| a[:name] <=> b[:name] }.to_yaml
46
+ all.map(&:to_hash).sort { |a, b| a[:name] <=> b[:name] }.to_yaml
48
47
  end
49
48
 
50
49
  # @return [Boolean]
@@ -57,7 +56,7 @@ module Giteaucrat
57
56
 
58
57
  def check_multiple_emails!
59
58
  if emails.count > 1 && !instance_variable_defined?(:@email)
60
- STDERR.puts "#{name} has multiple emails:\n#{emails.map {|e| "* #{e}"}.join("\n")}\nPlease set right one in your giteaucrat.yml\n"
59
+ STDERR.puts "#{name} has multiple emails:\n#{emails.map { |e| "* #{e}" }.join("\n")}\nPlease set right one in your giteaucrat.yml\n"
61
60
  end
62
61
  end
63
62
 
@@ -129,7 +128,7 @@ module Giteaucrat
129
128
 
130
129
  # @return [Hash]
131
130
  def to_hash
132
- hash = {'name' => name.to_s, 'email' => email.to_s}
131
+ hash = { 'name' => name.to_s, 'email' => email.to_s }
133
132
  hash['names'] = names.to_a - [name] if names.size > 1
134
133
  hash['emails'] = emails.to_a - [email] if emails.size > 1
135
134
  hash['ignored'] = true if ignored?
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat'
9
10
 
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Authors: Alexander Semyonov <al@semyonov.us> #
6
- # Sergey Ukustov <sergey@ukstv.me> #
7
- ################################################
4
+ ##############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Authors: Alex Semyonov <alex@semyonov.us> #
7
+ # Sergey Ukustov <sergey@ukstv.me> #
8
+ ##############################################
8
9
 
9
10
  require 'giteaucrat'
10
11
  require 'grit'
@@ -25,13 +26,12 @@ module Giteaucrat
25
26
  @authors ||= begin
26
27
  blame = repo.git_repo.blame(name)
27
28
  lines = blame.lines
28
- commits = lines.map { |line| line.commit }.uniq.find_all do |commit|
29
+ commits = lines.map(&:commit).uniq.find_all do |commit|
29
30
  !repo.ignored_commit?(commit)
30
31
  end
31
- commits.inject(Set.new) do |authors, commit|
32
+ commits.each_with_object(Set.new) do |commit, authors|
32
33
  author = Author.find_by_git_person(commit.author)
33
34
  authors << author unless author.ignored?
34
- authors
35
35
  end
36
36
  end
37
37
  end
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat'
9
10
 
@@ -18,8 +19,8 @@ module Giteaucrat
18
19
  '.sass' => :SassFormatter,
19
20
  '.scss' => :SassFormatter,
20
21
  '.coffee' => :CoffeeFormatter,
21
- '.erl' => :ErlangFormatter,
22
- }
22
+ '.erl' => :ErlangFormatter
23
+ }.freeze
23
24
 
24
25
  module_function
25
26
 
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/ruby_formatter'
9
10
 
@@ -1,16 +1,17 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/coffee_formatter'
9
10
 
10
11
  module Giteaucrat
11
12
  module Formatters
12
13
  class ErlangFormatter < CoffeeFormatter
13
- COMMENT_PARTS = %w(% % %)
14
+ COMMENT_PARTS = %w[% % %].freeze
14
15
  COPYRIGHT_REGEXP = %r{(?<ruler>%+\n)(?<copyright>(%\s*[^\s/]+.*\s%\n)+)(%\s+%?\n(?<comment>(%\s*.*%?\n)+))?\k<ruler>\n+}
15
16
  end
16
17
  end
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters'
9
10
  require 'delegate'
@@ -18,7 +19,7 @@ module Giteaucrat
18
19
  first, _, last = comment_parts
19
20
  lines = copyright_lines
20
21
 
21
- max_line_size = lines.max { |a, b| a.size <=> b.size }.size
22
+ max_line_size = lines.max_by(&:size).size
22
23
  max_line_size += 1 if max_line_size.odd?
23
24
 
24
25
  lines = lines.map do |line|
@@ -59,13 +60,11 @@ module Giteaucrat
59
60
 
60
61
  def remove_copyright!
61
62
  if contents =~ HASHBANG_REGEXP
62
- @hashbang = $1
63
+ @hashbang = Regexp.last_match(1)
63
64
  contents.sub!(HASHBANG_REGEXP, '')
64
65
  end
65
66
  contents.sub!(self.class.const_get(:COPYRIGHT_REGEXP), '')
66
- if $~ && $~[:comment]
67
- parse_comment($~[:comment])
68
- end
67
+ parse_comment($LAST_MATCH_INFO[:comment]) if $LAST_MATCH_INFO && $LAST_MATCH_INFO[:comment]
69
68
  end
70
69
 
71
70
  def parse_comment(comment)
@@ -73,9 +72,7 @@ module Giteaucrat
73
72
  @copyright_lines = nil
74
73
  end
75
74
 
76
- def comment_lines
77
- @comment_lines
78
- end
75
+ attr_reader :comment_lines
79
76
 
80
77
  def comment?
81
78
  !!@comment_lines
@@ -101,9 +98,9 @@ module Giteaucrat
101
98
 
102
99
  lines << repo.copyright_label
103
100
 
104
- if owner || authors.size > 0
105
- authors_label = (authors.size > 1) ? 'Authors: ' : 'Author: '
106
- author_names = (authors - [owner]).map { |a| a.identifier }.sort
101
+ if owner || !authors.empty?
102
+ authors_label = authors.size > 1 ? 'Authors: ' : 'Author: '
103
+ author_names = (authors - [owner]).map(&:identifier).sort
107
104
  prepend = ' ' * authors_label.size
108
105
  lines << "#{authors_label}#{owner.identifier}"
109
106
  author_names.each do |author|
@@ -1,16 +1,17 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/formatter'
9
10
 
10
11
  module Giteaucrat
11
12
  module Formatters
12
13
  class JavaFormatter < Formatter
13
- COMMENT_PARTS = %w(/* * */)
14
+ COMMENT_PARTS = %w[/* * */].freeze
14
15
 
15
16
  COPYRIGHT_REGEXP = %r{/\*(?<ruler>\*+)\n(?<copyrights>(\s\*\s*[^\s\*]+.*\n)+)(\s\*\s*\*?\n(?<comment>(\s\*\s?.*\*?\n)+))?(\s\g<ruler>\**/\n+)}
16
17
 
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/ruby_formatter'
9
10
 
@@ -1,16 +1,17 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/formatter'
9
10
 
10
11
  module Giteaucrat
11
12
  module Formatters
12
13
  class RubyFormatter < Formatter
13
- COMMENT_PARTS = %w(# # #)
14
+ COMMENT_PARTS = %w[# # #].freeze
14
15
 
15
16
  # @return [String]
16
17
  CODING_REGEXP = /\A((#\s*.*coding:\s*[^\s]+)\s*\n+)?/
@@ -30,7 +31,7 @@ module Giteaucrat
30
31
  def remove_copyright!
31
32
  super
32
33
  contents.sub!(CODING_REGEXP, '')
33
- @encoding = $2 if $2
34
+ @encoding = Regexp.last_match(2) if Regexp.last_match(2)
34
35
  end
35
36
 
36
37
  def parse_comment(comment)
@@ -1,16 +1,17 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat/formatters/coffee_formatter'
9
10
 
10
11
  module Giteaucrat
11
12
  module Formatters
12
13
  class SassFormatter < CoffeeFormatter
13
- COMMENT_PARTS = %w(// // //)
14
+ COMMENT_PARTS = %w[// // //].freeze
14
15
  COPYRIGHT_REGEXP = %r{(?<ruler>//+\n)(?<copyright>(//\s*[^\s/]+.*\s//\n)+)(//\s+//?\n(?<comment>(//\s*.*//?\n)+))?\k<ruler>\n+}
15
16
  end
16
17
  end
@@ -1,9 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ##############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Authors: Alex Semyonov <alex@semyonov.us> #
7
+ # Sergey Ukustov <sergey@ukstv.me> #
8
+ ##############################################
7
9
 
8
10
  require 'giteaucrat'
9
11
  require 'grit'
@@ -13,12 +15,8 @@ module Giteaucrat
13
15
  include Common
14
16
 
15
17
  def self.defaults=(options = {})
16
- if options[:git]
17
- Grit::Git.git_binary = options[:git]
18
- end
19
- if options[:git_timeout]
20
- Grit::Git.git_timeout = options[:git_timeout]
21
- end
18
+ Grit::Git.git_binary = options[:git] if options[:git]
19
+ Grit::Git.git_timeout = options[:git_timeout] if options[:git_timeout]
22
20
  end
23
21
 
24
22
  def git_repo
@@ -52,21 +50,17 @@ module Giteaucrat
52
50
  end
53
51
 
54
52
  def write_copyrights!
55
- files.each do |file|
56
- file.write_copyright!
57
- end
53
+ files.each(&:write_copyright!)
58
54
  end
59
55
 
60
56
  # @return [<String>]
61
57
  def patterns
62
- @patterns || %w(app/**/*.rb lib/**/*.rb script/**/*.rb spec/**/*.rb test/**/*.rb)
58
+ @patterns || %w[app/**/*.rb lib/**/*.rb script/**/*.rb spec/**/*.rb test/**/*.rb]
63
59
  end
64
60
 
65
61
  attr_writer :patterns
66
62
 
67
- def patterns=(patterns)
68
- @patterns = patterns
69
- end
63
+ attr_writer :patterns
70
64
 
71
65
  def timeout
72
66
  Grit::Git.git_timeout
@@ -90,8 +84,7 @@ module Giteaucrat
90
84
  end
91
85
  end
92
86
 
93
- def config=(*)
94
- end
87
+ def config=(*); end
95
88
 
96
89
  # @return [Number]
97
90
  def copyright_year
@@ -108,10 +101,10 @@ module Giteaucrat
108
101
 
109
102
  # @return [String]
110
103
  def copyright_label
111
- @copyright_label ||= copyright_format.
112
- gsub('%{years}', [copyright_year, Time.now.year].compact.join('—')).
113
- gsub('%{owner}', copyright_owner).
114
- gsub('%{license}', license || '')
104
+ @copyright_label ||= copyright_format
105
+ .gsub('%{years}', [copyright_year, Time.now.year].compact.join('—'))
106
+ .gsub('%{owner}', copyright_owner)
107
+ .gsub('%{license}', license || '')
115
108
  end
116
109
 
117
110
  # @return [Regexp]
@@ -143,6 +136,5 @@ module Giteaucrat
143
136
  find_git_repo(::File.expand_path(::File.join(directory, '..')))
144
137
  end
145
138
  end
146
-
147
139
  end
148
140
  end
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  require 'giteaucrat'
9
10
  require 'thor'
@@ -12,49 +13,49 @@ require 'yaml'
12
13
  module Giteaucrat
13
14
  class Runner < Thor
14
15
  class_option :git, group: :git
15
- class_option :timeout, default: 30, group: :git
16
+ class_option :timeout, default: 30, group: :git, type: :numeric
16
17
  class_option :path, default: Dir.pwd, desc: 'Path to project that needs some bureaucracy.'
17
18
  class_option :config,
18
19
  default: ::File.join(Dir.pwd, 'config', 'giteaucrat.yml'),
19
20
  desc: 'Giteaucrat configuration',
20
21
  group: :giteaucrat
21
22
  class_option :commit_keyword,
22
- aliases: %w(-i),
23
+ aliases: %w[-i],
23
24
  default: '#giteaucrat',
24
25
  desc: 'Commit keyword to prepend giteaucrat commits (to ignore authorship of this commit)',
25
26
  group: :giteaucrat
26
27
  class_option :copyright_owner,
27
- aliases: %w(-o),
28
+ aliases: %w[-o],
28
29
  default: `git config user.name`.chomp,
29
30
  desc: 'Company or owner name to put in copyright header',
30
31
  group: :giteaucrat
31
32
  class_option :copyright_year,
32
- aliases: %w(-y),
33
+ aliases: %w[-y],
33
34
  type: :numeric,
34
35
  desc: 'Start year of copyright',
35
36
  group: :giteaucrat
36
37
  class_option :copyright_format,
37
- aliases: %w(-f),
38
+ aliases: %w[-f],
38
39
  default: '© %{owner}, %{years}',
39
40
  desc: 'Start year of copyright',
40
41
  group: :giteaucrat
41
42
  class_option :license,
42
- aliases: %w(-l),
43
+ aliases: %w[-l],
43
44
  desc: 'License to put in copyright footer'
44
45
  class_option :include_encoding,
45
46
  type: :boolean,
46
47
  default: true,
47
- aliases: %w(-e),
48
+ aliases: %w[-e],
48
49
  desc: 'Put encoding in copyright footer',
49
50
  group: :giteaucrat
50
51
  class_option :commit,
51
52
  type: :boolean,
52
- aliases: %w(-c),
53
+ aliases: %w[-c],
53
54
  desc: 'Commit updated copyrights',
54
55
  group: :giteaucrat
55
56
  class_option :patterns,
56
57
  type: :array,
57
- aliases: %w(-f),
58
+ aliases: %w[-f],
58
59
  desc: 'Files to copyright',
59
60
  group: :giteaucrat
60
61
 
@@ -71,7 +72,6 @@ module Giteaucrat
71
72
 
72
73
  def defaults
73
74
  @defaults ||= begin
74
- YAML::ENGINE.yamler = 'syck'
75
75
  Encoding.default_external = 'utf-8'
76
76
  Encoding.default_internal = 'utf-8'
77
77
 
@@ -83,8 +83,10 @@ module Giteaucrat
83
83
  options.merge!(config)
84
84
  end
85
85
 
86
- config = options.inject({}) do |config, (key, value)|
87
- config[key] = value unless %w(config git path timeout commit).include?(key); config
86
+ config = options.each_with_object({}) do |(key, value), result|
87
+ unless %w[config git path timeout commit].include?(key)
88
+ result[key] = value
89
+ end
88
90
  end.to_yaml
89
91
 
90
92
  unless ::File.file?(options[:config])
@@ -93,7 +95,7 @@ module Giteaucrat
93
95
  end
94
96
 
95
97
  Dir.chdir(path)
96
- Repo.defaults = {git: options[:git], git_timeout: options[:timeout]}
98
+ Repo.defaults = { git: options[:git], git_timeout: options[:timeout].to_s }
97
99
  options
98
100
  end
99
101
  end
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
+ # frozen_string_literal: true
2
3
 
3
- ################################################
4
- # © Alexander Semyonov, 2013—2013, MIT License #
5
- # Author: Alexander Semyonov <al@semyonov.us> #
6
- ################################################
4
+ ############################################
5
+ # © Alex Semyonov, 2013—2017, MIT License #
6
+ # Author: Alex Semyonov <alex@semyonov.us> #
7
+ ############################################
7
8
 
8
9
  module Giteaucrat
9
- VERSION = '0.0.7'
10
+ VERSION = '0.0.8'
10
11
  end
metadata CHANGED
@@ -1,87 +1,93 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giteaucrat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
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-10-22 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: thor
14
+ name: grit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: grit
28
+ name: thor
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '12.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '12.0'
69
69
  description: Automatically update copyright messages using git
70
70
  email:
71
71
  - al@semyonov.us
72
- executables:
73
- - giteaucrat
72
+ executables: []
74
73
  extensions: []
75
74
  extra_rdoc_files: []
76
75
  files:
77
- - .gitignore
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
78
  - Gemfile
79
79
  - LICENSE.txt
80
80
  - MIT-LICENSE
81
81
  - README.md
82
82
  - Rakefile
83
- - bin/giteaucrat
83
+ - bin/bundler
84
+ - bin/htmldiff
85
+ - bin/ldiff
86
+ - bin/posix-spawn-benchmark
87
+ - bin/rake
88
+ - bin/thor
84
89
  - config/giteaucrat.yml
90
+ - exe/giteaucrat
85
91
  - giteaucrat.gemspec
86
92
  - lib/core_ext/grit/blame.rb
87
93
  - lib/giteaucrat.rb
@@ -109,19 +115,18 @@ require_paths:
109
115
  - lib
110
116
  required_ruby_version: !ruby/object:Gem::Requirement
111
117
  requirements:
112
- - - '>='
118
+ - - ">="
113
119
  - !ruby/object:Gem::Version
114
120
  version: '0'
115
121
  required_rubygems_version: !ruby/object:Gem::Requirement
116
122
  requirements:
117
- - - '>='
123
+ - - ">="
118
124
  - !ruby/object:Gem::Version
119
125
  version: '0'
120
126
  requirements: []
121
127
  rubyforge_project:
122
- rubygems_version: 2.1.8
128
+ rubygems_version: 2.5.2
123
129
  signing_key:
124
130
  specification_version: 4
125
131
  summary: The Git bureaucrat
126
132
  test_files: []
127
- has_rdoc: