Module: Opdotenv::FormatInferrer
- Defined in:
- lib/opdotenv/format_inferrer.rb
Overview
Shared module for format inference from item/field names
Constant Summary collapse
- DOTENV_PATTERN =
/\.env\.?/- JSON_EXTENSIONS =
[".json"].freeze
- YAML_EXTENSIONS =
[".yaml", ".yml"].freeze
Class Method Summary collapse
Class Method Details
.infer_from_name(name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/opdotenv/format_inferrer.rb', line 10 def infer_from_name(name) return :dotenv if name.match?(DOTENV_PATTERN) return :json if JSON_EXTENSIONS.any? { |ext| name.end_with?(ext) } return :yaml if YAML_EXTENSIONS.any? { |ext| name.end_with?(ext) } nil end |
.matches_format_pattern?(name) ⇒ Boolean
18 19 20 |
# File 'lib/opdotenv/format_inferrer.rb', line 18 def matches_format_pattern?(name) !infer_from_name(name).nil? end |