Class: Jekyll::Graph::PluginConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll-graph/config.rb

Constant Summary collapse

ASSETS_KEY =
"assets"
ATTRS_KEY =
"attrs"
CONFIG_KEY =
"graph"
ENABLED_KEY =
"enabled"
EXCLUDE_KEY =
"exclude"
"links"
NET_WEB_KEY =

deprecated: ‘net_web’ -> ‘web’

"net_web"
PATH_KEY =
"path"
SCRIPTS_KEY =
"scripts"
TREE_KEY =
"tree"
WEB_KEY =
"web"

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ PluginConfig

Returns a new instance of PluginConfig.



21
22
23
24
25
# File 'lib/jekyll-graph/config.rb', line 21

def initialize(config)
  @config ||= config
  @testing ||= config['testing'] if config.keys.include?('testing')
  Jekyll.logger.debug("Excluded jekyll types in graph: ", option(EXCLUDE_KEY)) unless disabled?
end

Instance Method Details

#baseurlObject

attrs



109
110
111
# File 'lib/jekyll-graph/config.rb', line 109

def baseurl
  return @config['baseurl']
end

#disabled?Boolean

descriptors

Returns:

  • (Boolean)


29
30
31
# File 'lib/jekyll-graph/config.rb', line 29

def disabled?
  return option(ENABLED_KEY) == false
end

#disabled_net_web?Boolean

deprecated: ‘net_web’ -> ‘web’

Returns:

  • (Boolean)


38
39
40
# File 'lib/jekyll-graph/config.rb', line 38

def disabled_net_web?
  return option_web(ENABLED_KEY) == false
end

#disabled_tree?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/jekyll-graph/config.rb', line 33

def disabled_tree?
  return option_tree(ENABLED_KEY) == false
end

#disabled_web?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/jekyll-graph/config.rb', line 42

def disabled_web?
  option_web(ENABLED_KEY) == false
end

#excluded?(type) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/jekyll-graph/config.rb', line 46

def excluded?(type)
  return false unless option(EXCLUDE_KEY)
  return option(EXCLUDE_KEY).include?(type.to_s)
end

#has_custom_assets_path?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/jekyll-graph/config.rb', line 51

def has_custom_assets_path?
  return option_path(ASSETS_KEY)
end

#has_custom_scripts_path?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/jekyll-graph/config.rb', line 55

def has_custom_scripts_path?
  return option_path(SCRIPTS_KEY)
end

#option(key) ⇒ Object

options



71
72
73
# File 'lib/jekyll-graph/config.rb', line 71

def option(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][key]
end

#option_path(key) ⇒ Object



75
76
77
# File 'lib/jekyll-graph/config.rb', line 75

def option_path(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][PATH_KEY] && @config[CONFIG_KEY][PATH_KEY][key]
end

#option_tree(key) ⇒ Object



103
104
105
# File 'lib/jekyll-graph/config.rb', line 103

def option_tree(key)
  @config[CONFIG_KEY] && @config[CONFIG_KEY][TREE_KEY] && @config[CONFIG_KEY][TREE_KEY][key]
end

#option_web(key) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/jekyll-graph/config.rb', line 79

def option_web(key)
  if @config[CONFIG_KEY]
    # deprecated: 'net_web' -> 'web'
    if @config[CONFIG_KEY][NET_WEB_KEY]
      return @config[CONFIG_KEY][NET_WEB_KEY][key]
    end
    if @config[CONFIG_KEY][WEB_KEY]
      return @config[CONFIG_KEY][WEB_KEY][key]
    end
  end
end

#option_web_exclude(key) ⇒ Object



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/jekyll-graph/config.rb', line 91

def option_web_exclude(key)
  if @config[CONFIG_KEY]
    # deprecated: 'net_web' -> 'web'
    if @config[CONFIG_KEY][NET_WEB_KEY] && @config[CONFIG_KEY][NET_WEB_KEY][EXCLUDE_KEY]
      return @config[CONFIG_KEY][NET_WEB_KEY][EXCLUDE_KEY][key]
    end
    if @config[CONFIG_KEY][WEB_KEY]&& @config[CONFIG_KEY][WEB_KEY][EXCLUDE_KEY]
      return @config[CONFIG_KEY][WEB_KEY][EXCLUDE_KEY][key]
    end
  end
end

#path_assetsObject



113
114
115
# File 'lib/jekyll-graph/config.rb', line 113

def path_assets
  return has_custom_assets_path? ? option_path(ASSETS_KEY) : "/assets"
end

#path_scriptsObject



117
118
119
# File 'lib/jekyll-graph/config.rb', line 117

def path_scripts
  return has_custom_scripts_path? ? File.join(path_assets, option_path(SCRIPTS_KEY)) : File.join(path_assets, "js")
end

#testingObject



121
122
123
# File 'lib/jekyll-graph/config.rb', line 121

def testing
  return @testing
end

#use_attrs?Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/jekyll-graph/config.rb', line 59

def use_attrs?
  return true if option_web_exclude(ATTRS_KEY).nil?
  return !option_web_exclude(ATTRS_KEY)
end

#use_links?Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/jekyll-graph/config.rb', line 64

def use_links?
  return true if option_web_exclude(LINKS_KEY).nil?
  return !option_web_exclude(LINKS_KEY)
end