rypple 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/rypple/base.rb +28 -24
  2. data/lib/rypple/version.rb +1 -1
  3. 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.yaml"
20
- RyppleConfigFile = "rypple.yaml"
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 = DropboxSession.new(dropboxKeys[:key], dropboxKeys[:secret])
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|
@@ -1,3 +1,3 @@
1
1
  module Rypple
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rypple
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Ziglar