rubocop update and resolutions
This commit is contained in:
parent
9362f506ee
commit
b063f188b9
@ -41,7 +41,6 @@ Style/StringLiterals:
|
||||
Metrics/AbcSize:
|
||||
Exclude:
|
||||
- db/migrate/**/*
|
||||
- app/services/crypt_serializer.rb
|
||||
|
||||
Metrics/LineLength:
|
||||
Max: 110
|
||||
@ -54,3 +53,6 @@ Metrics/LineLength:
|
||||
Metrics/MethodLength:
|
||||
Exclude:
|
||||
- db/migrate/*
|
||||
|
||||
Rails:
|
||||
Enabled: true
|
||||
|
1
.ruby_version
Normal file
1
.ruby_version
Normal file
@ -0,0 +1 @@
|
||||
2.3.1
|
@ -32,5 +32,6 @@ end
|
||||
guard :rubocop do
|
||||
watch(/.+\.rb$/)
|
||||
watch(/Rakefile/)
|
||||
watch(/.rubocop.yml/)
|
||||
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
||||
end
|
||||
|
@ -26,18 +26,28 @@ class CryptSerializer
|
||||
raise "Attribute was supposed to be a `String`, but was instead a `#{value.class}`"
|
||||
end
|
||||
|
||||
cipher.encrypt
|
||||
parts = [cipher.random_key, cipher.random_iv, cipher.update(value) + cipher.final]
|
||||
Base64.urlsafe_encode64 Marshal.dump(parts)
|
||||
build_cipher value
|
||||
end
|
||||
|
||||
def decrypt(value)
|
||||
return value if value.nil?
|
||||
|
||||
parts = Marshal.load Base64.urlsafe_decode64(value)
|
||||
cipher.decrypt
|
||||
cipher.key = parts[0]
|
||||
cipher.iv = parts[1]
|
||||
cipher.update(parts[2]) + cipher.final
|
||||
decode_cipher parts
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_cipher value
|
||||
cipher.encrypt
|
||||
parts = [cipher.random_key, cipher.random_iv, cipher.update(value) + cipher.final]
|
||||
Base64.urlsafe_encode64 Marshal.dump(parts)
|
||||
end
|
||||
|
||||
def decode_cipher parts
|
||||
cipher.decrypt
|
||||
cipher.key = parts[0]
|
||||
cipher.iv = parts[1]
|
||||
cipher.update(parts[2]) + cipher.final
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ default: &default
|
||||
host: <%= ENV['mysql_host'] %>
|
||||
username: <%= ENV['mysql_usr'] %>
|
||||
password: <%= ENV['mysql_pwd'] %>
|
||||
socket: /var/run/mysqld/mysqld.sock
|
||||
# socket: /var/run/mysqld/mysqld.sock
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
|
Loading…
Reference in New Issue
Block a user