Module: Postwave::BlogUtilities

Included in:
Client, Post
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"
POSTS_DIR =
"_posts"
META_DIR =
"meta"
TAGS_DIR =
"tags"

Instance Method Summary collapse

Instance Method Details

#directory_paths(blog_root) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/postwave/blog_utilities.rb', line 23

def directory_paths(blog_root)
  [
    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) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/postwave/blog_utilities.rb', line 15

def file_paths(blog_root)
  [
    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) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/postwave/blog_utilities.rb', line 31

def find_missing_paths(blog_root)
  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) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/postwave/blog_utilities.rb', line 10

def is_set_up?(blog_root)
  missing_paths = find_missing_paths(blog_root)
  missing_paths.empty?
end