module Conf
Constants
- ADD_URL
- AUTH_URL
- GET_URL
- OAUTH_AUTH_URL
- OAUTH_URL
- SEND_URL
Public Instance Methods
config()
click to toggle source
# File lib/pocketbeuter/conf.rb, line 11 def config @config ||= {} end
default_config()
click to toggle source
# File lib/pocketbeuter/conf.rb, line 19 def default_config config[:dir] = File.expand_path('~/.pocketbeuter') config[:file] = config[:dir] + '/config' config[:cache] = config[:dir] + '/cache' end
init()
click to toggle source
# File lib/pocketbeuter/conf.rb, line 14 def init load_config GetAccessToken.get_access_token_and_username save_config end
load_config()
click to toggle source
# File lib/pocketbeuter/conf.rb, line 24 def load_config default_config if File.exists?(config[:file]) @config = YAML.load_file(config[:file]) else File.open(config[:file], mode: 'w', perm: 0600).close end end
save_config()
click to toggle source
# File lib/pocketbeuter/conf.rb, line 32 def save_config unless File.exists?(config[:dir]) FileUtils.mkdir_p(config[:dir]) end if File.exists?(config[:file]) File.open(config[:file], 'w') { |f| f.write(config.to_yaml) } else File.open(config[:file], mode: 'w', perm: 0600).close end end