rypple 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rypple/base.rb +28 -24
- data/lib/rypple/version.rb +1 -1
- metadata +3 -3
data/lib/rypple/base.rb
CHANGED
@@ -12,44 +12,25 @@ module Rypple
|
|
12
12
|
:dropbox => {
|
13
13
|
:root => '/',
|
14
14
|
:sync => ['**'],
|
15
|
-
:access_type => :app_folder,
|
16
15
|
}
|
17
16
|
}
|
18
17
|
|
19
|
-
DropboxKeyFile = "dropbox_session.
|
20
|
-
RyppleConfigFile = "rypple.
|
18
|
+
DropboxKeyFile = "dropbox_session.yml"
|
19
|
+
RyppleConfigFile = "rypple.yml"
|
21
20
|
|
22
21
|
def Rypple.connectToDropbox(path)
|
22
|
+
session = nil
|
23
|
+
dropboxKeys = {:access_type => :app_folder}
|
23
24
|
dropConf = File.join(path, DropboxKeyFile)
|
24
25
|
#Load Dropbox API dropboxKeys from file, if applicable.
|
25
26
|
if File.exists?(dropConf)
|
26
27
|
dropboxKeys = YAML::load(File.read(dropConf))
|
27
|
-
else
|
28
|
-
puts "A Dropbox API key/secret is required for accessing your sync files."
|
29
|
-
puts "You can visit https://www.dropbox.com/developers/apps to generate these."
|
30
|
-
print "Please enter your Dropbox API key:"
|
31
|
-
dropboxKeys = {}
|
32
|
-
dropboxKeys[:key] = gets.chomp!
|
33
|
-
print "Please enter your Dropbox API secret:"
|
34
|
-
dropboxKeys[:secret] = gets.chomp!
|
35
|
-
print "Should this API access be used in sandbox mode? (Y/n):"
|
36
|
-
answer = gets.downcase.chomp
|
37
|
-
if !answer.empty? and answer == 'n'
|
38
|
-
dropboxKeys[:access_type]= :dropbox
|
39
|
-
end
|
40
28
|
end
|
41
29
|
|
42
|
-
session = nil
|
43
|
-
|
44
30
|
if dropboxKeys.has_key?(:session)
|
45
31
|
session = DropboxSession.deserialize(dropboxKeys[:session])
|
46
32
|
else
|
47
|
-
session =
|
48
|
-
session.get_request_token
|
49
|
-
authorize_url = session.get_authorize_url
|
50
|
-
puts "Visit #{authorize_url} to log in to Dropbox. Hit enter when you have done this."
|
51
|
-
gets
|
52
|
-
session.get_access_token
|
33
|
+
dropboxKeys[:access], session = Rypple.buildLoginSession()
|
53
34
|
end
|
54
35
|
|
55
36
|
if session.nil?
|
@@ -90,6 +71,29 @@ module Rypple
|
|
90
71
|
return conf
|
91
72
|
end
|
92
73
|
|
74
|
+
def Rypple.buildLoginSession()
|
75
|
+
puts "A Dropbox API key/secret is required for accessing your sync files."
|
76
|
+
puts "You can visit https://www.dropbox.com/developers/apps to generate these."
|
77
|
+
print "Please enter your Dropbox API key:"
|
78
|
+
key = gets.chomp!
|
79
|
+
print "Please enter your Dropbox API secret:"
|
80
|
+
secret = gets.chomp!
|
81
|
+
access = :app_folder
|
82
|
+
print "Should this API access be used in sandbox mode? (Y/n):"
|
83
|
+
answer = gets.downcase.chomp
|
84
|
+
if !answer.empty? and answer == 'n'
|
85
|
+
access = :dropbox
|
86
|
+
end
|
87
|
+
|
88
|
+
session = DropboxSession.new(key, secret)
|
89
|
+
session.get_request_token
|
90
|
+
authorize_url = session.get_authorize_url
|
91
|
+
puts "Visit #{authorize_url} to log in to Dropbox. Hit enter when you have done this."
|
92
|
+
gets
|
93
|
+
session.get_access_token
|
94
|
+
return access, session
|
95
|
+
end
|
96
|
+
|
93
97
|
def Rypple.saveDropbox(keys, path)
|
94
98
|
dropConfig = File.join(path, DropboxKeyFile)
|
95
99
|
File.open(dropConfig, 'w') do|file|
|
data/lib/rypple/version.rb
CHANGED
metadata
CHANGED