rypple 0.0.2 → 0.0.3

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 +17 -10
  2. data/lib/rypple/version.rb +1 -1
  3. metadata +4 -4
data/lib/rypple/base.rb CHANGED
@@ -26,10 +26,11 @@ module Rypple
26
26
  else
27
27
  puts "A Dropbox API key/secret is required for accessing your sync files."
28
28
  puts "You can visit https://www.dropbox.com/developers/apps to generate these."
29
- puts "Please enter your Dropbox API key"
30
- dropboxKeys['key'] = gets.chomp!
31
- puts "Please enter your Dropbox API secret"
32
- dropboxKeys['secret'] = gets.chomp!
29
+ print "Please enter your Dropbox API key:"
30
+ dropboxKeys = {}
31
+ dropboxKeys[:key] = gets.chomp!
32
+ print "Please enter your Dropbox API secret:"
33
+ dropboxKeys[:secret] = gets.chomp!
33
34
  end
34
35
 
35
36
  session = nil
@@ -83,21 +84,28 @@ module Rypple
83
84
  return conf
84
85
  end
85
86
 
86
- def Rypple.cleanup(conf, keys, path)
87
+ def Rypple.saveConfig(conf, path)
87
88
  dropConfig = File.join(path, DropboxKeyFile)
88
89
  File.open(dropConfig, 'w') do|file|
89
90
  file.puts keys.to_yaml
90
91
  end
92
+ end
91
93
 
94
+ def Rypple.saveDropbox(keys, path)
92
95
  ryppleConf = File.join(path, RyppleConfigFile)
93
96
  File.open(ryppleConf, 'w') do |file|
94
97
  file.puts conf.to_yaml
95
98
  end
96
99
  end
97
100
 
101
+ def Rypple.cleanup(conf, keys, path)
102
+ Rypple.saveConfig(conf, path)
103
+ Rypple.saveDropbox(keys, path)
104
+ end
105
+
98
106
  # Iterates over dropbox directory, returing paths and state hash for each file
99
107
  # oldFileState should be a hash of paths to state hashes, same as return values
100
- def Rypple.walkDropbox(client, path, fileState, oldFileState)
108
+ def Rypple.walkDropbox(client, path, oldFileState)
101
109
  #Here we need to actually sync newest files.
102
110
  begin
103
111
  useState = (!oldFileState.nil? and oldFileState.has_key?(path) and oldFileState[path]["path"] == path)
@@ -114,7 +122,7 @@ module Rypple
114
122
  states["contents"].each{ |xx|
115
123
  useState = (!oldFileState.nil? and oldFileState.has_key?(xx["path"]))
116
124
  old = (useState ? oldFileState[xx["path"]] : nil)
117
- subs = Rypple.walkDropbox(client, xx["path"], fileState, old)
125
+ subs = Rypple.walkDropbox(client, xx["path"], old)
118
126
  if !subs.nil?
119
127
  files.merge!(subs)
120
128
  end
@@ -148,9 +156,8 @@ module Rypple
148
156
 
149
157
  destDir = conf[:destinationDir]
150
158
 
151
- fileState = {}
152
159
  oldFileState = dropboxKeys[:files]
153
- files = Rypple.walkDropbox(client, '/', fileState, oldFileState)
160
+ files = Rypple.walkDropbox(client, '/', oldFileState)
154
161
 
155
162
  if !files.nil?
156
163
  files.keys.each { |x|
@@ -175,7 +182,7 @@ module Rypple
175
182
  }
176
183
  }
177
184
 
178
- dropboxKeys[:files] = Rypple.walkDropbox(client, '/', fileState, {})
185
+ dropboxKeys[:files] = Rypple.walkDropbox(client, '/', {})
179
186
  Rypple.cleanup(conf, dropboxKeys, path)
180
187
 
181
188
  return true
@@ -1,3 +1,3 @@
1
1
  module Rypple
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Ziglar
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-27 00:00:00 Z
18
+ date: 2012-02-28 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: jekyll