class Giteaucrat::Formatters::RubyFormatter
Constants
- CODING_REGEXP
@return [String]
- COMMENT_PARTS
- COPYRIGHT_REGEXP
Public Instance Methods
encoding()
click to toggle source
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 49 def encoding @encoding || (include_encoding? && '# coding: utf-8' || nil) end
format_copyright()
click to toggle source
Calls superclass method
Giteaucrat::Formatters::Formatter#format_copyright
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 20 def format_copyright copyright = super copyright = [encoding, copyright].compact.join("\n\n") copyright end
format_line(line)
click to toggle source
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 26 def format_line(line) first, _, last = comment_parts "#{first} #{line} #{last}" end
include_encoding?()
click to toggle source
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 45 def include_encoding? repo.include_encoding? end
parse_comment(comment)
click to toggle source
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 37 def parse_comment(comment) middle = Regexp.escape(comment_parts[1]) comment_lines = comment.split("\n").map do |line| line.sub(/\A#{middle}\s?/, '').sub(/\s*#{middle}\s*\Z/, '') end @comment_lines = comment_lines end
remove_copyright!()
click to toggle source
Calls superclass method
Giteaucrat::Formatters::Formatter#remove_copyright!
# File lib/giteaucrat/formatters/ruby_formatter.rb, line 31 def remove_copyright! super contents.sub!(CODING_REGEXP, '') @encoding = Regexp.last_match(2) if Regexp.last_match(2) end