module FileHelper

Direct including types

Defined in:

models/file_helper.cr

Instance Method Summary

Instance Method Detail

def all_files : Array(String) #

Get all files from CodeLocator


[View source]
def get_files_by_extension(extension : String) : Array(String) #

Get files filtered by extension (uses cached index for O(1) lookup)


[View source]
def get_files_by_prefix(prefix : String) : Array(String) #

Get files filtered by path prefix


[View source]
def get_files_by_prefix_and_extension(prefix : String, extension : String) : Array(String) #

Get files filtered by both prefix and extension


[View source]
def get_public_dir_files(base_path : String, folder : String) : Array(String) #

Helper to get public directories content from anywhere in the project


[View source]
def get_public_files(base_path : String, anchors : Array(String) = ["shard.yml", "Gemfile"]) : Array(String) #

Get public files (files that should be served as static content)

Returns files that are inside a public/ directory that is the sibling of a manifest file (shard.yml for Crystal, Gemfile for Ruby/Rails). The previous shape matched any */public/* substring under base_path, which had a real false-positive surface: a repo that hosts a Crystal framework fixture alongside an unrelated static site (e.g. a built docs directory at docs/public/) would have every file in the docs site surface as a framework endpoint. The previous fix scoped to shard.yml only, which broke Rails monorepos like App/Gemfile + App/public/secret.htmlApp/public/* no longer surfaced because there was no sibling shard.yml.


[View source]
def populate_channel_with_files(channel : Channel(String)) #

Helper to populate a channel from file list instead of using Dir.glob


[View source]
def populate_channel_with_filtered_files(channel : Channel(String), extension : String) #

Helper to populate a channel with only files matching the given extension


[View source]
def populate_channel_with_filtered_files(channel : Channel(String), extensions : Array(String)) #

Helper to populate a channel with files matching any of the given extensions


[View source]