rypple 0.0.1 → 0.0.2

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/bin/rypple ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'rypple'
5
+
6
+ configDir = File.join(ENV["HOME"], '.rypple')
7
+
8
+ if File.exists?(configDir)
9
+ Rypple.sync(configDir)
10
+ end
@@ -1,6 +1,6 @@
1
1
  #!/bin/ruby
2
2
  require 'rubygems'
3
- require 'ripple'
3
+ require 'rypple'
4
4
 
5
5
  baseCGI = <<'eos'
6
6
  #!/usr/bin/ruby
@@ -16,7 +16,7 @@ end
16
16
 
17
17
  require 'cgi'
18
18
  require 'rubygems'
19
- require 'ripple'
19
+ require 'rypple'
20
20
  require 'jekyll'
21
21
 
22
22
  cgi = CGI.new
@@ -24,7 +24,7 @@ cgi = CGI.new
24
24
  puts cgi.header
25
25
 
26
26
  puts "<h1>Rippling . . .</h1>"
27
- if Ripple.sync(configPath)
27
+ if Rypple.sync(configPath)
28
28
  puts "<h1>Generating Static Site</h1>"
29
29
  puts `%%COMMAND #{inDir} #{outDir}`
30
30
  end
@@ -33,38 +33,38 @@ eos
33
33
  updateHTML = <<'eos'
34
34
  <html>
35
35
  <head>
36
- <title>Update Site with Ripple!</title>
36
+ <title>Update Site with Rypple!</title>
37
37
  </head>
38
38
  <body>
39
39
  <h1> Throw a stone into the pond..</h1>
40
40
  <form action="update.cgi" method="POST">
41
- <input type="submit" value="Ripple">
41
+ <input type="submit" value="Rypple">
42
42
  </form>
43
43
  </body>
44
44
  </html>
45
45
  eos
46
46
 
47
47
  htaccess = <<'eos'
48
- AuthName "Ripple Updater"
48
+ AuthName "Rypple Updater"
49
49
  AuthType Basic
50
50
  AuthUserFile %%AUTH_FILE
51
51
  Require valid-user
52
52
  eos
53
53
 
54
- configBase = File.join(ENV["HOME"], '.ripple')
55
- puts "Configuring the Ripple update script for web use."
56
- puts "Please enter directory for Ripple Configuration. Default:", configBase
54
+ configBase = File.join(ENV["HOME"], '.rypple')
55
+ puts "Configuring the Rypple update script for web use."
56
+ puts "Please enter directory for Rypple Configuration. Default:", configBase
57
57
  directory = gets.chomp!
58
58
 
59
59
  if !directory.empty?
60
60
  configBase = directory
61
61
  end
62
62
 
63
- conf = Ripple.loadConfiguration(configBase)
64
- session, client, keys = Ripple.connectToDropbox(configBase)
63
+ conf = Rypple.loadConfiguration(configBase)
64
+ session, client, keys = Rypple.connectToDropbox(configBase)
65
65
 
66
66
  if !conf.nil? and !keys.nil?
67
- Ripple.cleanup(conf, keys, configBase)
67
+ Rypple.cleanup(conf, keys, configBase)
68
68
  end
69
69
 
70
70
  baseCGI.gsub!(/%%CONFIG_PATH/, configBase)
@@ -129,19 +129,19 @@ if File.exists?(command)
129
129
  baseCGI.gsub!(/%%COMMAND/, command + ' ' + args)
130
130
  end
131
131
 
132
- rippleDir = File.join(inDir, 'ripple')
132
+ ryppleDir = File.join(inDir, 'rypple')
133
133
 
134
- if !File.exists?(rippleDir)
134
+ if !File.exists?(ryppleDir)
135
135
  begin
136
- Dir.mkdir(rippleDir)
136
+ Dir.mkdir(ryppleDir)
137
137
  rescue SystemCallError
138
- "Cannot create ripple directory."
138
+ "Cannot create rypple directory."
139
139
  end
140
140
  end
141
141
 
142
- File.open(File.join(rippleDir, 'update.html'), 'w', 0644) { |f| f.puts updateHTML }
142
+ File.open(File.join(ryppleDir, 'update.html'), 'w', 0644) { |f| f.puts updateHTML }
143
143
 
144
- out = File.join(rippleDir, 'update.cgi')
144
+ out = File.join(ryppleDir, 'update.cgi')
145
145
  File.open(out, 'w', 0755) { |f| f.puts baseCGI }
146
146
 
147
147
  puts "Should I enable basic user authentication for the update script? (Y/n):"
@@ -157,13 +157,13 @@ if answer.nil? or answer.empty? or answer.downcase! == 'y'
157
157
  authFile = File.join(configBase, '.htpasswd')
158
158
  File.open(authFile, 'w') { |f| f.puts "#{user}:#{pass}" }
159
159
  htaccess.gsub!(/%%AUTH_FILE/, authFile)
160
- File.open(File.join(rippleDir, '.htaccess'), 'w') { |f| f.puts htaccess }
160
+ File.open(File.join(ryppleDir, '.htaccess'), 'w') { |f| f.puts htaccess }
161
161
  end
162
162
 
163
163
  puts "Attempting first update"
164
164
 
165
- if Ripple.sync(configBase)
165
+ if Rypple.sync(configBase)
166
166
  puts `jekyll #{inDir} #{outDir}`
167
167
  else
168
- puts "Ripple sync failed."
168
+ puts "Rypple sync failed."
169
169
  end
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/ruby
2
- module Ripple
2
+ module Rypple
3
3
  require 'fileutils'
4
+ require 'ftools'
4
5
  require 'yaml'
5
6
  require "rubygems"
6
7
  require 'dropbox_sdk'
@@ -15,9 +16,9 @@ module Ripple
15
16
  }
16
17
 
17
18
  DropboxKeyFile = "dropbox_session.yaml"
18
- RippleConfigFile = "ripple.yaml"
19
+ RyppleConfigFile = "rypple.yaml"
19
20
 
20
- def Ripple.connectToDropbox(path)
21
+ def Rypple.connectToDropbox(path)
21
22
  dropConf = File.join(path, DropboxKeyFile)
22
23
  #Load Dropbox API dropboxKeys from file, if applicable.
23
24
  if File.exists?(dropConf)
@@ -61,13 +62,13 @@ module Ripple
61
62
  end
62
63
  end
63
64
 
64
- def Ripple.loadConfiguration(path)
65
- conf = Ripple::DefaultConfiguration.dup
65
+ def Rypple.loadConfiguration(path)
66
+ conf = Rypple::DefaultConfiguration.dup
66
67
 
67
- ripConf = File.join(path, RippleConfigFile)
68
+ rypConf = File.join(path, RyppleConfigFile)
68
69
  # Load configuration and override any values that differ from the default.
69
- if File.exists?(ripConf)
70
- loadedConf = YAML::load(File.read(ripConf))
70
+ if File.exists?(rypConf)
71
+ loadedConf = YAML::load(File.read(rypConf))
71
72
  conf.merge!(loadedConf)
72
73
  end
73
74
 
@@ -82,21 +83,21 @@ module Ripple
82
83
  return conf
83
84
  end
84
85
 
85
- def Ripple.cleanup(conf, keys, path)
86
+ def Rypple.cleanup(conf, keys, path)
86
87
  dropConfig = File.join(path, DropboxKeyFile)
87
88
  File.open(dropConfig, 'w') do|file|
88
89
  file.puts keys.to_yaml
89
90
  end
90
91
 
91
- rippleConf = File.join(path, RippleConfigFile)
92
- File.open(rippleConf, 'w') do |file|
92
+ ryppleConf = File.join(path, RyppleConfigFile)
93
+ File.open(ryppleConf, 'w') do |file|
93
94
  file.puts conf.to_yaml
94
95
  end
95
96
  end
96
97
 
97
98
  # Iterates over dropbox directory, returing paths and state hash for each file
98
99
  # oldFileState should be a hash of paths to state hashes, same as return values
99
- def Ripple.walkDropbox(client, path, fileState, oldFileState)
100
+ def Rypple.walkDropbox(client, path, fileState, oldFileState)
100
101
  #Here we need to actually sync newest files.
101
102
  begin
102
103
  useState = (!oldFileState.nil? and oldFileState.has_key?(path) and oldFileState[path]["path"] == path)
@@ -107,42 +108,41 @@ module Ripple
107
108
  return nil
108
109
  end
109
110
 
110
- files = { states["path"] => states }
111
+ files = {}
111
112
  #State represents a folder
112
113
  if states["is_dir"] and states.has_key?("contents")
113
114
  states["contents"].each{ |xx|
114
- if !xx.nil?
115
- files[xx["path"]] = xx
116
- end
117
115
  useState = (!oldFileState.nil? and oldFileState.has_key?(xx["path"]))
118
- old = (useState ? oldFileState[xx["path"]]["hash"] : nil)
119
- subs = Ripple.walkDropbox(client, xx["path"], fileState, old)
116
+ old = (useState ? oldFileState[xx["path"]] : nil)
117
+ subs = Rypple.walkDropbox(client, xx["path"], fileState, old)
120
118
  if !subs.nil?
121
119
  files.merge!(subs)
122
120
  end
123
121
  }
122
+ else
123
+ files[states['path']] = states
124
124
  end
125
125
 
126
126
  return files
127
127
  end
128
128
 
129
- def Ripple.sync(path = "")
130
- conf = Ripple.loadConfiguration(path)
129
+ def Rypple.sync(path = "")
130
+ conf = Rypple.loadConfiguration(path)
131
131
  begin
132
- session, client, dropboxKeys = Ripple.connectToDropbox(path)
132
+ session, client, dropboxKeys = Rypple.connectToDropbox(path)
133
133
  rescue DropboxAuthError
134
134
  puts "Dropbox authorization failed."
135
- Ripple.cleanup(conf, dropboxKeys, path)
135
+ Rypple.cleanup(conf, dropboxKeys, path)
136
136
  return
137
137
  rescue NameError
138
138
  puts "Destination does not exist."
139
- Ripple.cleanup(conf, dropboxKeys, path)
139
+ Rypple.cleanup(conf, dropboxKeys, path)
140
140
  return
141
141
  end
142
142
 
143
143
  if session.nil?
144
144
  puts "Could not connect to Dropbox."
145
- Ripple.cleanup(conf, dropboxKeys, path)
145
+ Rypple.cleanup(conf, dropboxKeys, path)
146
146
  return
147
147
  end
148
148
 
@@ -150,12 +150,14 @@ module Ripple
150
150
 
151
151
  fileState = {}
152
152
  oldFileState = dropboxKeys[:files]
153
- files = Ripple.walkDropbox(client, '/', fileState, oldFileState)
153
+ files = Rypple.walkDropbox(client, '/', fileState, oldFileState)
154
154
 
155
155
  if !files.nil?
156
156
  files.keys.each { |x|
157
157
  file = client.get_file(x)
158
- File.open(File.join(destDir, x), 'w') {|f| f.puts file}
158
+ dest = File.join(destDir, x)
159
+ File.makedirs(File.dirname(dest))
160
+ File.open(dest, 'w') {|f| f.puts file}
159
161
  }
160
162
  end
161
163
 
@@ -173,8 +175,8 @@ module Ripple
173
175
  }
174
176
  }
175
177
 
176
- dropboxKeys[:files] = Ripple.walkDropbox(client, '/', fileState, {})
177
- Ripple.cleanup(conf, dropboxKeys, path)
178
+ dropboxKeys[:files] = Rypple.walkDropbox(client, '/', fileState, {})
179
+ Rypple.cleanup(conf, dropboxKeys, path)
178
180
 
179
181
  return true
180
182
  end
@@ -0,0 +1,3 @@
1
+ module Rypple
2
+ VERSION = "0.0.2"
3
+ end
data/lib/rypple.rb ADDED
@@ -0,0 +1 @@
1
+ require 'rypple/base'
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "lib/ripple/version"
3
+ require "lib/rypple/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "rypple"
7
- s.version = Ripple::VERSION
7
+ s.version = Rypple::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Jason Ziglar"]
10
10
  s.email = ["jasedit@catexia.com"]
11
- s.homepage = "https://github.com/jasedit/ripple"
11
+ s.homepage = "https://github.com/jasedit/rypple"
12
12
  s.summary = %q{Dropbox interface for jekyll.}
13
13
  s.description = %q{A gem providing a Dropbox syncing interface for jekyll, along with a cgi file to update jekyll.}
14
14
 
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jason Ziglar
@@ -49,7 +49,8 @@ description: A gem providing a Dropbox syncing interface for jekyll, along with
49
49
  email:
50
50
  - jasedit@catexia.com
51
51
  executables:
52
- - rippleInstall.rb
52
+ - rypple
53
+ - ryppleInstall
53
54
  extensions: []
54
55
 
55
56
  extra_rdoc_files: []
@@ -58,14 +59,15 @@ files:
58
59
  - Gemfile
59
60
  - README
60
61
  - Rakefile
61
- - bin/rippleInstall.rb
62
- - lib/ripple.rb
63
- - lib/ripple/base.rb
64
- - lib/ripple/version.rb
62
+ - bin/rypple
63
+ - bin/ryppleInstall
64
+ - lib/rypple.rb
65
+ - lib/rypple/base.rb
66
+ - lib/rypple/version.rb
65
67
  - pkg/ripple-0.0.1.gem
66
- - ripple.gemspec
67
- - ripple.yaml
68
- homepage: https://github.com/jasedit/ripple
68
+ - rypple.gemspec
69
+ - rypple.yaml
70
+ homepage: https://github.com/jasedit/rypple
69
71
  licenses: []
70
72
 
71
73
  post_install_message:
@@ -1,3 +0,0 @@
1
- module Ripple
2
- VERSION = "0.0.1"
3
- end
data/lib/ripple.rb DELETED
@@ -1 +0,0 @@
1
- require 'ripple/base'
File without changes