remove_file_suffix 1.0.7

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9fa918c6d7c0932367c0338bbb46db8034bf270207609b66b253c94428cf5312
4
+ data.tar.gz: 8e3c7fdcfe9fb5e2eb92d40c13ae61820c3cdf101fdbd7a416416c35f7444cd8
5
+ SHA512:
6
+ metadata.gz: d3815d0531ec6fdceecd69fcf18cc34f3cd21edee7d726561efdbf4d29981520d651aeb2d6c3837bc9132367344df6b07a89fed95431f9df44ca60856e24e2df
7
+ data.tar.gz: '0374864240274813091a479a433d94f44f2fa7b9d7585f012122778c78704cd9ce90d94a26f8b464f2146bfd0ee0efbaa696cc3b1af1d3a6c31224b12e256adb'
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'remove_file_suffix/constants.rb'
6
+ # =========================================================================== #
7
+ module RemoveFileSuffix
8
+
9
+ # ========================================================================= #
10
+ # === REMOVE_UNUSUAL_SUFFIXES
11
+ #
12
+ # If the following constant is set to true, then we will also get rid
13
+ # of e. g. "-source" names.
14
+ # ========================================================================= #
15
+ REMOVE_UNUSUAL_SUFFIXES = true
16
+
17
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === RemoveFileSuffix
6
+ #
7
+ # To use this module in your project, try something like the following:
8
+ #
9
+ # require 'remove_file_suffix'
10
+ # RemoveFileSuffix[i]
11
+ #
12
+ # =========================================================================== #
13
+ # require 'remove_file_suffix/remove_file_suffix.rb'
14
+ # =========================================================================== #
15
+ require 'remove_file_suffix/constants.rb'
16
+
17
+ module RemoveFileSuffix
18
+
19
+ # ========================================================================= #
20
+ # === RemoveFileSuffix.remove_file_suffix(i)
21
+ #
22
+ # Class method here. The order should be kept, IMO. We get rid of the
23
+ # file suffix.
24
+ #
25
+ # Note that .sub() for .tar should come after .gz and .xz, because
26
+ # .tar is typically coming before these two as well, such as in a
27
+ # ".tar.gz" file. Hence we first eliminate .gz in the following
28
+ # batch .sub listing.
29
+ #
30
+ # Would it not be easier to just use File.basename() instead? We will
31
+ # try this since Jan 2014. Hmm nope, won't work.
32
+ # ========================================================================= #
33
+ def self.remove_file_suffix(i)
34
+ i = i.dup if i.frozen?
35
+ i = i.sub(/\.bz2$/, ''). # Get rid of .bz2
36
+ sub(/\.gz$/, ''). # Get rid of .gz
37
+ sub(/\.zip$/, ''). # Get rid of .zip
38
+ sub(/\.xz$/, ''). # Get rid of .xz
39
+ sub(/\.Z$/, ''). # Get rid of .Z
40
+ sub(/\.tar$/, ''). # Get rid of .tar
41
+ sub(/\.tgz$/, ''). # Get rid of .tgz
42
+ sub(/\.gem$/, ''). # Get rid of .gem
43
+ sub(/\.yml$/, ''). # Get rid of .yml
44
+ sub(/\.js$/, '') # Get rid of .js
45
+ if REMOVE_UNUSUAL_SUFFIXES
46
+ i.sub!(/-source/,'')
47
+ end
48
+ return i
49
+ end
50
+
51
+ # ========================================================================= #
52
+ # === remove_file_suffix
53
+ #
54
+ # This method will properly remove a file suffix.
55
+ # ========================================================================= #
56
+ def remove_file_suffix(i)
57
+ RemoveFileSuffix.remove_file_suffix(i)
58
+ end
59
+
60
+ # ========================================================================= #
61
+ # === RemoveFileSuffix[]
62
+ # ========================================================================= #
63
+ def self.[](i)
64
+ remove_file_suffix(i)
65
+ end
66
+
67
+ end
68
+
69
+ # =========================================================================== #
70
+ # Testing this module next:
71
+ # =========================================================================== #
72
+ if __FILE__ == $PROGRAM_NAME
73
+ p RemoveFileSuffix['foobar-1.2.0.tar.xz']
74
+ end # rb remove_file_suffix.rb
@@ -0,0 +1 @@
1
+ require 'remove_file_suffix/remove_file_suffix.rb'
@@ -0,0 +1,36 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project RemoveFileSuffix.
3
+ # =========================================================================== #
4
+ require 'roebe'
5
+
6
+ Gem::Specification.new { |s|
7
+
8
+ s.name = 'remove_file_suffix'
9
+ s.version = '1.0.7'
10
+ s.date = Time.now.strftime('%Y-%m-%d')
11
+
12
+ DESCRIPTION = <<-EOF
13
+
14
+ This simple module allows you to remove file suffixes
15
+ from a given input.
16
+
17
+ Example for this:
18
+
19
+ RemoveFileSuffix['foobar-1.0.0.tar.xz']
20
+
21
+ EOF
22
+
23
+ s.summary = DESCRIPTION
24
+ s.description = DESCRIPTION
25
+
26
+ s.authors = ['Robert A. Heiler']
27
+ s.email = Roebe.email?
28
+ s.files = Dir['**/*']
29
+ s.license = 'MIT'
30
+ s.homepage = 'https://rubygems.org/gems/remove_file_suffix'
31
+
32
+ s.required_ruby_version = '>= '+RUBY_VERSION
33
+ s.required_rubygems_version = '>= '+Gem::VERSION
34
+ s.rubygems_version = '>= '+Gem::VERSION
35
+
36
+ }
@@ -0,0 +1,7 @@
1
+ require 'alias_e/autoinclude'
2
+ require 'remove_file_suffix'
3
+ e RemoveFileSuffix['foobar-1.2.0.tar.xz']
4
+ e RemoveFileSuffix['barbla-1.2.0.bz2']
5
+ e RemoveFileSuffix['librep-0.92.5.tar.xz']
6
+ e RemoveFileSuffix['librep-0.92.5']
7
+ e RemoveFileSuffix['http://www.cups.org/software/2.1.3/cups-2.1.3-source.tar.bz2']
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remove_file_suffix
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.7
5
+ platform: ruby
6
+ authors:
7
+ - Robert A. Heiler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-04-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2+
14
+
15
+ This simple module allows you to remove file suffixes
16
+ from a given input.
17
+
18
+ Example for this:
19
+
20
+ RemoveFileSuffix['foobar-1.0.0.tar.xz']
21
+
22
+ email: shevy@inbox.lt
23
+ executables: []
24
+ extensions: []
25
+ extra_rdoc_files: []
26
+ files:
27
+ - lib/remove_file_suffix.rb
28
+ - lib/remove_file_suffix/constants.rb
29
+ - lib/remove_file_suffix/remove_file_suffix.rb
30
+ - remove_file_suffix.gemspec
31
+ - test/testing_remove_file_suffix.rb
32
+ homepage: https://rubygems.org/gems/remove_file_suffix
33
+ licenses:
34
+ - MIT
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 3.1.1
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 3.3.10
50
+ requirements: []
51
+ rubygems_version: 3.3.10
52
+ signing_key:
53
+ specification_version: 4
54
+ summary: 'This simple module allows you to remove file suffixes from a given input. Example
55
+ for this: RemoveFileSuffix[''foobar-1.0.0.tar.xz'']'
56
+ test_files: []
57
+ ...