foobara-files-generator 0.1.3 → 0.1.4
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/src/symlink.rb +43 -0
- data/src/write_generated_files_to_disk.rb +13 -1
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8cf98ecb24a6c06ed9168b0dbf7c14a4d6aa19b7a0365684634a295de86fed57
|
|
4
|
+
data.tar.gz: 2626b68d7005938cc276c044523857154aee0fbde4a4ce1717df847b7dc35cbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 65e71db48ca1463143cfbab679dba25423992018fddc5fe19858d2d7ccd8f5bd355600e4bb47727ac45e23c08a5b759b3e92908521422a6e07ac7c8b43356a52
|
|
7
|
+
data.tar.gz: a51167675d456aa2686f283f1679c929471d28f233f8599e7fc6d0909f0a7a392d224166ebc094fe25ffc00f7cf75359ed7129979717e44ff7396b7795de89f5
|
data/CHANGELOG.md
CHANGED
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
|
|
@@ -55,7 +55,19 @@ module Foobara
|
|
|
55
55
|
def write_file_to_disk(path, contents)
|
|
56
56
|
path = "#{output_directory}/#{path}"
|
|
57
57
|
FileUtils.mkdir_p(File.dirname(path))
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
if contents.is_a?(FilesGenerator::Symlink)
|
|
60
|
+
if FilesGenerator::Symlink.supported?
|
|
61
|
+
File.symlink(contents, path)
|
|
62
|
+
# simplecov:disable
|
|
63
|
+
else
|
|
64
|
+
# TODO: come up with a way to test this path
|
|
65
|
+
FileUtils.cp_r(contents, path)
|
|
66
|
+
# simplecov:enable
|
|
67
|
+
end
|
|
68
|
+
else
|
|
69
|
+
File.write(path, contents)
|
|
70
|
+
end
|
|
59
71
|
end
|
|
60
72
|
|
|
61
73
|
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.
|
|
4
|
+
version: 0.1.4
|
|
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
|
- - ">="
|