class RecordLoader::RecordFile
A RecordFile
is a wrapper to handle categorization of the yaml files used by RecordLoader
Constants
- DEV_IDENTIFIER
@return [String] The tag immediately prior to the extension that flags a
file as being development specific. For example a file names users.dev.yaml
- EXTENSION
@return [String] Extension of the yaml files to load.
- WIP_IDENTIFIER
@return [String] The tag immediately prior to the extension that flags a
file as being work-in-progress. For example a file names new_feature.wip.yaml
Public Class Methods
Create a RecordFile
wrapper for a given file @param record_file [Pathname] The path of the file to wrap
# File lib/record_loader/record_file.rb, line 20 def initialize(record_file) @record_file = record_file end
Public Instance Methods
Returns the name of the file, minus the extension and dev/wip flags @return [String] The name of the file eg. “000_purpose”
# File lib/record_loader/record_file.rb, line 26 def basename without_extension.delete_suffix(WIP_IDENTIFIER) .delete_suffix(DEV_IDENTIFIER) end
Returns true if the file is development environment specific ie. ends in .dev.yml @return [Boolean] True if the file is a dev file
# File lib/record_loader/record_file.rb, line 34 def dev? without_extension.end_with?(DEV_IDENTIFIER) end
Returns true if the file is flagged as WIP ie. ends in .wip.yml @return [Boolean] True if the file is a wip file
# File lib/record_loader/record_file.rb, line 41 def wip? without_extension.end_with?(WIP_IDENTIFIER) end
Private Instance Methods
# File lib/record_loader/record_file.rb, line 47 def without_extension @record_file.basename(EXTENSION).to_s end