Class: ReleaseNotes::CLI
- Inherits:
-
Thor
- Object
- Thor
- ReleaseNotes::CLI
- Defined in:
- lib/release_notes/cli.rb,
lib/release_notes/cli/helpers.rb
Defined Under Namespace
Classes: Helpers
Instance Method Summary collapse
- #new ⇒ Object
-
#update ⇒ Object
method_option :version, :aliases => ‘-V’, :desc => ‘update only the given version number’.
- #version ⇒ Object
Instance Method Details
#new ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/release_notes/cli.rb', line 22 def new if [:version].nil? last_version = ReleaseNotes::Versioning.current_version_number([:destination]) update_version = ReleaseNotes::Versioning::Semantic.increment(last_version, [:increment]) else update_version = [:version] end = ReleaseNotes::CLI::Helpers. if [:message] = ReleaseNotes::CLI::Helpers.interactive_bullets() end ReleaseNotes::Generators::ReleaseNote.start([[:destination], , update_version, "--force=#{options[:force] || false}"]) end |
#update ⇒ Object
method_option :version, :aliases => ‘-V’, :desc => ‘update only the given version number’
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/release_notes/cli.rb', line 49 def update # If reset option is passed delete all release notes in model if [:reset] stamp = nil release_log = "" begin File.delete("#{options[:destination]}/README.md") rescue Errno::ENOENT # Nothing to see here... move along. end ReleaseNotes.release_note_model.constantize.all.each do |rn| rn.destroy end else # Checks timestamp of last release note stored begin stamp = File.read("#{options[:destination]}/stamp") rescue Errno::ENOENT stamp = nil end # Reads contents of release note compilation file begin release_log = File.read("#{options[:destination]}/README.md") rescue Errno::ENOENT release_log = "" end end # Collects relevant files and saves version and content to db update_files = collect_update_files([:destination]) update_files.each do |file| = file[0].to_i if !stamp.nil? and <= stamp.to_i next end version = file[1..4].join('.')[0..-4] file = file.join('_') markdown = File.read("#{options[:destination]}/#{file}") ReleaseNotes.release_note_model.constantize.create(version: version, markdown: markdown) release_log.insert(0, "#{markdown}\n\n---\n\n") unless [:no_log] end # Store the timestamp of the last release note new_stamp = latest_update_file([:destination]) File.write("#{options[:destination]}/stamp", "#{new_stamp}", mode: 'w') # Store release note compilation file File.write("#{options[:destination]}/README.md", "#{release_log}", mode: 'w') unless [:no_log] say "#{ReleaseNotes.release_note_model} model successfully updated.", :green say "ReleaseNotes log successfully updated (see #{options[:destination]}/README.md).", :green unless [:no_log] end |
#version ⇒ Object
113 114 115 |
# File 'lib/release_notes/cli.rb', line 113 def version puts "ReleaseNotes #{ReleaseNotes::VERSION}" end |