Class: MarkdownSite::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_site/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, type) ⇒ Config

Returns a new instance of Config.



15
16
17
18
19
20
# File 'lib/markdown_site/config.rb', line 15

def initialize(file, type)
    @file = file
    @type = type
    load_file(file)
    return self
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



5
6
7
# File 'lib/markdown_site/config.rb', line 5

def file
  @file
end

#raw_configObject

Returns the value of attribute raw_config.



5
6
7
# File 'lib/markdown_site/config.rb', line 5

def raw_config
  @raw_config
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/markdown_site/config.rb', line 5

def type
  @type
end

Instance Method Details

#assets_dirObject



87
88
89
# File 'lib/markdown_site/config.rb', line 87

def assets_dir
    return get_generate_info("assets_dir")
end

#citationObject



71
72
73
74
75
# File 'lib/markdown_site/config.rb', line 71

def citation
    if @raw_config
        return @raw_config["citation"]
    end
end

#copy_filesObject



91
92
93
# File 'lib/markdown_site/config.rb', line 91

def copy_files
    return get_generate_info("copy_files")
end

#get_base_info(name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/markdown_site/config.rb', line 22

def get_base_info(name)
    if @raw_config
        if @raw_config[@type.to_s]
            return @raw_config[@type.to_s][name]
        end
    end
    ""
end

#get_generate_info(name) ⇒ Object



31
32
33
34
35
# File 'lib/markdown_site/config.rb', line 31

def get_generate_info(name)
    if @raw_config["generate"]
        return @raw_config["generate"][name]
    end
end

#get_template_info(name) ⇒ Object



37
38
39
40
41
# File 'lib/markdown_site/config.rb', line 37

def get_template_info(name)
    if @raw_config["template"]
        return @raw_config["template"][name]
    end
end

#giscusObject



65
66
67
68
69
# File 'lib/markdown_site/config.rb', line 65

def giscus
    if @raw_config
        return @raw_config["giscus"]
    end
end

#index_templateObject



123
124
125
# File 'lib/markdown_site/config.rb', line 123

def index_template
    return get_template_info("index_template")
end

#journal_templateObject



111
112
113
# File 'lib/markdown_site/config.rb', line 111

def journal_template
    return get_template_info("journal_template")
end

#journalsObject



55
56
57
# File 'lib/markdown_site/config.rb', line 55

def journals
    get_base_info("journals")
end

#journals_templateObject



115
116
117
# File 'lib/markdown_site/config.rb', line 115

def journals_template
    return get_template_info("journals_template")
end

#knowledge_graphObject



95
96
97
# File 'lib/markdown_site/config.rb', line 95

def knowledge_graph
    return get_generate_info("knowledge_graph")
end

#knowledge_graph_templateObject



99
100
101
# File 'lib/markdown_site/config.rb', line 99

def knowledge_graph_template
    return get_template_info("knowledge_graph_template")
end

#languagesObject



77
78
79
80
81
# File 'lib/markdown_site/config.rb', line 77

def languages
    if @raw_config
        return @raw_config["languages"]
    end
end

#load_file(file) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/markdown_site/config.rb', line 7

def load_file(file)
    @raw_config = begin
        Tomlrb.load_file(file)
    rescue
        {}
    end
end

#page_templateObject



107
108
109
# File 'lib/markdown_site/config.rb', line 107

def page_template
    return get_template_info("page_template")
end

#pagesObject



51
52
53
# File 'lib/markdown_site/config.rb', line 51

def pages
    get_base_info("pages")
end

#pages_templateObject



103
104
105
# File 'lib/markdown_site/config.rb', line 103

def pages_template
    return get_template_info("pages_template")
end

#preprocessingObject



59
60
61
62
63
# File 'lib/markdown_site/config.rb', line 59

def preprocessing
    if @raw_config
        return @raw_config["preprocessing"]
    end
end

#publish_dirObject



83
84
85
# File 'lib/markdown_site/config.rb', line 83

def publish_dir
    return get_generate_info("publish_dir")
end

#root_templateObject



119
120
121
# File 'lib/markdown_site/config.rb', line 119

def root_template
    return get_template_info("root_template")
end

#srcObject



47
48
49
# File 'lib/markdown_site/config.rb', line 47

def src
    get_base_info("src")
end

#titleObject



43
44
45
# File 'lib/markdown_site/config.rb', line 43

def title
    get_base_info("title")
end