Class: NeverdoneCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- NeverdoneCommand
show all
- Defined in:
- bin/nd
Instance Method Summary
collapse
Instance Method Details
#authenticate(force = false) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'bin/nd', line 52
def authenticate(force=false)
@config = Neverdone::Config.load
auth = {
:user_store_url => @config[:user_store_url],
:consumer_key => Neverdone::CONSUMER_KEY,
:consumer_secret => Neverdone::CONSUMER_SECRET,
:access_token => @config[:access_token]
}
if not @config[:username]
auth[:username] = ask("Evernote username: ")
else
auth[:username] = @config[:username]
end
if not @config[:password]
auth[:password] = ask("Evernote password: ") { |q| q.echo = false }
puts "\nConfiguration stored at #{ENV['HOME']}/.neverdone.conf\n\n"
else
auth[:password] = @config[:password]
end
Everton::Remote.authenticate auth, force
@config[:access_token] = Everton::Remote.access_token
@config[:username] = auth[:username]
@config[:password] = auth[:password]
@config.save
end
|
#execute ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'bin/nd', line 31
def execute
begin
authenticate
@notebook = Everton::Notebook.find('Neverdone Todo')
rescue Evernote::EDAM::Error::EDAMSystemException
authenticate force=true
@notebook = Everton::Notebook.find('Neverdone Todo')
rescue Evernote::EDAM::Error::EDAMUserException
authenticate force=true
@notebook = Everton::Notebook.find('Neverdone Todo')
end
if not @notebook
print "Neverdone Todo notebook not found, creating..."
@notebook = Everton::Notebook.create('Neverdone Todo')
puts ' Done'
end
lazy_execute
end
|