dotify 0.0.2.1 → 0.0.3
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/.travis.yml +7 -0
- data/Rakefile +7 -0
- data/lib/dotify/cli.rb +34 -3
- data/lib/dotify/version.rb +1 -1
- metadata +3 -2
data/.travis.yml
ADDED
data/Rakefile
CHANGED
data/lib/dotify/cli.rb
CHANGED
@@ -17,6 +17,7 @@ module Dotify
|
|
17
17
|
|
18
18
|
DOTIFY_DIR_NAME = ENV['DOTIFY_DIR_NAME'] || '.dotify'
|
19
19
|
DOTIFY_PATH = ENV['DOTIFY_PATH'] || "#{Thor::Util.user_home}/#{DOTIFY_DIR_NAME}"
|
20
|
+
DOTIFY_BACKUP_PATH = ENV['DOTIFY_BACKUP_PATH'] || "#{DOTIFY_PATH}/.backup"
|
20
21
|
|
21
22
|
def self.source_root
|
22
23
|
DOTIFY_PATH
|
@@ -28,7 +29,7 @@ module Dotify
|
|
28
29
|
end
|
29
30
|
|
30
31
|
desc :link, "Link up your dotfiles"
|
31
|
-
method_option :force, default
|
32
|
+
method_option :force, :default => false, :type => :boolean, :aliases => '-f', :desc => "Definitely link all dotfiles"
|
32
33
|
def link
|
33
34
|
dotfile_list do |file|
|
34
35
|
if template? file
|
@@ -44,22 +45,42 @@ module Dotify
|
|
44
45
|
end
|
45
46
|
|
46
47
|
desc :unlink, "Unlink individual dotfiles"
|
47
|
-
method_option :force, default
|
48
|
+
method_option :force, :default => false, :type => :boolean, :aliases => '-f', :desc => "Definitely remove all dotfiles"
|
48
49
|
def unlink
|
49
50
|
dotfile_list do |file|
|
50
51
|
destination = filename(file)
|
51
52
|
if options.force? || yes?("Are you sure you want to remove ~/#{destination}? [Yn]", :blue)
|
52
|
-
remove_file dotfile_location(file), verbose
|
53
|
+
remove_file dotfile_location(file), :verbose => true
|
53
54
|
end
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
58
|
desc :backup, "Backup your dotfiles for quick recovery if something goes wrong"
|
58
59
|
def backup
|
60
|
+
dotfile_list do |file|
|
61
|
+
file = filename(file)
|
62
|
+
backup = "#{DOTIFY_BACKUP_PATH}/#{file}"
|
63
|
+
if File.exists?(dotfile_location(file))
|
64
|
+
remove_file backup, :verbose => false if File.exists?(backup)
|
65
|
+
copy_file dotfile_location(file), backup, :verbose => false
|
66
|
+
say "Backing up ~/#{file}", :blue
|
67
|
+
end
|
68
|
+
end
|
59
69
|
end
|
60
70
|
|
61
71
|
desc :restore, "Restore your backed-up dotfiles"
|
72
|
+
method_option :force, :default => false, :type => :boolean, :aliases => '-f', :desc => "Backup existing dotfiles"
|
62
73
|
def restore
|
74
|
+
backup_list do |file|
|
75
|
+
filename = filename(file)
|
76
|
+
if options.force? || yes?("Are you sure you want to restore ~/#{filename}? [Yn]", :red)
|
77
|
+
if File.exists?(dotfile_location(filename))
|
78
|
+
remove_file dotfile_location(filename), :verbose => false
|
79
|
+
end
|
80
|
+
copy_file file, dotfile_location(filename), :verbose => false
|
81
|
+
say "Restoring up ~/#{filename}", :blue
|
82
|
+
end
|
83
|
+
end
|
63
84
|
end
|
64
85
|
|
65
86
|
no_tasks do
|
@@ -93,6 +114,16 @@ module Dotify
|
|
93
114
|
end
|
94
115
|
end
|
95
116
|
|
117
|
+
def backup_list
|
118
|
+
files = Dir["#{DOTIFY_BACKUP_PATH}/.*"]
|
119
|
+
files.delete_if { |f| File.directory? f }
|
120
|
+
if block_given?
|
121
|
+
files.each { |f| yield f }
|
122
|
+
else
|
123
|
+
files
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
96
127
|
def filename(file)
|
97
128
|
file.split("/").last
|
98
129
|
end
|
data/lib/dotify/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -69,6 +69,7 @@ extra_rdoc_files: []
|
|
69
69
|
files:
|
70
70
|
- .gitignore
|
71
71
|
- .rspec
|
72
|
+
- .travis.yml
|
72
73
|
- Gemfile
|
73
74
|
- LICENSE
|
74
75
|
- README.md
|