Module: RailsApiDocs::Config::Loader
- Defined in:
- lib/rails-api-docs/config/loader.rb
Class Method Summary collapse
-
.header(path) ⇒ Object
Returns the leading comment block (“#”-prefixed lines and blank lines at the top of the file).
- .load(path) ⇒ Object
Class Method Details
.header(path) ⇒ Object
Returns the leading comment block (“#”-prefixed lines and blank lines at the top of the file). Used to preserve the auto-generated header — and any user notes they tacked at the top — across re-runs.
20 21 22 23 24 25 26 27 |
# File 'lib/rails-api-docs/config/loader.rb', line 20 def header(path) return "" unless File.exist?(path) File.read(path) .lines .take_while { |line| line.start_with?("#") || line.strip.empty? } .join end |
.load(path) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/rails-api-docs/config/loader.rb', line 10 def load(path) return {} unless File.exist?(path) raw = File.read(path) YAML.safe_load(raw, permitted_classes: [Symbol, Date, Time]) || {} end |