Module: Postwave::BlogUtilities
- Included in:
- BlogBuilder, BlogCreator, Client, Post, PostCreator, RssHelper
- Defined in:
- lib/postwave/blog_utilities.rb
Constant Summary collapse
- CONFIG_FILE_NAME =
"postwave.yaml"
- INDEX_FILE_NAME =
"index.csv"
- SUMMARY_FILE_NAME =
"summary.yaml"
- RSS_FILE_NAME =
"rss"
- POSTS_DIR =
"_posts"
- META_DIR =
"meta"
- TAGS_DIR =
"tags"
Instance Method Summary collapse
- #config_values ⇒ Object
- #directory_paths(blog_root = Dir.pwd) ⇒ Object
- #file_paths(blog_root = Dir.pwd) ⇒ Object
- #find_missing_paths(blog_root = Dir.pwd) ⇒ Object
- #is_set_up?(blog_root = Dir.pwd) ⇒ Boolean
Instance Method Details
#config_values ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/postwave/blog_utilities.rb', line 41 def config_values @config_values ||= if yaml_load = YAML.load_file(File.join(Dir.pwd, CONFIG_FILE_NAME)) yaml_load.transform_keys(&:to_sym) else {} end end |
#directory_paths(blog_root = Dir.pwd) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/postwave/blog_utilities.rb', line 24 def directory_paths(blog_root = Dir.pwd) [ File.join(blog_root, POSTS_DIR), File.join(blog_root, POSTS_DIR, META_DIR), File.join(blog_root, POSTS_DIR, META_DIR, TAGS_DIR), ] end |
#file_paths(blog_root = Dir.pwd) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/postwave/blog_utilities.rb', line 16 def file_paths(blog_root = Dir.pwd) [ File.join(blog_root, CONFIG_FILE_NAME), File.join(blog_root, POSTS_DIR, META_DIR, INDEX_FILE_NAME), File.join(blog_root, POSTS_DIR, META_DIR, SUMMARY_FILE_NAME), ] end |
#find_missing_paths(blog_root = Dir.pwd) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/postwave/blog_utilities.rb', line 32 def find_missing_paths(blog_root = Dir.pwd) paths_to_check = directory_paths(blog_root) + file_paths(blog_root) missing_paths = [] paths_to_check.each do |path| missing_paths << path if !FileTest.exist?(path) end missing_paths end |
#is_set_up?(blog_root = Dir.pwd) ⇒ Boolean
11 12 13 14 |
# File 'lib/postwave/blog_utilities.rb', line 11 def is_set_up?(blog_root = Dir.pwd) missing_paths = find_missing_paths(blog_root) missing_paths.empty? end |