Class: JekyllAdmin::Directory
- Inherits:
-
Object
- Object
- JekyllAdmin::Directory
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-admin/directory.rb
Constant Summary
Constants included from APIable
APIable::API_SCAFFOLD, APIable::CONTENT_FIELDS
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#splat ⇒ Object
readonly
Returns the value of attribute splat.
Instance Method Summary collapse
- #directories ⇒ Object
- #http_url ⇒ Object
-
#initialize(path, base:, splat:, content_type:) ⇒ Directory
constructor
Parameters: path - The full path of the directory at which its entries will be listed.
- #relative_path ⇒ Object
- #resource_path ⇒ Object (also: #url)
- #to_liquid ⇒ Object
Methods included from APIable
Methods included from URLable
Constructor Details
#initialize(path, base:, splat:, content_type:) ⇒ Directory
Parameters:
path - The full path of the directory at which its entries will be listed.
Named parameters:
base: - The full path to the directory from source.
splat: - The requested directory path relative to content namespace.
content_type: - The type of the requested directory entries. Corresponds to
the resources' API namespace.
27 28 29 30 31 32 |
# File 'lib/jekyll-admin/directory.rb', line 27 def initialize(path, base:, splat:, content_type:) @path = Pathname.new path @base = Pathname.new base @splat = Pathname.new splat @content_type = content_type end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
8 9 10 |
# File 'lib/jekyll-admin/directory.rb', line 8 def base @base end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/jekyll-admin/directory.rb', line 8 def content_type @content_type end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/jekyll-admin/directory.rb', line 8 def path @path end |
#splat ⇒ Object (readonly)
Returns the value of attribute splat.
8 9 10 |
# File 'lib/jekyll-admin/directory.rb', line 8 def splat @splat end |
Instance Method Details
#directories ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jekyll-admin/directory.rb', line 60 def directories path.entries.map do |entry| next if DOT_DIRECTORIES.include? entry.to_s next unless path.join(entry).directory? self.class.new( path.join(entry), :base => base, :content_type => content_type, :splat => splat ) end.compact! end |
#http_url ⇒ Object
56 57 58 |
# File 'lib/jekyll-admin/directory.rb', line 56 def http_url nil end |
#relative_path ⇒ Object
43 44 45 |
# File 'lib/jekyll-admin/directory.rb', line 43 def relative_path @relative_path ||= path.relative_path_from(base).to_s end |
#resource_path ⇒ Object Also known as: url
47 48 49 50 51 52 53 |
# File 'lib/jekyll-admin/directory.rb', line 47 def resource_path if RESOURCE_TYPES.include?(content_type) "/#{content_type}/#{splat}/#{name}" else "/collections/#{content_type}/entries/#{splat}/#{name}" end end |
#to_liquid ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/jekyll-admin/directory.rb', line 34 def to_liquid { "name" => name, "modified_time" => modified_time, "path" => relative_path, "type" => "directory", } end |