symlink 0.0.23

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of symlink might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3414c65443100ebdbabcb9dc27386fc4fc94203a5156ca43c92b26295949221a
4
+ data.tar.gz: da7586e51b26e08e5e7550967b34c090b2aab0a5fd914a7e7ee5efd6812c7bd0
5
+ SHA512:
6
+ metadata.gz: 92a1f0eaf3a7a286850762f213322f934caebafdb04337a8871eba990ce23ccf3ae3e4bc6b1d8267d4dc030ba7ce9c7b108f9efbbebc11781f92c7e04387b348
7
+ data.tar.gz: d7325df1023399420b041bf43fdab6e5cb46e86baea8916eb911a4a121e5c7691bd2b06602bd79882c2248ea7ac4544da9f5a8d67e52b29db8011af2b4385507
@@ -0,0 +1 @@
1
+ require 'symlink/symlink.rb'
@@ -0,0 +1,17 @@
1
+ #!/System/Index/bin/ruby -w
2
+ # Encoding: ISO-8859-1
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ class Symlink
6
+
7
+ # ========================================================================= #
8
+ # === NAMESPACE
9
+ # ========================================================================= #
10
+ NAMESPACE = inspect
11
+
12
+ # ========================================================================= #
13
+ # === USE_ABSOLUTE_SYMLINKING
14
+ # ========================================================================= #
15
+ USE_ABSOLUTE_SYMLINKING = false
16
+
17
+ end
@@ -0,0 +1,306 @@
1
+ #!/System/Index/bin/ruby -w
2
+ # Encoding: ISO-8859-1
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Symlink
6
+ #
7
+ # This general class will allow you to symlink one target to the other.
8
+ #
9
+ # Usage example:
10
+ # Symlink.new
11
+ # =========================================================================== #
12
+ # require 'symlink/symlink.rb'
13
+ # =========================================================================== #
14
+ require 'fileutils'
15
+ require 'opn'
16
+ # =========================================================================== #
17
+ # Add a few colours for support:
18
+ # =========================================================================== #
19
+ require 'colours/e/e.rb'
20
+ require 'colours/requires/require_sdir.rb'
21
+ require 'colours/requires/require_sfile.rb'
22
+ # =========================================================================== #
23
+ # And next pull in .rb files that are specific for Symlink:
24
+ # =========================================================================== #
25
+ require 'symlink/version/version.rb'
26
+ require 'symlink/constants.rb'
27
+
28
+ class Symlink # === Symlink.new
29
+
30
+ include Colours::E
31
+
32
+ # ========================================================================= #
33
+ # === initialize
34
+ # ========================================================================= #
35
+ def initialize(
36
+ old_existing_location,
37
+ new_location,
38
+ be_verbose = true,
39
+ run_already = true
40
+ )
41
+ reset
42
+ set_existing_location(old_existing_location) # from
43
+ set_new_location(new_location) # to
44
+ set_be_verbose(be_verbose) # Whether we are silent or not.
45
+ if block_given?
46
+ yielded = yield
47
+ if yielded.is_a? Hash
48
+ if yielded.has_key? :prepend_this_to_namespace
49
+ prepend_this_to_namespace(yielded.delete(:prepend_this_to_namespace))
50
+ end
51
+ end
52
+ end
53
+ if run_already == :do_not_run_yet
54
+ run_already = false
55
+ end
56
+ run if run_already
57
+ end
58
+
59
+ # ========================================================================= #
60
+ # === prepend_this_to_namespace
61
+ # ========================================================================= #
62
+ def prepend_this_to_namespace(i)
63
+ @namespace.prepend(i.to_s.dup)
64
+ end
65
+
66
+ # ========================================================================= #
67
+ # === reset (reset tag)
68
+ # ========================================================================= #
69
+ def reset
70
+ @use_absolute_symlinking = USE_ABSOLUTE_SYMLINKING
71
+ @use_opn = true
72
+ @be_verbose = true
73
+ @use_colours = true
74
+ @namespace = NAMESPACE # This can be changed.
75
+ end
76
+
77
+ # ========================================================================= #
78
+ # === shall_we_use_colours?
79
+ #
80
+ # This method requires one mandatory argument.
81
+ # ========================================================================= #
82
+ def shall_we_use_colours?(true_or_false)
83
+ if true_or_false == false
84
+ disable_colours
85
+ else
86
+ enable_colours
87
+ end
88
+ end
89
+
90
+ # ========================================================================= #
91
+ # === disable_colours
92
+ # ========================================================================= #
93
+ def disable_colours
94
+ @use_colours = false
95
+ end
96
+
97
+ # ========================================================================= #
98
+ # === enable_colours
99
+ # ========================================================================= #
100
+ def enable_colours
101
+ @use_colours = true
102
+ end
103
+
104
+ # ========================================================================= #
105
+ # === use_colours?
106
+ # ========================================================================= #
107
+ def use_colours?
108
+ @use_colours
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === use_absolute_symlinking
113
+ # ========================================================================= #
114
+ def use_absolute_symlinking
115
+ @use_absolute_symlinking = true
116
+ # ======================================================================= #
117
+ # We must also sync @existing_location.
118
+ # ======================================================================= #
119
+ set_existing_location(existing?)
120
+ end
121
+
122
+ # ========================================================================= #
123
+ # === set_be_verbose
124
+ # ========================================================================= #
125
+ def set_be_verbose(i)
126
+ @be_verbose = i
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === use_absolute_symlinking?
131
+ # ========================================================================= #
132
+ def use_absolute_symlinking?
133
+ @use_absolute_symlinking
134
+ end
135
+
136
+ # ========================================================================= #
137
+ # === set_existing_location
138
+ #
139
+ # This must be an existing file.
140
+ # ========================================================================= #
141
+ def set_existing_location(i = '')
142
+ i = i.first if i.is_a? Array
143
+ i = i.to_s.dup
144
+ i = rds(i)
145
+ if use_absolute_symlinking?
146
+ i = '../../../..'+i
147
+ end
148
+ @existing_location = i
149
+ end
150
+
151
+ # ========================================================================= #
152
+ # === delete
153
+ # ========================================================================= #
154
+ def delete(i)
155
+ i = i.dup if i.frozen?
156
+ i.strip!
157
+ if (rds(i) == '/')
158
+ ewarn 'We can never delete /'
159
+ else
160
+ File.delete(i)
161
+ end
162
+ end; alias remove delete # === remove
163
+
164
+ # ========================================================================= #
165
+ # === be_verbose?
166
+ # ========================================================================= #
167
+ def be_verbose?
168
+ @be_verbose
169
+ end
170
+
171
+ # ========================================================================= #
172
+ # === rds
173
+ # ========================================================================= #
174
+ def rds(i)
175
+ i.squeeze('/')
176
+ end
177
+
178
+ # ========================================================================= #
179
+ # === set_new_location
180
+ # ========================================================================= #
181
+ def set_new_location(i = '')
182
+ i = i.to_s.dup
183
+ i = rds(i)
184
+ @new_location = i
185
+ end; alias set_new_target set_new_location # === set_new_target
186
+
187
+ # ========================================================================= #
188
+ # === old?
189
+ # ========================================================================= #
190
+ def old?
191
+ @existing_location
192
+ end; alias existing? old? # === existing?
193
+ alias old_target? old? # === old_target?
194
+ alias from? old? # === from?
195
+
196
+ # ========================================================================= #
197
+ # === new?
198
+ # ========================================================================= #
199
+ def new?
200
+ @new_location
201
+ end; alias new_target? new? # === new_target?
202
+ alias to? new? # === to?
203
+
204
+ # ========================================================================= #
205
+ # === do_symlink
206
+ #
207
+ # This is the actual method that will perform the symlink-operation in
208
+ # question.
209
+ # ========================================================================= #
210
+ def do_symlink(be_verbose = be_verbose?)
211
+ # ======================================================================= #
212
+ # We must first check whether the target at new? exists or whether
213
+ # it does not.
214
+ # ======================================================================= #
215
+ if File.exist? new_target?
216
+ if File.directory?(new_target?) and File.file?(old_target?) # Silent renaming then.
217
+ _ = new_target?+File.basename(old_target?)
218
+ set_new_target(_)
219
+ end
220
+ if File.symlink? new_target?
221
+ delete(new_target?)
222
+ end
223
+ end
224
+ if be_verbose
225
+ opnn if use_opn?
226
+ e 'Symlinking '+sfile(existing?)+' into '+sfile(new_target?)+'.'
227
+ end
228
+ begin
229
+ File.symlink(existing?, new_target?)
230
+ rescue Errno::ENOENT => error # No such file or directory
231
+ opnn if use_opn?
232
+ e "Can not symlink - no such file exists, at `#{sfile(new_target?)}`."
233
+ pp error
234
+ rescue Errno::EEXIST => error # The file does not exist.
235
+ opnn if use_opn?
236
+ e "Can not symlink - the file at `#{sfile(new_target?)}` already exists."
237
+ pp error
238
+ end
239
+ end
240
+
241
+ # ========================================================================= #
242
+ # === do_not_use_opn
243
+ # ========================================================================= #
244
+ def do_not_use_opn
245
+ @use_opn = false
246
+ end; alias disable_opn do_not_use_opn # === disable_opn
247
+
248
+ # ========================================================================= #
249
+ # === use_opn?
250
+ # ========================================================================= #
251
+ def use_opn?
252
+ @use_opn
253
+ end
254
+
255
+ # ========================================================================= #
256
+ # === namespace?
257
+ # ========================================================================= #
258
+ def namespace?
259
+ @namespace
260
+ end
261
+
262
+ # ========================================================================= #
263
+ # === sfile
264
+ # ========================================================================= #
265
+ def sfile(i)
266
+ return Colours.sfile(i) if use_colours?
267
+ i
268
+ end
269
+
270
+ # ========================================================================= #
271
+ # === sdir
272
+ # ========================================================================= #
273
+ def sdir(i)
274
+ return Colours.sdir(i) if use_colours?
275
+ i
276
+ end
277
+
278
+ # ========================================================================= #
279
+ # === opnn
280
+ # ========================================================================= #
281
+ def opnn
282
+ Opn.opn(
283
+ namespace: @namespace,
284
+ use_colours: use_colours?
285
+ )
286
+ end
287
+
288
+ # ========================================================================= #
289
+ # === run (run tag)
290
+ # ========================================================================= #
291
+ def run
292
+ do_symlink
293
+ end
294
+
295
+ # ========================================================================= #
296
+ # === Symlink[]
297
+ # ========================================================================= #
298
+ def self.[](old, new)
299
+ self.new(old, new)
300
+ end
301
+
302
+ end
303
+
304
+ if __FILE__ == $PROGRAM_NAME
305
+ Symlink.new(ARGV.first, ARGV[1])
306
+ end # rubysymlink /Depot/j/foo.mp3 /Depot/j/bar.mp3
@@ -0,0 +1,12 @@
1
+ #!/System/Index/bin/ruby -w
2
+ # Encoding: ISO-8859-1
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ class Symlink
6
+
7
+ # ========================================================================= #
8
+ # === Symlink::VERSION
9
+ # ========================================================================= #
10
+ VERSION = '0.0.23'
11
+
12
+ end
@@ -0,0 +1,48 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Symlink.
3
+ # =========================================================================== #
4
+ require 'symlink/version/version.rb'
5
+
6
+ Gem::Specification.new { |s|
7
+
8
+ s.name = 'symlink'
9
+ s.version = Symlink::VERSION
10
+ s.date = Time.now.strftime('%Y-%m-%d')
11
+
12
+ DESCRIPTION = <<-EOF
13
+
14
+ This library is called symlink. It can be used to symlink
15
+ files or directories, from within ruby.
16
+
17
+ General syntax is:
18
+
19
+ Symlink.new(from, to)
20
+
21
+ If you have specific suggestions to make this gem more
22
+ useful for others, please drop me an email at:
23
+
24
+ shevegen@gmail.com
25
+
26
+ Thank you.
27
+ EOF
28
+
29
+ s.summary = DESCRIPTION
30
+ s.description = DESCRIPTION
31
+
32
+ s.extra_rdoc_files = %w()
33
+
34
+ s.authors = ['Robert A. Heiler']
35
+ s.email = 'shevegen@gmail.com'
36
+ s.files = Dir['**/*']
37
+
38
+ s.license = 'GPL-2.0'
39
+
40
+ s.required_ruby_version = '>= '+RUBY_VERSION
41
+ s.required_rubygems_version = '>= '+Gem::VERSION
42
+ s.rubygems_version = '>= '+Gem::VERSION
43
+
44
+ # Dependencies for the project:
45
+ s.add_dependency 'colours'
46
+ s.add_dependency 'opn'
47
+
48
+ }
@@ -0,0 +1,10 @@
1
+ #!/System/Index/bin/ruby -w
2
+ # Encoding: ISO-8859-1
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'symlink'
6
+ require 'colour_e/autoinclude'
7
+ Symlink[
8
+ '/Programs/Applewmproto/1.4.2/',
9
+ '/Programs/Applewmproto/Current'
10
+ ] # $RSRC/symlink/test/testing_symlink.rb
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: symlink
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.23
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colours
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: opn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |2
42
+
43
+ This library is called symlink. It can be used to symlink
44
+ files or directories, from within ruby.
45
+
46
+ General syntax is:
47
+
48
+ Symlink.new(from, to)
49
+
50
+ If you have specific suggestions to make this gem more
51
+ useful for others, please drop me an email at:
52
+
53
+ shevegen@gmail.com
54
+
55
+ Thank you.
56
+ email: shevegen@gmail.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - lib/symlink.rb
62
+ - lib/symlink/constants.rb
63
+ - lib/symlink/symlink.rb
64
+ - lib/symlink/version/version.rb
65
+ - symlink.gemspec
66
+ - test/testing_symlink.rb
67
+ homepage:
68
+ licenses:
69
+ - GPL-2.0
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 2.6.3
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 3.0.3
85
+ requirements: []
86
+ rubygems_version: 3.0.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: 'This library is called symlink. It can be used to symlink files or directories,
90
+ from within ruby. General syntax is: Symlink.new(from, to) If you have specific
91
+ suggestions to make this gem more useful for others, please drop me an email at: shevegen@gmail.com Thank
92
+ you.'
93
+ test_files: []