lib/imap/backup/configuration/store.rb in imap-backup-1.2.2 vs lib/imap/backup/configuration/store.rb in imap-backup-1.2.3
- old
+ new
@@ -1,18 +1,17 @@
-# encoding: utf-8
-require 'json'
+require "json"
module Imap::Backup
module Configuration; end
class Configuration::Store
- CONFIGURATION_DIRECTORY = File.expand_path('~/.imap-backup')
+ CONFIGURATION_DIRECTORY = File.expand_path("~/.imap-backup")
attr_reader :pathname
def self.default_pathname
- File.join(CONFIGURATION_DIRECTORY, 'config.json')
+ File.join(CONFIGURATION_DIRECTORY, "config.json")
end
def self.exist?(pathname = default_pathname)
File.exist?(pathname)
end
@@ -27,11 +26,11 @@
def save
mkdir_private path
remove_modified_flags
remove_deleted_accounts
- File.open(pathname, 'w') { |f| f.write(JSON.pretty_generate(data)) }
+ File.open(pathname, "w") { |f| f.write(JSON.pretty_generate(data)) }
FileUtils.chmod 0600, pathname
end
def accounts
data[:accounts]
@@ -54,13 +53,13 @@
def data
return @data if @data
if File.exist?(pathname)
Utils.check_permissions pathname, 0600
contents = File.read(pathname)
- @data = JSON.parse(contents, :symbolize_names => true)
+ @data = JSON.parse(contents, symbolize_names: true)
else
- @data = {:accounts => []}
+ @data = {accounts: []}
end
@data[:debug] = false unless @data.include?(:debug)
@data[:debug] = false unless [true, false].include?(@data[:debug])
@data
end
@@ -72,10 +71,10 @@
def remove_deleted_accounts
accounts.reject! { |a| a[:delete] }
end
def mkdir_private(path)
- if ! File.directory?(path)
+ if !File.directory?(path)
FileUtils.mkdir path
end
if Utils::stat(path) != 0700
FileUtils.chmod 0700, path
end