Class: Amiba::Entry::Create
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Amiba::Entry::Create
show all
- Includes:
- Generator, Repo
- Defined in:
- lib/amiba/entry.rb
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
53
54
55
|
# File 'lib/amiba/entry.rb', line 53
def add_to_git
add_and_commit @source.filename
end
|
#init_source ⇒ Object
19
20
21
22
23
24
25
|
# File 'lib/amiba/entry.rb', line 19
def init_source
@source = Amiba::Source::Entry.new(options[:category].to_sym,
name,
format,
options,
"# New post\n")
end
|
#save_entry ⇒ Object
47
48
49
50
51
|
# File 'lib/amiba/entry.rb', line 47
def save_entry
@source.save do |filename, file_data|
create_file filename, file_data
end
end
|
#should_be_valid ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/amiba/entry.rb', line 33
def should_be_valid
unless @source.valid?
str = ""
@source.errors.each_pair do |area, msg|
if msg.is_a? Array
msg.each {|m| str += "Error detected in #{area}: #{m}\n" }
else
str += "Error detected in #{area}: #{msg.to_s}\n"
end
end
raise Thor::Error.new("Errors detected:\n" + str)
end
end
|
#should_not_exist ⇒ Object
27
28
29
30
31
|
# File 'lib/amiba/entry.rb', line 27
def should_not_exist
unless @source.new?
raise Thor::Error.new("Error: An entry called '#{name}' already exists.")
end
end
|