Class: Jekyll::Site
- Inherits:
-
Object
- Object
- Jekyll::Site
- Defined in:
- lib/jekyll_constant_values.rb
Instance Attribute Summary collapse
-
#constants_file ⇒ Object
Returns the value of attribute constants_file.
Instance Method Summary collapse
- #constants_file_path ⇒ Object
- #process ⇒ Object
- #process_constants ⇒ Object
- #valid_file?(const_file) ⇒ Boolean
Instance Attribute Details
#constants_file ⇒ Object
Returns the value of attribute constants_file.
5 6 7 |
# File 'lib/jekyll_constant_values.rb', line 5 def constants_file @constants_file end |
Instance Method Details
#constants_file_path ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/jekyll_constant_values.rb', line 21 def constants_file_path # Check if a custom name for constants file is defined if config['constants'].nil? '_data/constants.yml' # Default constants file else '_data/' + config['constants'] + '.yml' # Custom constants file end end |
#process ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/jekyll_constant_values.rb', line 8 def process # Get the constants file path const_file = constants_file_path # Exit the process if not valid file exit unless valid_file?(const_file) # Assign the path if valid self.constants_file ||= const_file # Show info message puts "Using file #{const_file} for constant values" process_constants end |
#process_constants ⇒ Object
6 |
# File 'lib/jekyll_constant_values.rb', line 6 alias :process_constants :process |
#valid_file?(const_file) ⇒ Boolean
30 31 32 33 34 35 36 37 |
# File 'lib/jekyll_constant_values.rb', line 30 def valid_file?(const_file) # Check if the constants file exist unless File.exist?(const_file) puts "No such file or directory #{const_file}" return false end true end |