Class: Amiba::Page::Create
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Amiba::Page::Create
show all
- Includes:
- Generator, Repo
- Defined in:
- lib/amiba/page.rb
Overview
Thor task to create a new page. It checks for the existance of a page already existing and that the user specified a valid format before progressing.
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_git ⇒ Object
49
50
51
52
|
# File 'lib/amiba/page.rb', line 49
def add_to_git
add_and_commit @source.filename
add_and_commit @entry.filename
end
|
#save_page ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/amiba/page.rb', line 40
def save_page
@source.save do |filename, file_data|
create_file filename, file_data
end
@entry.save do |filename, file_data|
create_file filename, file_data
end
end
|
33
34
35
36
37
38
|
# File 'lib/amiba/page.rb', line 33
def should_be_correct_format
if !@source.valid? && !@source.errors[:format].nil?
raise Thor::Error.new("Error: format should be one of " +
Amiba::Source::Page::VALID_FORMATS.join(','))
end
end
|
#should_not_exist ⇒ Object
27
28
29
30
31
|
# File 'lib/amiba/page.rb', line 27
def should_not_exist
unless @source.new?
raise Thor::Error.new("Error:A page called '#{name}' has already been created.")
end
end
|