Class: RecordLoader::RecordFile

Inherits:
Object
  • Object
show all
Defined in:
lib/record_loader/record_file.rb

Overview

A RecordFile is a wrapper to handle categorization of the yaml files used by RecordLoader

Constant Summary collapse

EXTENSION =

Returns Extension of the yaml files to load.

Returns:

  • (String)

    Extension of the yaml files to load.

'.yml'
DEV_IDENTIFIER =

Returns The tag immediately prior to the extension that flags a file as being development specific. For example a file names users.dev.yaml.

Returns:

  • (String)

    The tag immediately prior to the extension that flags a file as being development specific. For example a file names users.dev.yaml

'.dev'
WIP_IDENTIFIER =

Returns 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.

Returns:

  • (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

'.wip'

Instance Method Summary collapse

Constructor Details

#initialize(record_file) ⇒ RecordFile

Create a RecordFile wrapper for a given file

Parameters:

  • record_file (Pathname)

    The path of the file to wrap



20
21
22
# File 'lib/record_loader/record_file.rb', line 20

def initialize(record_file)
  @record_file = record_file
end

Instance Method Details

#basenameString

Returns the name of the file, minus the extension and dev/wip flags

Returns:

  • (String)

    The name of the file eg. “000_purpose”



26
27
28
29
# File 'lib/record_loader/record_file.rb', line 26

def basename
  without_extension.delete_suffix(WIP_IDENTIFIER)
                   .delete_suffix(DEV_IDENTIFIER)
end

#dev?Boolean

Returns true if the file is development environment specific ie. ends in .dev.yml

Returns:

  • (Boolean)

    True if the file is a dev file



34
35
36
# File 'lib/record_loader/record_file.rb', line 34

def dev?
  without_extension.end_with?(DEV_IDENTIFIER)
end

#wip?Boolean

Returns true if the file is flagged as WIP ie. ends in .wip.yml

Returns:

  • (Boolean)

    True if the file is a wip file



41
42
43
# File 'lib/record_loader/record_file.rb', line 41

def wip?
  without_extension.end_with?(WIP_IDENTIFIER)
end