Class: Hanamimastery::CLI::Transformations::Touch

Inherits:
Object
  • Object
show all
Defined in:
lib/hanamimastery/cli/transformations/touch.rb

Constant Summary collapse

PATTERN =
/^modifiedAt\:[[:space:]]"\d{4}-\d{2}-\d{2}"$/

Instance Method Summary collapse

Instance Method Details

#call(content, timestamp: nil) ⇒ Object

Updates the modifiedAt with the passed date



11
12
13
14
15
16
17
# File 'lib/hanamimastery/cli/transformations/touch.rb', line 11

def call(content, timestamp: nil)
  timestamp ||= Time.now
  content.gsub(
    PATTERN,
    %(modifiedAt: "#{timestamp.strftime("%Y-%M-%d")}")
  )
end