Class: Jekyll::LiveSite::ContentFile
- Inherits:
-
Object
- Object
- Jekyll::LiveSite::ContentFile
- Defined in:
- lib/jekyll/live_site.rb
Constant Summary collapse
- TYPE_MAPPING =
{ '_layouts' => :layout, '_includes' => :include, '_posts' => :post }
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #deep_check ⇒ Object
-
#initialize(path, source, dest, allowed_checker = nil) ⇒ ContentFile
constructor
A new instance of ContentFile.
- #relative_dir ⇒ Object
- #type ⇒ Object
- #valid? ⇒ Boolean
- #valid_dir?(path) ⇒ Boolean
Constructor Details
#initialize(path, source, dest, allowed_checker = nil) ⇒ ContentFile
Returns a new instance of ContentFile.
90 91 92 93 94 95 96 97 98 |
# File 'lib/jekyll/live_site.rb', line 90 def initialize path, source, dest, allowed_checker = nil @path = path @source = source @destination = dest @allowed_checker = allowed_checker || lambda {|f| true } @dir, @name = File.split @path @type = :file @valid_dir = nil end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
81 82 83 |
# File 'lib/jekyll/live_site.rb', line 81 def dir @dir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
81 82 83 |
# File 'lib/jekyll/live_site.rb', line 81 def name @name end |
#path ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute path.
81 82 83 |
# File 'lib/jekyll/live_site.rb', line 81 def path @path end |
Instance Method Details
#deep_check ⇒ Object
115 116 117 118 |
# File 'lib/jekyll/live_site.rb', line 115 def deep_check return @valid_dir unless @valid_dir.nil? @valid_dir = valid_dir? self.dir end |
#relative_dir ⇒ Object
105 106 107 |
# File 'lib/jekyll/live_site.rb', line 105 def relative_dir @relative_dir ||= self.dir.sub(File.join(@source, ''), '') end |
#type ⇒ Object
100 101 102 103 |
# File 'lib/jekyll/live_site.rb', line 100 def type deep_check @type end |
#valid? ⇒ Boolean
109 110 111 112 113 |
# File 'lib/jekyll/live_site.rb', line 109 def valid? !File.symlink? path and @allowed_checker.call(name) and deep_check end |
#valid_dir?(path) ⇒ Boolean
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/jekyll/live_site.rb', line 120 def valid_dir? path if path == '/' false elsif path == @destination false elsif path == @source true elsif File.symlink? path false else dir, name = File.split path if type = TYPE_MAPPING[name] @type = type elsif !@allowed_checker.call(name) return false end valid_dir? dir end end |