dorian-dot 0.4.2 → 0.5.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dot +15 -0
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 601ab8f401777d4a476a67462b2af1da857e20ec2cec99850b1749caae62dc53
4
- data.tar.gz: 83a1481cb28a3fc475cb3cce95d771079285b7a36aea4e21c4f8cfa9662d22a8
3
+ metadata.gz: b0e8e99f65b29add9f02b9b7a117f435280f396b6e4ae93ef62f9098183a72b0
4
+ data.tar.gz: 23bca3a8c49c307934536841763dddb6d47e375330b31fef8b371f38981154a4
5
5
  SHA512:
6
- metadata.gz: 4434435ec4b993b59d61b0b60313ee7e6b09ce88b49a99b7de492464cdcc236a64bcc1d0a50620839773d71a3fd50283ada16915736e21944f3bd531d1fa1b29
7
- data.tar.gz: 6e79c53b5f71fbf46e3a8ff8e1db7824cc62d22703ef1dbcd19eac8797401f3e9592215a5989848d74ba42cb12708747c9680676322aa458f07637a2ee9cb296
6
+ metadata.gz: e5f25b870fd90a64c2a12fc286752df65f0195c6b0df4ea2c0f7982a0b6d49ba9e1c992a3f2dc1ea2c0b52fa3daa203f09d1c9983e73fc0939a76d8199921120
7
+ data.tar.gz: 1711e8d06636ad54f720122e4cb8917d3bf9bd6b07bd19ec9e046753dc98f1e49bec719877ae283606d9d3260f72d82e1db99a4420d5d187596f5dd75e65f65c
data/bin/dot CHANGED
@@ -9,13 +9,28 @@ if ARGV.size != 1
9
9
  exit
10
10
  end
11
11
 
12
+ IGNORE_FILE = File.expand_path("#{ARGV.first.chomp("/")}/.dotignore")
13
+ IGNORE_CONTENT = File.exist?(IGNORE_FILE) ? File.read(IGNORE_FILE) : ""
14
+
15
+ IGNORE_PATTERNS = IGNORE_CONTENT.lines.map(&:strip).reject do |line|
16
+ line.empty? || line.start_with?("#")
17
+ end.map do |pattern|
18
+ Regexp.new("\\A#{pattern}\\z")
19
+ end
20
+
21
+ def ignore?(path)
22
+ IGNORE_PATTERNS.any? { |pattern| pattern.match?(path) }
23
+ end
24
+
12
25
  Git
13
26
  .open(ARGV.first)
14
27
  .ls_files
15
28
  .map(&:first)
16
29
  .each do |file|
30
+ next if ignore?(file)
17
31
  homefile = "#{Dir.home}/#{file}"
18
32
  dotfile = File.expand_path("#{ARGV.first.chomp("/")}/#{file}")
19
33
  File.delete(homefile) if File.exist?(homefile) || File.symlink?(homefile)
34
+ FileUtils.mkdir_p(File.dirname(dotfile))
20
35
  FileUtils.ln_s(dotfile, homefile, verbose: true)
21
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-dot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.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: 2024-03-09 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git