lace 0.5.2 → 0.6.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.
data/lib/lace/utils.rb CHANGED
@@ -1,8 +1,8 @@
1
- #Copyright 2009-2014 Max Howell and other contributors.
1
+ # Copyright 2009-2014 Max Howell and other contributors.
2
2
  #
3
- #Redistribution and use in source and binary forms, with or without
4
- #modification, are permitted provided that the following conditions
5
- #are met:
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions
5
+ # are met:
6
6
  #
7
7
  # 1. Redistributions of source code must retain the above copyright
8
8
  # notice, this list of conditions and the following disclaimer.
@@ -10,27 +10,27 @@
10
10
  # notice, this list of conditions and the following disclaimer in the
11
11
  # documentation and/or other materials provided with the distribution.
12
12
  #
13
- #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
- #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
- #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
- #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17
- #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
- #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
- #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
- #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
- #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
- #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
+ # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
+ # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
+ # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
+ # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
23
 
24
24
  class Tty
25
25
  class << self
26
- def blue; bold 34; end
27
- def white; bold 39; end
28
- def red; underline 31; end
29
- def yellow; underline 33 ; end
30
- def reset; escape 0; end
31
- def em; underline 39; end
32
- def green; color 92 end
33
- def gray; bold 30 end
26
+ def blue = bold(34)
27
+ def white = bold(39)
28
+ def red = underline(31)
29
+ def yellow = underline(33)
30
+ def reset = escape(0)
31
+ def em = underline(39)
32
+ def green = color(92)
33
+ def gray = bold(30)
34
34
 
35
35
  def width
36
36
  `/usr/bin/tput cols`.strip.to_i
@@ -42,48 +42,51 @@ class Tty
42
42
 
43
43
  private
44
44
 
45
- def color n
45
+ def color(n)
46
46
  escape "0;#{n}"
47
47
  end
48
- def bold n
48
+
49
+ def bold(n)
49
50
  escape "1;#{n}"
50
51
  end
51
- def underline n
52
+
53
+ def underline(n)
52
54
  escape "4;#{n}"
53
55
  end
54
- def escape n
56
+
57
+ def escape(n)
55
58
  "\033[#{n}m" if $stdout.tty?
56
59
  end
57
60
  end
58
61
  end
59
62
 
60
- def ohai title, *sput
63
+ def ohai(title, *sput)
61
64
  title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
62
65
  puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
63
66
  puts sput unless sput.empty?
64
67
  end
65
68
 
66
- def oh1 title
69
+ def oh1(title)
67
70
  title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
68
71
  puts "#{Tty.green}==>#{Tty.white} #{title}#{Tty.reset}"
69
72
  end
70
73
 
71
- def opoo warning
72
- STDERR.puts "#{Tty.red}Warning#{Tty.reset}: #{warning}"
74
+ def opoo(warning)
75
+ $stderr.puts "#{Tty.red}Warning#{Tty.reset}: #{warning}"
73
76
  end
74
77
 
75
- def onoe error
78
+ def onoe(error)
76
79
  lines = error.to_s.split("\n")
77
- STDERR.puts "#{Tty.red}Error#{Tty.reset}: #{lines.shift}"
78
- STDERR.puts lines unless lines.empty?
80
+ $stderr.puts "#{Tty.red}Error#{Tty.reset}: #{lines.shift}"
81
+ $stderr.puts lines unless lines.empty?
79
82
  end
80
83
 
81
- def ofail error
84
+ def ofail(error)
82
85
  onoe error
83
86
  Lace.failed = true
84
87
  end
85
88
 
86
- def odie error
89
+ def odie(error)
87
90
  onoe error
88
91
  exit 1
89
92
  end
@@ -96,13 +99,19 @@ def determine_os
96
99
  end
97
100
  end
98
101
 
99
- module Lace extend self
100
- def system cmd, *args
101
- puts "#{cmd} #{args*' '}" if ARGV.verbose?
102
+ module Lace
103
+ extend self
104
+
105
+ def system(cmd, *args)
106
+ puts "#{cmd} #{args * ' '}" if ARGV.verbose?
102
107
  fork do
103
108
  yield if block_given?
104
- args.collect!{|arg| arg.to_s}
105
- exec(cmd.to_s, *args) rescue nil
109
+ args.collect! { |arg| arg.to_s }
110
+ begin
111
+ exec(cmd.to_s, *args)
112
+ rescue StandardError
113
+ nil
114
+ end
106
115
  exit! 1 # never gets here unless exec failed
107
116
  end
108
117
  Process.wait
@@ -111,15 +120,15 @@ module Lace extend self
111
120
  end
112
121
 
113
122
  # Kernel.system but with exceptions
114
- def safe_system cmd, *args
115
- unless Lace.system cmd, *args
116
- args = args.map{ |arg| arg.to_s.gsub " ", "\\ " } * " "
117
- raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}"
118
- end
123
+ def safe_system(cmd, *args)
124
+ return if Lace.system cmd, *args
125
+
126
+ args = args.map { |arg| arg.to_s.gsub ' ', '\\ ' } * ' '
127
+ raise ErrorDuringExecution, "Failure while executing: #{cmd} #{args}"
119
128
  end
120
129
 
121
130
  # prints no output
122
- def quiet_system cmd, *args
131
+ def quiet_system(cmd, *args)
123
132
  Lace.system(cmd, *args) do
124
133
  # Redirect output streams to `/dev/null` instead of closing as some programs
125
134
  # will fail to execute if they can't write to an open stream.
@@ -127,4 +136,3 @@ def quiet_system cmd, *args
127
136
  $stderr.reopen('/dev/null')
128
137
  end
129
138
  end
130
-
data/lib/lace/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lace
2
- VERSION = "0.5.2"
2
+ VERSION = '0.6.0'
3
3
  end
data/lib/lace.rb CHANGED
@@ -1,23 +1,28 @@
1
- require "lace/utils"
2
- require "lace/exceptions"
3
- require "lace/version"
1
+ require 'lace/utils'
2
+ require 'lace/exceptions'
3
+ require 'lace/version'
4
+
5
+ module Lace
6
+ extend self
4
7
 
5
- module Lace extend self
6
8
  attr_accessor :failed
7
- alias_method :failed?, :failed
9
+ alias failed? failed
8
10
 
9
11
  def self.pkgs_folder
10
- packages_folder = Pathname.new(ENV["HOME"]).join(".lace.pkgs")
12
+ packages_folder = Pathname.new(ENV.fetch('HOME', nil)).join('.lace.pkgs')
11
13
 
12
- if ENV["LACE_FOLDER"]
13
- packages_folder = Pathname.new(ENV["LACE_FOLDER"])
14
- end
14
+ packages_folder = Pathname.new(ENV['LACE_FOLDER']) if ENV['LACE_FOLDER']
15
15
  packages_folder
16
16
  end
17
17
 
18
- def self.pstore
19
- @pstore ||= PStore.new(pkgs_folder/".lace.pstore")
18
+ # Load a command file. False when no such command exists; a LoadError
19
+ # from inside the command file is a real bug and propagates.
20
+ def self.require_command(path)
21
+ require path
22
+ true
23
+ rescue LoadError => e
24
+ raise unless e.path == path
25
+
26
+ false
20
27
  end
21
28
  end
22
-
23
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kai Richard Koenig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-25 00:00:00.000000000 Z
11
+ date: 2026-12-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Lace lets you manage your dotfiles when using them on multiple machines
14
14
  email: kai.richard.koenig@gmail.com
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/lace
21
21
  - lib/cmd/activate.rb
22
+ - lib/cmd/apply.rb
22
23
  - lib/cmd/deactivate.rb
23
24
  - lib/cmd/diff.rb
24
25
  - lib/cmd/fetch.rb
@@ -39,6 +40,7 @@ files:
39
40
  - lib/lace/package.rb
40
41
  - lib/lace/package/facts.rb
41
42
  - lib/lace/package/package.rb
43
+ - lib/lace/package/pkg_lace.rb
42
44
  - lib/lace/package/utils.rb
43
45
  - lib/lace/utils.rb
44
46
  - lib/lace/version.rb