Class: ReleaseNotes::Generators::ReleaseNote

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/release_notes/generators/release_note.rb

Instance Method Summary collapse

Instance Method Details

#check_versionObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/release_notes/generators/release_note.rb', line 35

def check_version
  destination = version_exists?(@destination, @release_version)

  if destination
    if options.force?
      remove_file(destination)
    else
      raise Thor::Error, 
<<-ERROR
    Another update was found using the version number #{@release_version.gsub('_', '.')}. 
    Use --force to remove the old update file and replace it.
ERROR
    end
  end
end

#copy_release_noteObject



51
52
53
54
55
# File 'lib/release_notes/generators/release_note.rb', line 51

def copy_release_note
  update_number = next_update_number(destination)
  @filename = "#{destination}/#{update_number}_#{@release_version}.md"
  template(@update_template, @filename)
end

#create_directoryObject



31
32
33
# File 'lib/release_notes/generators/release_note.rb', line 31

def create_directory
  empty_directory(@destination)
end

#set_local_assignsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/release_notes/generators/release_note.rb', line 16

def set_local_assigns
  @app_name = ReleaseNotes.app_name
  @update_template = 'update_blank.md'
  @destination = File.expand_path(destination)
  @release_version = release_version.gsub('.', '_')
  @message = message

  message.each do |k,v|
    if v.length > 0
      @update_template = 'update.md'
      break
    end
  end
end