freyia 0.5.0 → 0.5.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bf6cf315bb9c907a5e521b072379f571e10440205bd34dec31f44b91c7f5eca
4
- data.tar.gz: 0f780348c2b60c049dba969b7a34f790739a7061003926a61a05c2624f0c77db
3
+ metadata.gz: d54ccbc4b592196cfe46016215a003b906914ef048207860adede0805a925d3b
4
+ data.tar.gz: 1284b8773037791455e7e30c6adef3152212b7a4a169d678fb0899ef227af1e1
5
5
  SHA512:
6
- metadata.gz: 8c0731ec3f312fb869009c1f4bddcae1d72a96f406bbf6f6f04a062fa372bd6b0a306c5c520fd5581dbb3b0954bd14c729a8180d3caccf8feba918d024f1427f
7
- data.tar.gz: 4bf4c0a3321169d742108f5ccda4af3e86b6f5cf5462d56d26a459f520bb05e8adebd9ea0b6ed94587a86aa9b2a12013428da0c5110a43ad3e038e006769d2b4
6
+ metadata.gz: 0c18007dcf382d0f6bfbdecf323583cad5e1e7d4dd8193af5533cd31ee5a06fef5e1f64bc925de6245df000a6391076fb29a5b6bb10ae8fddc2c5269b5eb64bd
7
+ data.tar.gz: 32c0d6fbf9ca5329e61630ce39457423e6afbf5b97bdd91aa3779a72aa69a0541b1ccd3f63c2c1491f46a408447965251269d5505ac7810bf8258057b9f8fce6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.5.2] - 2025-11-21
4
+
5
+ - Fix for missing `escape_globs`, refactoring of calling automation classes
6
+
7
+ ## [0.5.1] - 2025-11-21
8
+
9
+ - Only check class `exit_on_failure?` if it has been defined
10
+
3
11
  ## [0.5.0] - 2025-11-17
4
12
 
5
13
  - Initial creation of the Freyia gem, hard-fork of the shell/actions components of Thor
data/README.md CHANGED
@@ -4,6 +4,8 @@ Define and execute automated tasks in Ruby like the party girl you are! Let your
4
4
 
5
5
  > [!NOTE]
6
6
  > Freyia is a hard-fork of extracted shell/actions components from the [Thor](https://github.com/rails/thor) project, now modernized and usable in any Ruby application with any command line tooling.
7
+ >
8
+ > **Historical factoid:** Much of the original work on Thor actions and its serving as the substrate for Rails generators was done by [José Valim](https://github.com/josevalim), who is now well-known as the creator of the Elixir programming language. Some of that work was in turn based on the [Templater](https://github.com/jnicklas/templater) gem.
7
9
 
8
10
  ## Installation
9
11
 
@@ -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
- action CreateFile.new(self, destination, block || data.to_s, config)
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.call
56
+ data.()
57
57
  else
58
58
  data
59
59
  end
60
60
  end
61
61
 
62
- def invoke!
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
- action CreateLink.new(self, destination, source, config)
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 invoke!
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
- action Directory.new(self, source, destination || source, config, &)
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[Util.escape_globs(base.find_in_source_paths(source.to_s))].first
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 invoke!
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 = Util.escape_globs(source)
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
- action EmptyDirectory.new(self, destination, config)
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 invoke!
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
- action InjectIntoFile.new(self, destination, data, config)
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
- action InjectIntoFile.new(self, destination, data, config)
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.call : 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 invoke! # rubocop:todo Metrics
90
+ def call # rubocop:todo Metrics
91
91
  content = if @behavior == :after
92
92
  "\\0#{replacement}"
93
93
  else
@@ -9,10 +9,16 @@ require_relative "automations/inject_into_file"
9
9
 
10
10
  module Freyia
11
11
  module Automations
12
- # Wraps an action object and call it accordingly to the freyia class behavior.
12
+ # Returns a string that has had any glob characters escaped.
13
+ # The glob characters are `* ? { } [ ]`.
13
14
  #
14
- def action(instance) #:nodoc:
15
- instance.invoke!
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).
@@ -183,7 +189,9 @@ module Freyia
183
189
  success = result
184
190
  end
185
191
 
186
- abort if !success && config.fetch(:abort_on_failure, self.class.exit_on_failure?)
192
+ abort if !success &&
193
+ config.fetch(:abort_on_failure,
194
+ self.class.respond_to(:exit_on_failure?) && self.class.exit_on_failure?)
187
195
 
188
196
  result
189
197
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Freyia
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.2"
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freyia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jared White
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-11-18 00:00:00.000000000 Z
10
+ date: 2025-11-21 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Define and execute automated tasks like the party girl you are.
13
13
  email: