everton 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/everton.rb +28 -9
- metadata +4 -4
data/lib/everton.rb
CHANGED
@@ -17,30 +17,49 @@ end
|
|
17
17
|
|
18
18
|
module Everton
|
19
19
|
|
20
|
-
VERSION = '0.1.
|
20
|
+
VERSION = '0.1.3'
|
21
21
|
|
22
22
|
class Remote
|
23
23
|
|
24
24
|
class << self
|
25
|
-
attr_reader :user_store, :note_store, :
|
25
|
+
attr_reader :user_store, :note_store, :shard_id
|
26
|
+
attr_accessor :access_token
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
# @config parameter format
|
30
|
+
#
|
31
|
+
# :username
|
32
|
+
# :password
|
33
|
+
# :access_token
|
34
|
+
# :user_store_url
|
35
|
+
#
|
36
|
+
# if @force is true, authenticate even if access_token found
|
37
|
+
#
|
38
|
+
def self.authenticate config, force=false
|
29
39
|
if config.is_a? Hash
|
30
40
|
cfg = config
|
31
41
|
else
|
32
42
|
cfg = YAML.load_file config
|
33
43
|
end
|
34
|
-
|
44
|
+
@user_store = Evernote::UserStore.new(cfg[:user_store_url], cfg)
|
45
|
+
# We have a token, assume it's valid
|
46
|
+
if not force and not config[:access_token].nil? and not config[:username].nil?
|
47
|
+
@user = config[:username]
|
48
|
+
@access_token = config[:access_token]
|
49
|
+
@shard_id = @access_token.split(':').first.split('=').last
|
50
|
+
else
|
35
51
|
auth_result = user_store.authenticate
|
36
52
|
@user = auth_result.user
|
37
53
|
@access_token = auth_result.authenticationToken
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
54
|
+
@shard_id = @user.shardId
|
55
|
+
end
|
56
|
+
uri = URI.parse cfg[:user_store_url]
|
57
|
+
host = uri.host
|
58
|
+
scheme = uri.scheme
|
59
|
+
@note_store_url = "#{scheme}://#{host}/edam/note/#{@shard_id}"
|
60
|
+
@note_store = Evernote::NoteStore.new(@note_store_url)
|
43
61
|
end
|
62
|
+
|
44
63
|
end
|
45
64
|
|
46
65
|
class ::Evernote::EDAM::Type::Note
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: everton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sergio Rubio
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|