Skip to content

Commit

Permalink
Add the scanners
Browse files Browse the repository at this point in the history
  • Loading branch information
waferbaby committed Jan 19, 2024
1 parent cc76daa commit 6eeda9f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/dimples/scanner/pages.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

module Dimples
module Scanner
# A helper class for scanning a directory of page files.
class Pages
def self.scan(source_path)
Dir[File.join(source_path, '**', '*.*')].map { |path| Dimples::Page.new(path: path) }
end
end
end
end
13 changes: 13 additions & 0 deletions lib/dimples/scanner/posts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module Dimples
module Scanner
# A helper class for scanning a directory of post files.
class Posts
def self.scan(source_path)
posts = Dir[File.join(source_path, '**', '*.*')].map { |path| Dimples::Post.new(path: path) }
posts.sort_by!(&:date).reverse!
end
end
end
end
16 changes: 16 additions & 0 deletions lib/dimples/scanner/templates.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

module Dimples
module Scanner
# A helper class for scanning a directory of template files.
class Templates
def self.scan(source_path)
{}.tap do |templates|
Dir[File.join(source_path, '**', '*.*')].each do |path|
templates[File.basename(path, '.erb')] = Dimples::Template.new(path: path)
end
end
end
end
end
end

0 comments on commit 6eeda9f

Please sign in to comment.