Module: Postwave::BlogUtilities

Included in:
BlogBuilder, BlogCreator, 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

Instance Method Details

#config_valuesObject



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_pathsObject



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

def directory_paths
  [
    File.join(Dir.pwd, POSTS_DIR),
    File.join(Dir.pwd, POSTS_DIR, META_DIR),
    File.join(Dir.pwd, POSTS_DIR, META_DIR, TAGS_DIR),
  ]
end

#file_pathsObject



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

def file_paths
  [
    File.join(Dir.pwd, CONFIG_FILE_NAME),
    File.join(Dir.pwd, POSTS_DIR, META_DIR, INDEX_FILE_NAME),
    File.join(Dir.pwd, POSTS_DIR, META_DIR, SUMMARY_FILE_NAME),
  ]
end

#find_missing_pathsObject



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

def find_missing_paths
  paths_to_check = directory_paths + file_paths
  missing_paths = []
  paths_to_check.each do |path|
    missing_paths << path if !FileTest.exists?(path)
  end
  missing_paths
end

#is_set_up?Boolean

Returns:

  • (Boolean)


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

def is_set_up?
  missing_paths = find_missing_paths
  missing_paths.empty?
end