foobara-files-generator 0.1.3 → 0.1.5

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: d8902970378e5b5c475b3783d81dde67390547e9bbbff283c1a3e13910058f79
4
- data.tar.gz: 0371ac6c3da3430e86e429bc978c0026f2291706592cbe4f1714e7ca4eee6533
3
+ metadata.gz: a3461e9456b77d42ef2b18982335d6dc249e4ab9d31aaa8021b53175994d1b6b
4
+ data.tar.gz: ce0b2ffa4258580acf8bdba8de4e02472e93bdcdff9a84da2e3195096e675312
5
5
  SHA512:
6
- metadata.gz: 49cc08590b93036f34993378578bf366e5e8e0bd77ec67f9ffbb4e05e979ed84c9a15c7d335d7511f59f82f48064cfa0d9fa2993e6a2d9b3d5b54dba423b24d8
7
- data.tar.gz: dd2cf8a5a1e96d22ddbb765d0f2469383bec94a636198bed897330198b5a4d2774a7cea1ecbad4766130a6809eb507faef9991d1e3930a56fd6c18c2a85ebb32
6
+ metadata.gz: 6f814407b5a575d59e94d54de20c793e50b9acb8a60c88ff08f0b7340bcad7c060df879da05925c3864e5282cac99de71daba7f2864ee967c0012581114d8308
7
+ data.tar.gz: fba7d452ac12189ed7507217e3b2478dfb34204690ed4afdf3202163300e2b3440bbd9e334e9fa1f5f6cf2f408a27ef805ac251a7793f275fb736bf88b237b15
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [0.1.5] - 2026-09-20
2
+
3
+ - Don't fail if symlink already exists
4
+
5
+ ## [0.1.4] - 2026-09-19
6
+
7
+ - Support creating symlinks
8
+
9
+ ## [0.1.3] - 2026-09-15
10
+
11
+ - Fix deprecation warnings
12
+
1
13
  ## [0.1.2] - 2026-02-02
2
14
 
3
15
  - Fix bug where fileutils might not have been required yet
data/src/symlink.rb ADDED
@@ -0,0 +1,43 @@
1
+ module Foobara
2
+ class FilesGenerator
3
+ class Symlink < String
4
+ @mutex = Mutex.new
5
+
6
+ class << self
7
+ def supported?
8
+ return @supported if defined?(@supported)
9
+ # simplecov:disable-next
10
+ return @supported if @mutex.nil?
11
+
12
+ @mutex.synchronize do
13
+ target_path = ".foobara-symlink-test-target"
14
+ symlink_path = ".foobara-symlink-test-link"
15
+
16
+ @supported = begin
17
+ FileUtils.rm_f(target_path)
18
+ FileUtils.rm_f(symlink_path)
19
+
20
+ File.write(target_path, "hi!")
21
+ File.symlink(target_path, symlink_path)
22
+
23
+ File.symlink?(symlink_path)
24
+ # TODO: figure out which of these actually happen in Windows
25
+ # rubocop:disable-next Lint/ShadowedException
26
+ rescue Errno::EACCES, NotImplementedError, SystemCallError
27
+ # TODO: come up with a way to test this
28
+ # simplecov:disable
29
+ false
30
+ # simplecov:enable
31
+ ensure
32
+ FileUtils.rm_f(target_path)
33
+ FileUtils.rm_f(symlink_path)
34
+ end
35
+
36
+ @mutex = nil
37
+ @supported
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -48,14 +48,32 @@ module Foobara
48
48
  end
49
49
 
50
50
  paths_to_source_code.map do |path, contents|
51
- Thread.new { write_file_to_disk(path, contents) unless path == generated_files_json_filename }
51
+ Thread.new do
52
+ write_file_to_disk(path, contents) unless path == generated_files_json_filename
53
+ end
52
54
  end.each(&:join)
53
55
  end
54
56
 
55
57
  def write_file_to_disk(path, contents)
56
58
  path = "#{output_directory}/#{path}"
57
59
  FileUtils.mkdir_p(File.dirname(path))
58
- File.write(path, contents)
60
+
61
+ if contents.is_a?(FilesGenerator::Symlink)
62
+ if FilesGenerator::Symlink.supported?
63
+ # simplecov:disable
64
+ unless File.symlink?(path)
65
+ # simplecov:enable
66
+ File.symlink(contents, path)
67
+ end
68
+ # simplecov:disable
69
+ else
70
+ # TODO: come up with a way to test this path
71
+ FileUtils.cp_r(contents, path)
72
+ # simplecov:enable
73
+ end
74
+ else
75
+ File.write(path, contents)
76
+ end
59
77
  end
60
78
 
61
79
  def generated_files_json_filename
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-files-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
@@ -44,6 +44,7 @@ files:
44
44
  - lib/foobara/files_generator/bundler_actions.rb
45
45
  - src/files_generator.rb
46
46
  - src/generate.rb
47
+ - src/symlink.rb
47
48
  - src/write_generated_files_to_disk.rb
48
49
  homepage: https://github.com/foobara/files-generator
49
50
  licenses:
@@ -62,6 +63,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
63
  - - ">="
63
64
  - !ruby/object:Gem::Version
64
65
  version: 3.4.0
66
+ - - "<"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.1'
65
69
  required_rubygems_version: !ruby/object:Gem::Requirement
66
70
  requirements:
67
71
  - - ">="