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



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

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
# File 'lib/transpec/commit_message.rb', line 13

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

  "    |Convert specs to RSpec \#{@rspec_version} syntax with Transpec\n    |\n    |This conversion is done by Transpec \#{Transpec::Version} with the following command:\n    |    transpec \#{smart_cli_args}\n    |\n    |\#{conversion_summary}\n  END\nend\n".gsub(/^\s+\|/, '').chomp