Class: Giteaucrat::Formatters::JavaFormatter

Inherits:
Formatter
  • Object
show all
Defined in:
lib/giteaucrat/formatters/java_formatter.rb

Constant Summary collapse

COMMENT_PARTS =
%w[/* * */].freeze
%r{/\*(?<ruler>\*+)\n(?<copyrights>(\s\*\s*[^\s\*]+.*\n)+)(\s\*\s*\*?\n(?<comment>(\s\*\s?.*\*?\n)+))?(\s\g<ruler>\**/\n+)}

Constants inherited from Formatter

Formatter::HASHBANG_REGEXP

Instance Attribute Summary

Attributes inherited from Formatter

#comment_lines

Instance Method Summary collapse

Methods inherited from Formatter

#add_copyright!, #comment?, #comment_parts, #format_copyright, #remove_copyright!, #ruler, #write_copyright!

Instance Method Details



26
27
28
# File 'lib/giteaucrat/formatters/java_formatter.rb', line 26

def footer_ruler(line_width)
  " #{'*' * (line_width - 3)}*/"
end

#format_line(line) ⇒ Object



18
19
20
# File 'lib/giteaucrat/formatters/java_formatter.rb', line 18

def format_line(line)
  " * #{line} *"
end

#header_ruler(line_width) ⇒ Object



22
23
24
# File 'lib/giteaucrat/formatters/java_formatter.rb', line 22

def header_ruler(line_width)
  "/*#{'*' * (line_width - 3)}"
end

#parse_comment(comment) ⇒ Object



30
31
32
33
34
35
# File 'lib/giteaucrat/formatters/java_formatter.rb', line 30

def parse_comment(comment)
  comment_lines = comment.split("\n").map do |line|
    line.sub(/\A\s\*\s?/, '').sub(/\s*\*\s*\Z/, '')
  end
  @comment_lines = comment_lines
end