Class: Transpec::CommitMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/transpec/commit_message.rb

Instance Method Summary collapse

Constructor Details

#initialize(report, rspec_version, cli_args = []) ⇒ CommitMessage

Returns a new instance of CommitMessage.



7
8
9
10
11
# File 'lib/transpec/commit_message.rb', line 7

def initialize(report, rspec_version, cli_args = [])
  @report = report
  @rspec_version = rspec_version
  @cli_args = cli_args
end

Instance Method Details

#smart_cli_argsObject



28
29
30
31
32
33
34
35
36
# File 'lib/transpec/commit_message.rb', line 28

def smart_cli_args
  @cli_args.map do |arg|
    if arg.include?(' ')
      arg.inspect
    else
      arg
    end
  end.join(' ')
end

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/transpec/commit_message.rb', line 13

def to_s
  conversion_summary = @report.summary(bullet: '*', separate_by_blank_line: true)

  <<-END.gsub(/^\s+\|/, '').chomp
    |Convert specs to RSpec #{@rspec_version} syntax with Transpec
    |
    |This conversion is done by Transpec #{Transpec::Version} with the following command:
    |    transpec #{smart_cli_args}
    |
    |#{conversion_summary}
    |
    |For more details: https://github.com/yujinakayama/transpec#supported-conversions
  END
end