123456789_123456789_123456789_123456789_123456789_

Module: Rails::Command::CredentialsCommand::Diffing

Do not use. This module is for internal use only.
Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: railties/lib/rails/commands/credentials/credentials_command/diffing.rb

Constant Summary

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#diffing_driver_configured?Boolean (readonly, private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 41

def diffing_driver_configured?
  system "git config --get diff.rails_credentials.textconv", out: File::NULL
end

#enrolled_in_credentials_diffing?Boolean (readonly, private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 37

def enrolled_in_credentials_diffing?
  gitattributes.file? && gitattributes.read.include?(GITATTRIBUTES_ENTRY)
end

Instance Method Details

#configure_diffing_driver (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 45

def configure_diffing_driver
  system "git config diff.rails_credentials.textconv '#{executable(:diff)}'"
  say "Configured Git diff driver for credentials."
end

#disenroll_project_from_credentials_diffing

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 21

def disenroll_project_from_credentials_diffing
  if enrolled_in_credentials_diffing?
    gitattributes.write(gitattributes.read.gsub(GITATTRIBUTES_ENTRY, ""))
    gitattributes.delete if gitattributes.empty?

    say "Disenrolled project from credentials file diffing!"
  else
    say "Project is not enrolled in credentials file diffing."
  end
end

#enroll_project_in_credentials_diffing

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 9

def enroll_project_in_credentials_diffing
  if enrolled_in_credentials_diffing?
    say "Project is already enrolled in credentials file diffing."
  else
    gitattributes.write(GITATTRIBUTES_ENTRY, mode: "a")

    say "Enrolled project in credentials file diffing!"
    say ""
    say "Rails will configure the Git diff driver for credentials when running `#{executable(:edit)}`. See `#{executable(:help)}` for more information."
  end
end

#ensure_diffing_driver_is_configured

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 32

def ensure_diffing_driver_is_configured
  configure_diffing_driver if enrolled_in_credentials_diffing? && !diffing_driver_configured?
end

#gitattributes (private)

[ GitHub ]

  
# File 'railties/lib/rails/commands/credentials/credentials_command/diffing.rb', line 50

def gitattributes
  @gitattributes ||= (Rails::Command.root || Pathname.pwd).join(".gitattributes")
end