freyia 0.5.1 → 0.5.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/freyia/automations/create_file.rb +3 -3
- data/lib/freyia/automations/create_link.rb +2 -2
- data/lib/freyia/automations/directory.rb +4 -4
- data/lib/freyia/automations/empty_directory.rb +2 -2
- data/lib/freyia/automations/inject_into_file.rb +4 -4
- data/lib/freyia/automations.rb +10 -4
- data/lib/freyia/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d18d6f5e341842b0cd67728fdbec92ac6525b02878806f3b91b1ec60dbcf664b
|
|
4
|
+
data.tar.gz: c5c1b224a6894a51a5a2b3ddd95fa4b6ac766273a5c57445243e659bf003a3c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 042d8ddfa2963c03cd7b52df4b9a7ef1fc77cad9e5e7e671d3dd3a223f7bb5ff94f65af8b9197329cd3c31205b743745caf4d172659d485480459bd4b9873b4c
|
|
7
|
+
data.tar.gz: 2a6974c2881e98b4580a175be710567a4a5b82468620f3758a910817d7d746a73e4783d2a1b5e436d300cf7c047d075c595dd8ccd04eeb05b99d6d31daf3dde0
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.5.3] - 2025-11-21
|
|
4
|
+
|
|
5
|
+
- Fix syntax error
|
|
6
|
+
|
|
7
|
+
## [0.5.2] - 2025-11-21
|
|
8
|
+
|
|
9
|
+
- Fix for missing `escape_globs`, refactoring of calling automation classes
|
|
10
|
+
|
|
3
11
|
## [0.5.1] - 2025-11-21
|
|
4
12
|
|
|
5
13
|
- Only check class `exit_on_failure?` if it has been defined
|
|
@@ -24,7 +24,7 @@ module Freyia
|
|
|
24
24
|
def create_file(destination, *args, &block)
|
|
25
25
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
|
26
26
|
data = args.first
|
|
27
|
-
|
|
27
|
+
CreateFile.new(self, destination, block || data.to_s, config).()
|
|
28
28
|
end
|
|
29
29
|
alias_method :add_file, :create_file
|
|
30
30
|
|
|
@@ -53,13 +53,13 @@ module Freyia
|
|
|
53
53
|
#
|
|
54
54
|
def render
|
|
55
55
|
@render ||= if data.is_a?(Proc)
|
|
56
|
-
data.
|
|
56
|
+
data.()
|
|
57
57
|
else
|
|
58
58
|
data
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
def
|
|
62
|
+
def call
|
|
63
63
|
invoke_with_conflict_check do
|
|
64
64
|
require "fileutils"
|
|
65
65
|
FileUtils.mkdir_p(File.dirname(destination))
|
|
@@ -19,7 +19,7 @@ module Freyia
|
|
|
19
19
|
def create_link(destination, *args)
|
|
20
20
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
|
21
21
|
source = args.first
|
|
22
|
-
|
|
22
|
+
CreateLink.new(self, destination, source, config).()
|
|
23
23
|
end
|
|
24
24
|
alias_method :add_link, :create_link
|
|
25
25
|
|
|
@@ -39,7 +39,7 @@ module Freyia
|
|
|
39
39
|
exists? && File.identical?(source, destination)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def
|
|
42
|
+
def call
|
|
43
43
|
invoke_with_conflict_check do
|
|
44
44
|
require "fileutils"
|
|
45
45
|
FileUtils.mkdir_p(File.dirname(destination))
|
|
@@ -51,7 +51,7 @@ module Freyia
|
|
|
51
51
|
def directory(source, *args, &)
|
|
52
52
|
config = args.last.is_a?(Hash) ? args.pop : {}
|
|
53
53
|
destination = args.first || source
|
|
54
|
-
|
|
54
|
+
Directory.new(self, source, destination || source, config, &).()
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
class Directory < EmptyDirectory #:nodoc:
|
|
@@ -59,13 +59,13 @@ module Freyia
|
|
|
59
59
|
|
|
60
60
|
def initialize(base, source, destination = nil, config = {}, &block)
|
|
61
61
|
@source = File.expand_path(
|
|
62
|
-
Dir[
|
|
62
|
+
Dir[Automations.escape_globs(base.find_in_source_paths(source.to_s))].first
|
|
63
63
|
)
|
|
64
64
|
@block = block
|
|
65
65
|
super(base, destination, { recursive: true }.merge(config))
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
def
|
|
68
|
+
def call
|
|
69
69
|
base.empty_directory given_destination, config
|
|
70
70
|
execute!
|
|
71
71
|
end
|
|
@@ -77,7 +77,7 @@ module Freyia
|
|
|
77
77
|
protected
|
|
78
78
|
|
|
79
79
|
def execute! # rubocop:todo Metrics
|
|
80
|
-
lookup =
|
|
80
|
+
lookup = Automations.escape_globs(source)
|
|
81
81
|
lookup = File.join(lookup, "**") if config[:recursive]
|
|
82
82
|
lookup = file_level_lookup(lookup)
|
|
83
83
|
|
|
@@ -13,7 +13,7 @@ module Freyia
|
|
|
13
13
|
# empty_directory "doc"
|
|
14
14
|
#
|
|
15
15
|
def empty_directory(destination, config = {})
|
|
16
|
-
|
|
16
|
+
EmptyDirectory.new(self, destination, config).()
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# Class which holds create directory logic. This is the base class for
|
|
@@ -48,7 +48,7 @@ module Freyia
|
|
|
48
48
|
::File.exist?(destination)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def
|
|
51
|
+
def call
|
|
52
52
|
invoke_with_conflict_check do
|
|
53
53
|
require "fileutils"
|
|
54
54
|
::FileUtils.mkdir_p(destination)
|
|
@@ -36,7 +36,7 @@ module Freyia
|
|
|
36
36
|
config[:after] = %r{\z} unless config.key?(:before) || config.key?(:after)
|
|
37
37
|
config = config.merge({ error_on_no_change: true })
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
InjectIntoFile.new(self, destination, data, config).()
|
|
40
40
|
end
|
|
41
41
|
alias_method :inject_into_file!, :insert_into_file!
|
|
42
42
|
|
|
@@ -66,7 +66,7 @@ module Freyia
|
|
|
66
66
|
config = args.shift || {}
|
|
67
67
|
config[:after] = %r{\z} unless config.key?(:before) || config.key?(:after)
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
InjectIntoFile.new(self, destination, data, config).()
|
|
70
70
|
end
|
|
71
71
|
alias_method :inject_into_file, :insert_into_file
|
|
72
72
|
|
|
@@ -82,12 +82,12 @@ module Freyia
|
|
|
82
82
|
[:before, @config.delete(:before)]
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
@replacement = data.is_a?(Proc) ? data.
|
|
85
|
+
@replacement = data.is_a?(Proc) ? data.() : data
|
|
86
86
|
@flag = Regexp.escape(@flag) unless @flag.is_a?(Regexp)
|
|
87
87
|
@error_on_no_change = @config.fetch(:error_on_no_change, false)
|
|
88
88
|
end
|
|
89
89
|
|
|
90
|
-
def
|
|
90
|
+
def call # rubocop:todo Metrics
|
|
91
91
|
content = if @behavior == :after
|
|
92
92
|
"\\0#{replacement}"
|
|
93
93
|
else
|
data/lib/freyia/automations.rb
CHANGED
|
@@ -9,10 +9,16 @@ require_relative "automations/inject_into_file"
|
|
|
9
9
|
|
|
10
10
|
module Freyia
|
|
11
11
|
module Automations
|
|
12
|
-
#
|
|
12
|
+
# Returns a string that has had any glob characters escaped.
|
|
13
|
+
# The glob characters are `* ? { } [ ]`.
|
|
13
14
|
#
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
# @example
|
|
16
|
+
# Freya::Automations.escape_globs('[apps]') # => '\[apps\]'
|
|
17
|
+
#
|
|
18
|
+
# @param path [String]
|
|
19
|
+
# @return [String]
|
|
20
|
+
def self.escape_globs(path)
|
|
21
|
+
path.to_s.gsub(%r{[*?{}\[\]]}, '\\\\\\&')
|
|
16
22
|
end
|
|
17
23
|
|
|
18
24
|
# Returns the root for this freyia class (also aliased as destination root).
|
|
@@ -185,7 +191,7 @@ module Freyia
|
|
|
185
191
|
|
|
186
192
|
abort if !success &&
|
|
187
193
|
config.fetch(:abort_on_failure,
|
|
188
|
-
self.class.respond_to(:exit_on_failure?) && self.class.exit_on_failure?)
|
|
194
|
+
self.class.respond_to?(:exit_on_failure?) && self.class.exit_on_failure?)
|
|
189
195
|
|
|
190
196
|
result
|
|
191
197
|
end
|
data/lib/freyia/version.rb
CHANGED