Class: Postwave::BlogCreator
Constant Summary
Postwave::BlogUtilities::CONFIG_FILE_NAME, Postwave::BlogUtilities::INDEX_FILE_NAME, Postwave::BlogUtilities::META_DIR, Postwave::BlogUtilities::POSTS_DIR, Postwave::BlogUtilities::RSS_FILE_NAME, Postwave::BlogUtilities::SUMMARY_FILE_NAME, Postwave::BlogUtilities::TAGS_DIR
Instance Method Summary
collapse
#output_blog_created, #output_blog_description_prompt, #output_blog_name_prompt, #output_blog_posts_path_prompt, #output_blog_url_prompt, #output_build_completed, #output_building, #output_config_message, #output_creating_blog, #output_creating_post, #output_drafts_skipped, #output_exising_setup, #output_general_error, #output_missing_setup, #output_post_created, #output_post_processed, #output_tags_created
#config_values, #directory_paths, #file_paths, #find_missing_paths, #is_set_up?
Instance Method Details
#build_directories ⇒ Object
30
31
32
33
34
|
# File 'lib/postwave/blog_creator.rb', line 30
def build_directories
directory_paths.each do |path|
FileUtils.mkdir_p(path)
end
end
|
#build_files ⇒ Object
36
37
38
39
40
|
# File 'lib/postwave/blog_creator.rb', line 36
def build_files
file_paths.each do |path|
FileUtils.touch(path)
end
end
|
#configure_blog ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/postwave/blog_creator.rb', line 51
def configure_blog
config = {}
output_blog_name_prompt
config[:name] = gets.chomp
output_blog_url_prompt
config[:url] = gets.chomp
output_blog_posts_path_prompt
config[:posts_path] = gets.chomp
output_blog_description_prompt
config[:description] = gets.chomp
File.write(File.join(Dir.pwd, CONFIG_FILE_NAME), config.transform_keys(&:to_s).to_yaml)
output_config_message
end
|
#create ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/postwave/blog_creator.rb', line 13
def create
output_creating_blog
if is_set_up?
output_exising_setup
return
end
build_directories
build_files
write_initial_summary_contents
configure_blog
output_blog_created
end
|
#write_initial_summary_contents ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/postwave/blog_creator.rb', line 42
def write_initial_summary_contents
summary = {
post_count: 0,
tags: []
}
File.write(File.join(Dir.pwd, POSTS_DIR, META_DIR, SUMMARY_FILE_NAME), summary.transform_keys(&:to_s).to_yaml)
end
|