rubocop update and resolutions

This commit is contained in:
Mark Moser 2016-09-11 09:57:55 -05:00
parent 9362f506ee
commit b063f188b9
5 changed files with 23 additions and 9 deletions

View File

@ -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
View File

@ -0,0 +1 @@
2.3.1

View File

@ -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

View File

@ -26,15 +26,25 @@ 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)
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]

View File

@ -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