rnote 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rnote.rb +9 -0
- data/lib/rnote/auth.rb +14 -2
- data/lib/rnote/cmd/login.rb +8 -5
- data/lib/rnote/consumer.rb +3 -0
- data/lib/rnote/converter.rb +1 -1
- data/lib/rnote/find.rb +1 -1
- data/lib/rnote/persister.rb +14 -14
- data/lib/rnote/version.rb +1 -1
- metadata +2 -1
data/lib/rnote.rb
CHANGED
@@ -14,6 +14,15 @@ rescue LoadError
|
|
14
14
|
RNOTE_SANDBOX_ONLY = false
|
15
15
|
end
|
16
16
|
|
17
|
+
# load optional production consumer key
|
18
|
+
begin
|
19
|
+
require_relative 'rnote/consumer'
|
20
|
+
rescue LoadError
|
21
|
+
# ignore
|
22
|
+
PRODUCTION_CONSUMER_KEY = nil
|
23
|
+
PRODUCTION_CONSUMER_SECRET = nil
|
24
|
+
end
|
25
|
+
|
17
26
|
require 'rnote/version'
|
18
27
|
require 'rnote/converter'
|
19
28
|
require 'rnote/persister'
|
data/lib/rnote/auth.rb
CHANGED
@@ -36,13 +36,25 @@ module Rnote
|
|
36
36
|
logout
|
37
37
|
end
|
38
38
|
end
|
39
|
+
|
40
|
+
## Consumer Key and Secret provided in published gem.
|
41
|
+
#
|
42
|
+
# we'll use these if the user doesn't provide their own
|
43
|
+
# we do this check here, instead of in Persister,
|
44
|
+
# so we can verify this is only used in production, not sandbox.
|
45
|
+
#
|
46
|
+
|
47
|
+
consumer_key = @persister.get_consumer_key || ( ! sandbox && PRODUCTION_CONSUMER_KEY )
|
48
|
+
raise 'no consumer key to use, please provide one.' unless consumer_key
|
49
|
+
consumer_secret = @persister.get_consumer_secret || ( ! sandbox && PRODUCTION_CONSUMER_SECRET )
|
50
|
+
raise 'no consumer secret to use, please provide one.' unless consumer_secret
|
39
51
|
|
40
52
|
## Get a user key using these crednetials
|
41
53
|
|
42
54
|
# this client isn't authorized, and can only request authorization. no api calls.
|
43
55
|
auth_client = EvernoteOAuth::Client.new(
|
44
|
-
consumer_key:
|
45
|
-
consumer_secret:
|
56
|
+
consumer_key: consumer_key,
|
57
|
+
consumer_secret: consumer_secret,
|
46
58
|
sandbox: sandbox
|
47
59
|
)
|
48
60
|
|
data/lib/rnote/cmd/login.rb
CHANGED
@@ -42,18 +42,21 @@ command :login do |c|
|
|
42
42
|
puts "login successful using developer key"
|
43
43
|
else
|
44
44
|
# then fall back to using a username and password
|
45
|
+
|
46
|
+
user = options[:user]
|
47
|
+
password = options[:password]
|
45
48
|
|
46
|
-
if
|
49
|
+
if user.nil?
|
47
50
|
answer = ask("Enter your username: ")
|
48
|
-
|
51
|
+
user = answer.chomp
|
49
52
|
end
|
50
53
|
|
51
|
-
if
|
54
|
+
if password.nil?
|
52
55
|
answer = ask("Enter your password: ") { |q| q.echo = 'x' }
|
53
|
-
|
56
|
+
password = answer.chomp
|
54
57
|
end
|
55
58
|
|
56
|
-
$app.auth.login_with_password(
|
59
|
+
$app.auth.login_with_password(user,password, options[:sandbox])
|
57
60
|
|
58
61
|
# test the login with a harmless api call.
|
59
62
|
$app.auth.client.user_store.getUser
|
data/lib/rnote/converter.rb
CHANGED
data/lib/rnote/find.rb
CHANGED
@@ -76,7 +76,7 @@ module Rnote
|
|
76
76
|
def display_results(notes)
|
77
77
|
inc = 1
|
78
78
|
notes.each do |note|
|
79
|
-
puts "#{inc}: #{note.title} - #{note.tagNames.join(', ')}\n#{note.summarize}\n"
|
79
|
+
puts "#{inc}: #{note.title} - #{note.tagNames.join(', ')}\n#{note.summarize}\n\n"
|
80
80
|
inc += 1
|
81
81
|
end
|
82
82
|
end
|
data/lib/rnote/persister.rb
CHANGED
@@ -6,12 +6,20 @@ SEARCH_FILE = RNOTE_HOME + '/search_cache'
|
|
6
6
|
|
7
7
|
=begin
|
8
8
|
|
9
|
-
|
9
|
+
# settings and cache files
|
10
10
|
|
11
|
-
|
11
|
+
These files are all YAML.
|
12
12
|
|
13
|
-
You shouldn't touch the auth or search_cache.
|
14
|
-
|
13
|
+
You shouldn't touch the auth or search_cache. These are auto-generated by the tool.
|
14
|
+
|
15
|
+
When we add user settings they'll be in an 'rnoterc' file. Which you can create and modify at will.
|
16
|
+
But there are no user settings yet.
|
17
|
+
|
18
|
+
# cached values
|
19
|
+
|
20
|
+
consumer key and secret
|
21
|
+
if a consumer key and secret are provided (as happens in the published gem),
|
22
|
+
then it will be used unless one is provided by the user instead.
|
15
23
|
|
16
24
|
=end
|
17
25
|
|
@@ -148,21 +156,13 @@ EOF
|
|
148
156
|
|
149
157
|
def get_consumer_key
|
150
158
|
read_config do |config|
|
151
|
-
|
152
|
-
raise "no consumer key saved"
|
153
|
-
else
|
154
|
-
config[:consumer_key]
|
155
|
-
end
|
159
|
+
config[:consumer_key]
|
156
160
|
end
|
157
161
|
end
|
158
162
|
|
159
163
|
def get_consumer_secret
|
160
164
|
read_config do |config|
|
161
|
-
|
162
|
-
raise "noc consumer secret saved"
|
163
|
-
else
|
164
|
-
config[:consumer_secret]
|
165
|
-
end
|
165
|
+
config[:consumer_secret]
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
data/lib/rnote/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rnote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -192,6 +192,7 @@ files:
|
|
192
192
|
- lib/rnote/cmd/remove.rb
|
193
193
|
- lib/rnote/cmd/show.rb
|
194
194
|
- lib/rnote/cmd/who.rb
|
195
|
+
- lib/rnote/consumer.rb
|
195
196
|
- lib/rnote/converter.rb
|
196
197
|
- lib/rnote/edit.rb
|
197
198
|
- lib/rnote/find.rb
|