Class: Anchorman::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/anchorman/cli.rb

Instance Method Summary collapse

Instance Method Details

#htmlObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/anchorman/cli.rb', line 36

def html
  notes = get_notes

  return unless notes.length

  say "#{notes.length} note(s) found, generating HTML..."

  empty_directory File.join('release_notes', 'html')

  url = Git.open('.').remote.url

  notes.each do |n|
    converter = HtmlConverter.new(path: n, converter: Octokit, repo: GitHubRepo.new(url))
    create_file(File.join 'release_notes', 'html', converter.filename) do
      converter.html
    end
  end
end

#notesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/anchorman/cli.rb', line 12

def notes
  git = open_repo

  commits = if options[:from]
              git.log(nil).between options[:from], options[:to]
            else
              git.log(nil)
            end

  return unless commits.size

  say "#{commits.size} commit(s) found - building notes", :green

  empty_directory 'release_notes'

  formatter = CommitFormatter.new
  notes = commits.collect { |c| formatter.format(c) }.join("\n\n")

  create_file "release_notes/#{options[:name]}.md" do
    NOTES_HEADER + notes + NOTES_FOOTER
  end
end