Last active
February 24, 2019 13:28
-
-
Save DmytroVasin/78fd084a49950d0f177a8ae1f0b82f46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RuboCop | |
module Cop | |
module CustomCops | |
class TimecopReplacerCop < Cop | |
# ... | |
def autocorrect(arg_pair) | |
date_string = eval(arg_pair.value.source).strftime('%Y-%m-%dT%H:%M:%S%z') | |
new_source = String.new("freezed_time: '#{date_string}'") | |
->(corrector) do | |
corrector.insert_before(arg_pair.source_range, new_source) | |
corrector.remove(arg_pair.source_range) | |
end | |
end | |
# ... | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment