Class: Amiba::Entry::Publish

Inherits:
Thor::Group
  • Object
show all
Includes:
Generator, Repo
Defined in:
lib/amiba/entry.rb

Overview

Thor task to mark an entry published.

Instance Method Summary collapse

Methods included from Repo

#add_and_commit, #init, #last_commit_date, #last_commit_dates, #pull, #push, #repo

Methods included from Generator

included

Instance Method Details

#add_to_gitObject



103
104
105
# File 'lib/amiba/entry.rb', line 103

def add_to_git
  add_and_commit @source.filename, "Published #{@source.filename}"
end

#init_sourceObject



76
77
78
# File 'lib/amiba/entry.rb', line 76

def init_source
  @source = Amiba::Source::Entry.new(options[:category].to_sym, name, format)
end

#save_pageObject



92
93
94
95
96
97
98
99
100
101
# File 'lib/amiba/entry.rb', line 92

def save_page
  @source.state = "published"
  @source.save do |filename, file_data|
    remove_file filename, :verbose => false
    create_file(filename, :verbose => false) do
      file_data
    end
    say_status :published, filename, :green
  end
end

#should_existObject



80
81
82
83
84
# File 'lib/amiba/entry.rb', line 80

def should_exist
  if @source.new?
    raise Thor::Error.new("Error: Can't publish an entry that doesn't exist.")
  end
end

#should_not_be_publishedObject



86
87
88
89
90
# File 'lib/amiba/entry.rb', line 86

def should_not_be_published
  if @source.state == "published"
    raise Thor::Error.new("Entry already published")
  end
end