Class: Rnote::AuthCache

Inherits:
Object
  • Object
show all
Includes:
ConfigFile
Defined in:
lib/rnote/persister.rb

Instance Method Summary collapse

Methods included from ConfigFile

#modify_config, #read_config

Constructor Details

#initializeAuthCache

Returns a new instance of AuthCache.



76
77
78
# File 'lib/rnote/persister.rb', line 76

def initialize
  @config_file = AUTH_FILE
end

Instance Method Details

#after_vivifyObject



92
93
94
# File 'lib/rnote/persister.rb', line 92

def after_vivify
  FileUtils.chmod 0600, AUTH_FILE
end

#forget_developer_tokenObject



127
128
129
130
131
# File 'lib/rnote/persister.rb', line 127

def forget_developer_token
  modify_config do |config|
    config.delete(:developer_token)
  end
end

#forget_sandboxObject



188
189
190
191
192
# File 'lib/rnote/persister.rb', line 188

def forget_sandbox
  modify_config do |config|
    config.delete(:sandbox)
  end
end

#forget_user_tokenObject



115
116
117
118
119
# File 'lib/rnote/persister.rb', line 115

def forget_user_token
  modify_config do |config|
    config.delete(:user_token)
  end
end

#forget_usernameObject



121
122
123
124
125
# File 'lib/rnote/persister.rb', line 121

def forget_username
  modify_config do |config|
    config.delete(:username)
  end
end

#get_consumer_keyObject



157
158
159
160
161
# File 'lib/rnote/persister.rb', line 157

def get_consumer_key
  read_config do |config|
    config[:consumer_key]
  end
end

#get_consumer_secretObject



163
164
165
166
167
# File 'lib/rnote/persister.rb', line 163

def get_consumer_secret
  read_config do |config|
    config[:consumer_secret]
  end
end

#get_developer_tokenObject



145
146
147
148
149
# File 'lib/rnote/persister.rb', line 145

def get_developer_token
  read_config do |config|
    config[:developer_token]
  end
end

#get_sandboxObject



151
152
153
154
155
# File 'lib/rnote/persister.rb', line 151

def get_sandbox
  read_config do |config|
    config[:sandbox]
  end
end

#get_user_tokenObject



133
134
135
136
137
# File 'lib/rnote/persister.rb', line 133

def get_user_token
  read_config do |config|
    config[:user_token]
  end
end

#get_usernameObject



139
140
141
142
143
# File 'lib/rnote/persister.rb', line 139

def get_username
  read_config do |config|
    config[:username]
  end
end

#headerObject



80
81
82
83
84
85
86
87
88
89
90
# File 'lib/rnote/persister.rb', line 80

def header
  <<EOF
  
#
# This file is auto-generated and shouldn't be edited by hand
#
# deleting this file is akin to logging out.
#

EOF
end

#persist_consumer_key(consumer_key) ⇒ Object



176
177
178
179
180
# File 'lib/rnote/persister.rb', line 176

def persist_consumer_key(consumer_key)
  modify_config do|config|
    config[:consumer_key] = consumer_key
  end
end

#persist_consumer_secret(consumer_secret) ⇒ Object



182
183
184
185
186
# File 'lib/rnote/persister.rb', line 182

def persist_consumer_secret(consumer_secret)
  modify_config do |config|
    config[:consumer_secret] = consumer_secret
  end
end

#persist_developer_token(developer_token) ⇒ Object



109
110
111
112
113
# File 'lib/rnote/persister.rb', line 109

def persist_developer_token(developer_token)
  modify_config do |config|
    config[:developer_token] = developer_token
  end
end

#persist_sandbox(sandbox) ⇒ Object



169
170
171
172
173
174
# File 'lib/rnote/persister.rb', line 169

def persist_sandbox(sandbox)
  raise if ! sandbox and RNOTE_SANDBOX_ONLY
  modify_config do |config|
    config[:sandbox] = sandbox
  end
end

#persist_user_token(user_token) ⇒ Object



103
104
105
106
107
# File 'lib/rnote/persister.rb', line 103

def persist_user_token(user_token)
  modify_config do |config|
    config[:user_token] = user_token
  end
end

#persist_username(username) ⇒ Object



96
97
98
99
100
# File 'lib/rnote/persister.rb', line 96

def persist_username(username)
  modify_config do |config|
    config[:username] = username
  end
end