Class: Codelog::Command::New

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/codelog/command/new.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ New

Returns a new instance of New.



8
9
10
11
# File 'lib/codelog/command/new.rb', line 8

def initialize(name, options)
  @name = name
  @options = options
end

Class Method Details

.run(name, options) ⇒ Object



13
14
15
# File 'lib/codelog/command/new.rb', line 13

def self.run(name, options)
  new(name, options).run
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/codelog/command/new.rb', line 17

def run
  chdir Dir.pwd do
    # This script create a change file for the changelog documentation.

    @file_name = "changelogs/unreleased/#{change_file_timestamp}_#{change_file_name}.yml"
    if @options[:interactive]
      build_from_hash Codelog::CLIs::Interactive.new.run
    else
      build_from_template
    end
    system! "#{default_editor} #{@file_name}" if @options[:edit]
  end
end