dropbox-dotfiles 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dropbox-dotfiles +111 -46
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 874bbf7b0fdb10bf64fe8393eaa3743f523df9e9
|
4
|
+
data.tar.gz: 9e05412004f6634370a78674138572c272edd367
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b073508111e25a6b31b974a20d3b7f251ff8608ecd5bc901c986146ccbea36b2d4558b87cda7db984cf522885c5e8085d080d969591301641048565e82cc90ea
|
7
|
+
data.tar.gz: 66f3d2d4c5800e0825c61eebeb7cf6aaf03b106907044562864cb2723df68148936cb13e9f8f09b1f051a11ad002c077b762626a0c4fdfec1ae712d5ae58cde0
|
data/bin/dropbox-dotfiles
CHANGED
@@ -4,7 +4,7 @@ require 'colorize'
|
|
4
4
|
require 'FileUtils'
|
5
5
|
|
6
6
|
def error(message)
|
7
|
-
puts
|
7
|
+
puts "#{message}".red
|
8
8
|
end
|
9
9
|
|
10
10
|
def check_if_dropbox_dir_exist
|
@@ -16,35 +16,58 @@ def check_if_dropbox_dir_exist
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def check_if_dotfiles_dir_exist
|
20
|
+
dotfiles_directory = File.expand_path '~/Dropbox/Dotfiles'
|
21
|
+
unless File.directory? dotfiles_directory
|
22
|
+
error "'#{dotfiles_directory}' doesn't exists or is not a directory!"
|
23
|
+
puts 'Should I create the directory for you? (y/N): '
|
24
|
+
response = gets.chomp.downcase
|
25
|
+
if response == 'y'
|
26
|
+
begin
|
27
|
+
FileUtils.mkdir_p dotfiles_directory
|
28
|
+
rescue Exception => e
|
29
|
+
error e.message
|
30
|
+
exit!
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
19
36
|
def check_if_configuration_exist(configuration_file)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
37
|
+
if File.exist? configuration_file
|
38
|
+
unless File.file? configuration_file
|
39
|
+
error "'#{configuration_file}' is not a file!"
|
40
|
+
end
|
41
|
+
else
|
42
|
+
error "'#{configuration_file}' doesn't exists!"
|
43
|
+
print 'Should I create a new the file with an example configuration? (y/N): '
|
24
44
|
response = gets.chomp.downcase
|
25
|
-
if response == '
|
45
|
+
if response == 'y'
|
26
46
|
create_example_configuration configuration_file
|
47
|
+
else
|
48
|
+
exit!
|
27
49
|
end
|
28
50
|
end
|
29
51
|
end
|
30
52
|
|
31
53
|
def create_example_configuration(configuration_file)
|
32
|
-
File.open
|
33
|
-
|
54
|
+
File.open configuration_file, 'w' do |example|
|
55
|
+
example.puts <<CONFIGURATION
|
34
56
|
DropboxDotfiles.configuration {
|
35
|
-
# if you want to create a link for a single file use the command file
|
57
|
+
# if you want to create a link for a single file use the command 'file' like this:
|
36
58
|
# file '.vimrc'
|
37
59
|
|
38
|
-
# if its a directory you want to link use the
|
60
|
+
# if its a directory you want to link use the command 'dir' like this:
|
39
61
|
# dir '.gem'
|
40
62
|
|
41
|
-
# when you use file
|
42
|
-
# home. If you want to link something inside a sub
|
43
|
-
# to the folder itself use the command cd to
|
44
|
-
#
|
45
|
-
# cd
|
63
|
+
# when you use a 'file' or 'dir' command dropbox-dotfiles assumes that the source
|
64
|
+
# file or directory are in your home. If you want to link something inside a sub
|
65
|
+
# directory without creating a link to the folder itself use the command cd to
|
66
|
+
# change the root then use file and dir normally.
|
67
|
+
# cd statements can be nested
|
68
|
+
# cd('Library') {
|
46
69
|
# dir 'Fonts'
|
47
|
-
# cd(
|
70
|
+
# cd('Preferences') {
|
48
71
|
# file 'com.apple.Terminal.plist'
|
49
72
|
# }
|
50
73
|
# }
|
@@ -55,7 +78,9 @@ rescue Exception => e
|
|
55
78
|
error e.message
|
56
79
|
exit!
|
57
80
|
else
|
58
|
-
puts '
|
81
|
+
puts 'File created!'.green
|
82
|
+
puts "Now open '#{configuration_file}' in your favourite text editor and edit the configuration."
|
83
|
+
puts "When you're done launch dropbox-dotfiles again."
|
59
84
|
exit! 0
|
60
85
|
end
|
61
86
|
|
@@ -70,15 +95,15 @@ class Stats
|
|
70
95
|
@correct_links = 0
|
71
96
|
end
|
72
97
|
|
73
|
-
def correct
|
98
|
+
def correct!
|
74
99
|
@correct_links += 1
|
75
100
|
end
|
76
101
|
|
77
|
-
def error
|
102
|
+
def error!
|
78
103
|
@errors += 1
|
79
104
|
end
|
80
105
|
|
81
|
-
def created
|
106
|
+
def created!
|
82
107
|
@links_created += 1
|
83
108
|
end
|
84
109
|
end
|
@@ -100,7 +125,7 @@ class DropboxDotfiles
|
|
100
125
|
end
|
101
126
|
|
102
127
|
def DropboxDotfiles.configuration(&block)
|
103
|
-
dropbox = File.expand_path '~/Dropbox'
|
128
|
+
dropbox = File.expand_path '~/Dropbox/Dotfiles'
|
104
129
|
home = File.expand_path '~'
|
105
130
|
|
106
131
|
dp = DropboxDotfiles.new(dropbox, home, Stats.new)
|
@@ -109,9 +134,13 @@ class DropboxDotfiles
|
|
109
134
|
end
|
110
135
|
|
111
136
|
def report
|
112
|
-
|
113
|
-
|
114
|
-
|
137
|
+
if @stats.correct_links == 0 and @stats.links_created == 0 and @stats.errors == 0
|
138
|
+
puts "Your configuration file is empty!"
|
139
|
+
else
|
140
|
+
puts "#{@stats.correct_links} link were already present and correct"
|
141
|
+
puts "#{@stats.links_created} new links were created" if @stats.links_created > 0
|
142
|
+
puts "#{@stats.errors} errors" if @stats.errors > 0
|
143
|
+
end
|
115
144
|
end
|
116
145
|
|
117
146
|
def file(name)
|
@@ -131,11 +160,16 @@ class DropboxDotfiles
|
|
131
160
|
private
|
132
161
|
def create_dir_if_doesnt_exists(dir)
|
133
162
|
unless File.directory? dir
|
134
|
-
|
135
|
-
|
136
|
-
rescue Exception => e
|
137
|
-
error "#{e.message}"
|
163
|
+
if File.exist? dir
|
164
|
+
error "'#{dir}' is not a directory!"
|
138
165
|
exit!
|
166
|
+
else
|
167
|
+
begin
|
168
|
+
FileUtils.mkdir_p dir
|
169
|
+
rescue Exception => e
|
170
|
+
error "#{e.message}"
|
171
|
+
exit!
|
172
|
+
end
|
139
173
|
end
|
140
174
|
end
|
141
175
|
end
|
@@ -149,54 +183,85 @@ private
|
|
149
183
|
link = File.readlink home
|
150
184
|
if File.send is, home
|
151
185
|
if dropbox == link
|
152
|
-
@stats.correct
|
186
|
+
@stats.correct!
|
153
187
|
else
|
154
188
|
error "'#{home}' points to '#{link}' and not '#{dropbox}'"
|
155
|
-
|
189
|
+
correct_link dropbox, home, is
|
156
190
|
end
|
157
191
|
else
|
158
192
|
error "'#{home}' points to '#{dropbox}' which is not a #{type}"
|
159
|
-
|
193
|
+
correct_link dropbox, home, is
|
160
194
|
end
|
161
195
|
else
|
162
196
|
if File.exist? home
|
163
197
|
if File.send is, home
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
198
|
+
if File.exist? dropbox
|
199
|
+
print "Dropbox already contains '#{home}'"
|
200
|
+
print "Do you want to create a backup of '#{home}' and then create the link? (y/N): "
|
201
|
+
response = gets.chomp.downcase
|
202
|
+
if response == 'y'
|
203
|
+
backup = File.join home, '.old'
|
204
|
+
File.move home, backup
|
205
|
+
File.symlink dropbox, home
|
206
|
+
else
|
207
|
+
puts "'#{home}' not touched. remember to correct the conflict manually!"
|
208
|
+
@stats.error!
|
209
|
+
end
|
172
210
|
else
|
173
|
-
|
211
|
+
print "Should I move '#{home}' inside Dropbox and create a link? (y/N): "
|
212
|
+
response = gets.chomp.downcase
|
213
|
+
if response == 'y'
|
214
|
+
FileUtils.move home, dropbox
|
215
|
+
File.symlink dropbox, home
|
216
|
+
puts "link '#{home}' created"
|
217
|
+
@stats.created!
|
218
|
+
else
|
219
|
+
puts "'#{home}' ignored"
|
220
|
+
end
|
174
221
|
end
|
175
222
|
else
|
176
223
|
error "'#{home}' is not a #{type}"
|
177
|
-
@stats.error
|
224
|
+
@stats.error!
|
178
225
|
end
|
179
226
|
else
|
180
|
-
if File.
|
227
|
+
if File.exists? dropbox
|
181
228
|
if File.send is, dropbox
|
182
229
|
File.symlink dropbox, home
|
183
230
|
puts "link '#{home}' created"
|
184
|
-
@stats.created
|
231
|
+
@stats.created!
|
185
232
|
else
|
186
233
|
error "'#{dropbox}' is not a #{type}"
|
187
|
-
@stats.error
|
234
|
+
@stats.error!
|
188
235
|
end
|
189
236
|
else
|
190
237
|
error "'#{dropbox}' doesnt exists!"
|
191
|
-
@stats.error
|
238
|
+
@stats.error!
|
192
239
|
end
|
193
240
|
end
|
194
241
|
end
|
195
242
|
end
|
243
|
+
|
244
|
+
def correct_link(dropbox, home, is)
|
245
|
+
if File.exist? dropbox and File.send is, dropbox
|
246
|
+
puts 'Do you want to create a backup of the link and then correct it? (y/N): '
|
247
|
+
response = gets.chomp.downcase
|
248
|
+
if response == 'y'
|
249
|
+
backup = File.join home, '.old'
|
250
|
+
File.move home, backup
|
251
|
+
File.symlink dropbox, home
|
252
|
+
else
|
253
|
+
puts 'link not corrected'
|
254
|
+
@stats.error!
|
255
|
+
end
|
256
|
+
else
|
257
|
+
@stats.error!
|
258
|
+
end
|
259
|
+
end
|
196
260
|
end
|
197
261
|
|
198
|
-
configuration_file = File.expand_path '~/Dropbox/.
|
262
|
+
configuration_file = File.expand_path '~/Dropbox/Dotfiles/.configuration'
|
199
263
|
|
200
264
|
check_if_dropbox_dir_exist
|
265
|
+
check_if_dotfiles_dir_exist
|
201
266
|
check_if_configuration_exist configuration_file
|
202
267
|
load configuration_file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dropbox-dotfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mirco Macrelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -30,8 +30,10 @@ dependencies:
|
|
30
30
|
- - '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.6.0
|
33
|
-
description: This gem
|
34
|
-
|
33
|
+
description: This gem provides a binary called dropbox-dotfiles that can be used to
|
34
|
+
synchronize your dotfiles with Dropbox. Which files or folders are synched must
|
35
|
+
be defined in an easy to edit configuration file.
|
36
|
+
email: mail@mircomacrelli.net
|
35
37
|
executables:
|
36
38
|
- dropbox-dotfiles
|
37
39
|
extensions: []
|
@@ -61,5 +63,5 @@ rubyforge_project:
|
|
61
63
|
rubygems_version: 2.2.0
|
62
64
|
signing_key:
|
63
65
|
specification_version: 4
|
64
|
-
summary:
|
66
|
+
summary: Easy dotfiles's synchronization via Dropbox
|
65
67
|
test_files: []
|