dorian-dot 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dot +35 -2
- metadata +7 -8
- data/lib/dorian/dot.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55f4bf4cc0b8777bcabe973d59982eb1b7a603c2e95106abd7fb4aa5a01ddf9
|
4
|
+
data.tar.gz: 8596781b1b529193cd015ae449c007646f0a40cba2353c7519260e8c8668daa3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc2b97caeae8e7e66001372ce8e544a351929f68441c54477608fb78ceae92fa77fa0555d71386a7935c4a3448a6209c87815f013d6b15785af8ea04acf6075f
|
7
|
+
data.tar.gz: df88574a9506a9913e633ecb4d96d074f78667860707fc95c2d531e4d2586fd4c264e0e560737e04ab8de79ede4a0ee2951cb3a669b3cae02eef6941bd7c8ba4
|
data/bin/dot
CHANGED
@@ -1,4 +1,37 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
if ARGV.empty? || ARGV.size > 2 || ARGV[0] == "--help" || ARGV[0] == "-h"
|
7
|
+
puts "USAGE: dot DIRECTORY [--force]"
|
8
|
+
exit
|
9
|
+
end
|
10
|
+
|
11
|
+
dir = ARGV[0]
|
12
|
+
force = ARGV[1] == "--force"
|
13
|
+
files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH)
|
14
|
+
files = files.grep_v(%r{/.git/}).grep_v(%r{/\.$}).grep_v(%r{/\.\.$})
|
15
|
+
files = files.select { |file| File.file?(file) }
|
16
|
+
files.each do |file|
|
17
|
+
file = file.gsub("//", "/")
|
18
|
+
barefile = file.gsub(dir, "").gsub(%r{^/}, "")
|
19
|
+
homefile = "#{Dir.home}/#{barefile}".gsub("//", "/")
|
20
|
+
|
21
|
+
if File.exist?(homefile) || File.symlink?(homefile)
|
22
|
+
if force
|
23
|
+
FileUtils.rm(homefile)
|
24
|
+
else
|
25
|
+
print "#{homefile} exists, delete? (y/N) "
|
26
|
+
answer = $stdin.gets.strip[0].to_s.downcase
|
27
|
+
|
28
|
+
if answer == "y"
|
29
|
+
FileUtils.rm(homefile)
|
30
|
+
else
|
31
|
+
exit
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
FileUtils.ln_s(file, homefile, verbose: true)
|
37
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dorian-dot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
|
-
Links dot files
|
14
|
+
Links dot files e.g. `dot ~/src/dotfiles`
|
15
15
|
|
16
|
-
|
16
|
+
USAGE: dot DIRECTORY [--force]
|
17
17
|
email: dorian@dorianmarie.fr
|
18
18
|
executables:
|
19
19
|
- dot
|
@@ -21,8 +21,7 @@ extensions: []
|
|
21
21
|
extra_rdoc_files: []
|
22
22
|
files:
|
23
23
|
- bin/dot
|
24
|
-
|
25
|
-
homepage: https://github.com/dorianmariefr/dot
|
24
|
+
homepage: https://github.com/dorianmariefr/dorian-dot
|
26
25
|
licenses:
|
27
26
|
- MIT
|
28
27
|
metadata:
|
@@ -42,8 +41,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
41
|
- !ruby/object:Gem::Version
|
43
42
|
version: '0'
|
44
43
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
44
|
+
rubygems_version: 3.5.3
|
46
45
|
signing_key:
|
47
46
|
specification_version: 4
|
48
|
-
summary: Links dot files
|
47
|
+
summary: Links dot files e.g. `dot ~/src/dotfiles`
|
49
48
|
test_files: []
|
data/lib/dorian/dot.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
module Dorian
|
4
|
-
class Dot
|
5
|
-
def self.run
|
6
|
-
if ARGV.size < 1 || ARGV.size > 2 || ARGV[0] == "--help" || ARGV[0] == "-h"
|
7
|
-
puts "USAGE: dot DIRECTORY [--confirm]"
|
8
|
-
exit
|
9
|
-
end
|
10
|
-
|
11
|
-
dir = ARGV[0]
|
12
|
-
confirm = ARGV[1] == "--confirm"
|
13
|
-
files = Dir.glob("#{dir}/**/*", File::FNM_DOTMATCH)
|
14
|
-
files = files.grep_v(/\/.git\//).grep_v(/\/\.$/).grep_v(/\/\.\.$/)
|
15
|
-
files = files.select { |file| File.file?(file) }
|
16
|
-
files.each do |file|
|
17
|
-
file = file.gsub("//", "/")
|
18
|
-
barefile = file.gsub(dir, "").gsub(/^\//, "")
|
19
|
-
homefile = "#{Dir.home}/#{barefile}".gsub("//", "/")
|
20
|
-
|
21
|
-
if File.exists?(homefile)
|
22
|
-
if confirm
|
23
|
-
FileUtils.rm(homefile)
|
24
|
-
else
|
25
|
-
print "#{homefile} file exists, delete? (y/N) "
|
26
|
-
answer = confirm ? "yes" : $stdin.gets.strip
|
27
|
-
|
28
|
-
if answer[0].to_s.downcase == "y"
|
29
|
-
FileUtils.rm(homefile)
|
30
|
-
else
|
31
|
-
exit
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
FileUtils.ln_s(file, homefile, verbose: true)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|