flexdot 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -11
- data/flexdot.gemspec +1 -0
- data/lib/flexdot/installer.rb +5 -5
- data/lib/flexdot/output.rb +48 -0
- data/lib/flexdot/tasks.rb +6 -4
- data/lib/flexdot/version.rb +1 -1
- data/lib/flexdot.rb +2 -2
- metadata +17 -3
- data/lib/flexdot/console.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbeccda096b5cffa6592e2fd044091357384a1be8eed6d692f2ddfd8e7b6cb3e
|
4
|
+
data.tar.gz: cb0bb15f3a618e50ebe0c4e5db1fc325e426ba357f4ccfbddfd5110ec263a172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93df4b1412f1fbaccc3a242f68a569955435e2271d9cab0de29ec62cd04d760997162bb81fb1573454d837d29ba34606e6ef9a8d83b0c07cab5238c28cbfa62b
|
7
|
+
data.tar.gz: 89284ebc88a5c475e53e80a6049bfa2bd37d498bf4a600ecd9ba1637a5c170951a9aa6be749e72adef587b691865c686a2ae834ea973f78674f1e32effd56a54
|
data/README.md
CHANGED
@@ -48,6 +48,11 @@ Flexdot.setup(
|
|
48
48
|
# The dotfile directory path.
|
49
49
|
# Default '.'.
|
50
50
|
dotfiles_dir: '.'
|
51
|
+
|
52
|
+
# (optional)
|
53
|
+
# Whether or not to colorize the output
|
54
|
+
# Default: true
|
55
|
+
output_colorize: true
|
51
56
|
)
|
52
57
|
```
|
53
58
|
|
@@ -224,17 +229,17 @@ Or,
|
|
224
229
|
The following is the output result:
|
225
230
|
|
226
231
|
```
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
232
|
+
already linked: bin/git-delete-other-branches
|
233
|
+
already linked: bin/git-reset-and-clean
|
234
|
+
already linked: .config/git/ignore
|
235
|
+
already linked: .gemrc
|
236
|
+
already linked: .vimrc
|
237
|
+
link created: .bash_profile (backup)
|
238
|
+
link created: .bashrc (backup)
|
239
|
+
link created: .gitconfig (backup)
|
240
|
+
link created: .config/karabiner/assets/complex_modifications/tab-emulation.json (backup)
|
241
|
+
link created: Library/Application Support/Code/User/keybindings.json (backup)
|
242
|
+
link created: Library/Application Support/Code/User/settings.json (backup)
|
238
243
|
```
|
239
244
|
|
240
245
|
`already_linked` means skipped because `bin/git-delete-other-branches` is already linked. `link_created` means the link was created.
|
data/flexdot.gemspec
CHANGED
data/lib/flexdot/installer.rb
CHANGED
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
require_relative '
|
5
|
+
require_relative 'output'
|
6
6
|
require_relative 'backup'
|
7
7
|
require_relative 'index'
|
8
8
|
|
9
9
|
module Flexdot
|
10
10
|
class Installer
|
11
|
-
def initialize(name, dotfiles_dir
|
11
|
+
def initialize(name, dotfiles_dir, home_dir, output_colorize)
|
12
12
|
@name = name
|
13
13
|
@dotfiles_dir = dotfiles_dir
|
14
14
|
@home_dir = home_dir
|
15
15
|
@backup = Backup.new
|
16
|
-
@
|
16
|
+
@output = Output.new(@home_dir, colorize: output_colorize)
|
17
17
|
end
|
18
18
|
|
19
19
|
def install(index_file)
|
@@ -27,13 +27,13 @@ module Flexdot
|
|
27
27
|
|
28
28
|
private
|
29
29
|
|
30
|
-
attr_reader :name, :dotfiles_dir, :home_dir, :backup, :
|
30
|
+
attr_reader :name, :dotfiles_dir, :home_dir, :backup, :output
|
31
31
|
|
32
32
|
def install_link(dotfile_path, home_file_path)
|
33
33
|
dotfile = @dotfiles_dir.join(dotfile_path).expand_path
|
34
34
|
home_file = @home_dir.join(home_file_path, dotfile.basename).expand_path
|
35
35
|
|
36
|
-
|
36
|
+
output.log(home_file) do |status|
|
37
37
|
if home_file.symlink?
|
38
38
|
if home_file.readlink == dotfile
|
39
39
|
status.result = :already_linked
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'paint'
|
4
|
+
|
5
|
+
module Flexdot
|
6
|
+
class Output
|
7
|
+
Status = Struct.new(:home_file, :result, :backuped)
|
8
|
+
|
9
|
+
def initialize(dotfiles_dir, colorize: true)
|
10
|
+
@dotfiles_dir = dotfiles_dir
|
11
|
+
@colorize = colorize
|
12
|
+
end
|
13
|
+
|
14
|
+
def log(home_file)
|
15
|
+
status = Status.new(home_file)
|
16
|
+
yield(status)
|
17
|
+
puts message_for(status)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :dotfiles_dir
|
23
|
+
|
24
|
+
def message_for(status)
|
25
|
+
result_color =
|
26
|
+
case status.result
|
27
|
+
when :already_linked then :gray
|
28
|
+
when :link_updated then :yellow
|
29
|
+
when :link_created then :green
|
30
|
+
else :default
|
31
|
+
end
|
32
|
+
|
33
|
+
msg = []
|
34
|
+
msg << paint("#{status.result.to_s.gsub('_', ' ')}:", result_color)
|
35
|
+
msg << status.home_file.relative_path_from(dotfiles_dir)
|
36
|
+
msg << '(backup)' if status.backuped
|
37
|
+
msg.join(' ')
|
38
|
+
end
|
39
|
+
|
40
|
+
def paint(string, *colors)
|
41
|
+
colorize? ? Paint[string, *colors] : string
|
42
|
+
end
|
43
|
+
|
44
|
+
def colorize?
|
45
|
+
@colorize
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/flexdot/tasks.rb
CHANGED
@@ -10,9 +10,10 @@ module Flexdot
|
|
10
10
|
|
11
11
|
Index = Struct.new(:filename, :name, keyword_init: true)
|
12
12
|
|
13
|
-
def initialize(dotfiles_dir, home_dir)
|
13
|
+
def initialize(dotfiles_dir, home_dir, output_colorize)
|
14
14
|
@dotfiles_dir = Pathname.new(dotfiles_dir).expand_path
|
15
15
|
@home_dir = Pathname.new(home_dir).expand_path
|
16
|
+
@output_colorize = output_colorize
|
16
17
|
end
|
17
18
|
|
18
19
|
def install
|
@@ -27,8 +28,9 @@ module Flexdot
|
|
27
28
|
task index.name do
|
28
29
|
installer = Installer.new(
|
29
30
|
index.name,
|
30
|
-
dotfiles_dir
|
31
|
-
home_dir
|
31
|
+
dotfiles_dir,
|
32
|
+
home_dir,
|
33
|
+
output_colorize
|
32
34
|
)
|
33
35
|
installer.install(index.filename)
|
34
36
|
end
|
@@ -38,7 +40,7 @@ module Flexdot
|
|
38
40
|
|
39
41
|
private
|
40
42
|
|
41
|
-
attr_reader :dotfiles_dir, :home_dir
|
43
|
+
attr_reader :dotfiles_dir, :home_dir, :output_colorize
|
42
44
|
|
43
45
|
def indexes
|
44
46
|
@indexes ||= Pathname.new(dotfiles_dir).glob('*.yml').map do |index_file|
|
data/lib/flexdot/version.rb
CHANGED
data/lib/flexdot.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative 'flexdot/version'
|
|
6
6
|
require_relative 'flexdot/tasks'
|
7
7
|
|
8
8
|
module Flexdot
|
9
|
-
def self.setup(home_dir:, dotfiles_dir: '.')
|
10
|
-
Tasks.new(dotfiles_dir, home_dir).install
|
9
|
+
def self.setup(home_dir:, dotfiles_dir: '.', output_colorize: true)
|
10
|
+
Tasks.new(dotfiles_dir, home_dir, output_colorize).install
|
11
11
|
end
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexdot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuya Hidaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '12.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: paint
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.2.1
|
27
41
|
description: Flexdot is a Flexible and Rake based dotfile manager
|
28
42
|
email:
|
29
43
|
- hidakatsuya@gmail.com
|
@@ -43,9 +57,9 @@ files:
|
|
43
57
|
- flexdot.gemspec
|
44
58
|
- lib/flexdot.rb
|
45
59
|
- lib/flexdot/backup.rb
|
46
|
-
- lib/flexdot/console.rb
|
47
60
|
- lib/flexdot/index.rb
|
48
61
|
- lib/flexdot/installer.rb
|
62
|
+
- lib/flexdot/output.rb
|
49
63
|
- lib/flexdot/tasks.rb
|
50
64
|
- lib/flexdot/version.rb
|
51
65
|
homepage: https://github.com/hidakatsuya/flexdot
|
data/lib/flexdot/console.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Flexdot
|
4
|
-
class Console
|
5
|
-
Status = Struct.new(:home_file, :result, :backuped)
|
6
|
-
|
7
|
-
def initialize(dotfiles_dir)
|
8
|
-
@dotfiles_dir = dotfiles_dir
|
9
|
-
end
|
10
|
-
|
11
|
-
def log(home_file)
|
12
|
-
status = Status.new(home_file)
|
13
|
-
yield(status)
|
14
|
-
puts message_for(status)
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :dotfiles_dir
|
20
|
-
|
21
|
-
def message_for(status)
|
22
|
-
[].tap { |msg|
|
23
|
-
msg << "[#{status.result}]"
|
24
|
-
msg << status.home_file.relative_path_from(dotfiles_dir)
|
25
|
-
msg << '(backup)' if status.backuped
|
26
|
-
}.join(' ')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|