class Evertils::Controller::Change
Constants
- CONFIG
- ERROR_MESSAGE
- REQUIRED_TOKEN_GROUPS
Public Instance Methods
token()
click to toggle source
Change
the defined Evernote token
# File lib/evertils/controllers/change.rb, line 11 def token Notify.spit 'Already have your Evernote token? Paste it now:' begin set_evertils_token rescue RuntimeError Notify.error ERROR_MESSAGE rescue Interrupt Notify.error ERROR_MESSAGE end Notify.success('Token saved!') end
Private Instance Methods
overwrite_config_with()
click to toggle source
# File lib/evertils/controllers/change.rb, line 37 def overwrite_config_with File.open(CONFIG, 'w') { |file| file.write(conf.to_yaml) } end
set_evertils_token()
click to toggle source
# File lib/evertils/controllers/change.rb, line 27 def set_evertils_token token = STDIN.gets.chomp conf = YAML.load_file(CONFIG) conf['token'] = token raise unless valid? token overwrite_config_with(conf) end
valid?(token)
click to toggle source
# File lib/evertils/controllers/change.rb, line 41 def valid?(token) token_groups = token.split(':').map do |group| group.split('=').first.to_sym end token_groups == REQUIRED_TOKEN_GROUPS end