New Upstream Snapshot - ruby-filepath

Ready changes

Summary

Merged new upstream version: 0.7+git20171224.1.44ec0cf (was: 0.7).

Resulting package

Built on 2023-01-19T15:20 (took 4m39s)

The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:

apt install -t fresh-snapshots ruby-filepath

Lintian Result

Diff

diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 0698218..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-/.bundle/
-/Gemfile.lock
-/coverage/
-/doc/
-/pkg/
-/.yardoc/
-/spec/fixtures/
diff --git a/debian/changelog b/debian/changelog
index 775fb4f..f8390ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-filepath (0.7-2) UNRELEASED; urgency=medium
+ruby-filepath (0.7+git20171224.1.44ec0cf-1) UNRELEASED; urgency=medium
 
   [ Utkarsh Gupta ]
   * Add salsa-ci.yml
@@ -12,8 +12,9 @@ ruby-filepath (0.7-2) UNRELEASED; urgency=medium
   * Set upstream metadata fields: Bug-Database, Bug-Submit.
   * Update watch file format version to 4.
   * Bump debhelper from old 12 to 13.
+  * New upstream snapshot.
 
- -- Utkarsh Gupta <guptautkarsh2102@gmail.com>  Tue, 13 Aug 2019 04:48:55 +0530
+ -- Utkarsh Gupta <guptautkarsh2102@gmail.com>  Thu, 19 Jan 2023 15:16:43 -0000
 
 ruby-filepath (0.7-1) unstable; urgency=medium
 
diff --git a/debian/patches/0001-Require-RSpec-in-helper.patch b/debian/patches/0001-Require-RSpec-in-helper.patch
index 76bbebc..9642186 100644
--- a/debian/patches/0001-Require-RSpec-in-helper.patch
+++ b/debian/patches/0001-Require-RSpec-in-helper.patch
@@ -6,8 +6,10 @@ Subject: Require RSpec in helper
  spec/spec_helper.rb | 2 ++
  1 file changed, 2 insertions(+)
 
---- a/spec/spec_helper.rb
-+++ b/spec/spec_helper.rb
+Index: ruby-filepath.git/spec/spec_helper.rb
+===================================================================
+--- ruby-filepath.git.orig/spec/spec_helper.rb
++++ ruby-filepath.git/spec/spec_helper.rb
 @@ -1,6 +1,8 @@
  LIB_DIR = File.expand_path(File.join(File.dirname(__FILE__), %w[.. lib]))
  $LOAD_PATH.unshift(LIB_DIR) unless $LOAD_PATH.include?(LIB_DIR)
diff --git a/debian/patches/0002-Avoid-requiring-bundler-in-Rakefile.patch b/debian/patches/0002-Avoid-requiring-bundler-in-Rakefile.patch
index 93dee59..428abe8 100644
--- a/debian/patches/0002-Avoid-requiring-bundler-in-Rakefile.patch
+++ b/debian/patches/0002-Avoid-requiring-bundler-in-Rakefile.patch
@@ -6,10 +6,10 @@ Subject: Avoid requiring bundler in Rakefile
  Rakefile | 1 -
  1 file changed, 1 deletion(-)
 
-diff --git a/Rakefile b/Rakefile
-index 9e1a46b..fbcf4d6 100644
---- a/Rakefile
-+++ b/Rakefile
+Index: ruby-filepath.git/Rakefile
+===================================================================
+--- ruby-filepath.git.orig/Rakefile
++++ ruby-filepath.git/Rakefile
 @@ -1,6 +1,5 @@
  # This is free software released into the public domain (CC0 license).
  
diff --git a/debian/patches/0003-Avoid-readability-test.patch b/debian/patches/0003-Avoid-readability-test.patch
index cfe6ffd..2f1dd89 100644
--- a/debian/patches/0003-Avoid-readability-test.patch
+++ b/debian/patches/0003-Avoid-readability-test.patch
@@ -9,11 +9,11 @@ test will fail.
  spec/filepath_spec.rb | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/spec/filepath_spec.rb b/spec/filepath_spec.rb
-index a35e300..9aec448 100644
---- a/spec/filepath_spec.rb
-+++ b/spec/filepath_spec.rb
-@@ -565,7 +565,7 @@ describe FilePath do
+Index: ruby-filepath.git/spec/filepath_spec.rb
+===================================================================
+--- ruby-filepath.git.orig/spec/filepath_spec.rb
++++ ruby-filepath.git/spec/filepath_spec.rb
+@@ -592,7 +592,7 @@ describe Filepath do
  		end
  
  		describe "#chmod" do
diff --git a/filepath.gemspec b/filepath.gemspec
index 71dcaae..35afb5c 100644
--- a/filepath.gemspec
+++ b/filepath.gemspec
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
 
 Gem::Specification.new do |spec|
 	spec.name          = "filepath"
-	spec.version       = "0.7"
+	spec.version       = "0.8.dev"
 	spec.authors       = ["Gioele Barabucci"]
 	spec.email         = ["gioele@svario.it"]
 	spec.summary       = "A small library to manipulate paths; a modern replacement " +
diff --git a/lib/filepath/filepath.rb b/lib/filepath/filepath.rb
index 86eedcd..faf399e 100644
--- a/lib/filepath/filepath.rb
+++ b/lib/filepath/filepath.rb
@@ -1,6 +1,3 @@
-# This is free software released into the public domain (CC0 license).
-
-
 class Filepath
 	SEPARATOR = '/'.freeze
 
@@ -31,6 +28,7 @@ class Filepath
 
 		segs = []
 		paths.each { |path| segs += path.segments }
+		segs.reject!.with_index { |seg, idx| !idx.zero? && seg == '/' }
 
 		return Filepath.new(segs)
 	end
@@ -377,6 +375,44 @@ class Filepath
 	alias :remove_extension :without_extension
 
 
+	# Adds an extension to the current file extension
+	#
+	# @see #extension
+	# @see #extension?
+	# @see #with_extension
+	# @see #without_extension
+	#
+	# Replaces the file extension with the supplied one. If the file
+	# has no extension it is added to the filename together with a dot.
+	#
+	# @example Addition of an extension
+	#
+	#     tar_path = "archives/docs.tar".as_path
+	#     compressed_path = tar_path.add_extension("gz")
+	#     compressed_path.to_s #=> "archives/docs.tar.gz"
+	#
+	# @example Addition of an extension to a filename without extensions
+	#
+	#     dir_path = "archives/2016".as_path
+	#     zip_path = dir_path.add_extension("zip")
+	#     zip_path.to_s #=> "archives/2016.zip"
+	#
+	# @param [String] extra_ext the extension to add
+	#
+	# @return [Filepath] a new path with the given extension added to the existing extensions
+
+	def add_extension(extra_ext)
+		if !self.extension.nil?
+			old_ext = self.extension
+			new_ext = old_ext + '.' + extra_ext
+		else
+			new_ext = extra_ext
+		end
+
+		return self.with_extension(new_ext)
+	end
+
+
 	# Matches a pattern against this path.
 	#
 	# @param [Regexp, Object] pattern the pattern to match against
@@ -463,6 +499,26 @@ class Filepath
 
 	alias :normalised :normalized
 
+
+	# Expands tilde to the user's home directory
+	#
+	# The tilde character (i.e. `~`) will be expanded into the
+	# path of the user's home directory according to the rules
+	# of [`File#expand_path`](https://ruby-doc.org/core/File.html#method-c-expand_path).
+	#
+	# @example
+	#
+	#     path = "~/.config".as_path
+	#     path.expanded_tilde #=> </home/mel/.config>
+	#
+	# @return [Filepath] a new path in which the tilde character
+	#                    has been expanded into the path of the
+	#                    user's home directory.
+
+	def expanded_tilde
+		return Filepath.new(File.expand_path(self))
+	end
+
 	# Iterates over all the path segments, from the leftmost to the
 	# rightmost.
 	#
@@ -646,6 +702,10 @@ class Filepath
 	# @note this method compares the normalized versions of the paths
 
 	def ==(other)
+		if !other.respond_to?(:as_path)
+			return false
+		end
+
 		return self.normalized_segments == other.as_path.normalized_segments
 	end
 
@@ -749,6 +809,18 @@ class Filepath
 				return FileTest.send(filetest_method, self)
 			end
 		end
+
+		# @private
+		def define_fileutils_method(filepath_method, fileutils_method = nil)
+			if !defined?(FileUtils)
+				return
+			end
+
+			fileutils_method ||= filepath_method
+			define_method(filepath_method) do
+				return FileUtils.send(fileutils_method, self)
+			end
+		end
 	end
 
 	module MetadataInfo
@@ -846,10 +918,25 @@ class Filepath
 	end
 
 	module FilesystemChanges
+		extend MethodDelegation
+
 		def touch
 			self.open('a') do ; end
 			File.utime(File.atime(self), Time.now, self)
 		end
+
+		def touch_p
+			self.parent_dir.mkdir_p
+			self.touch
+		end
+
+		define_fileutils_method :mkdir
+		define_fileutils_method :mkdir_p
+
+		define_fileutils_method :rm
+		define_fileutils_method :rm_f
+		define_fileutils_method :rm_r
+		define_fileutils_method :rm_rf
 	end
 
 	module FilesystemTests
@@ -927,7 +1014,7 @@ class Filepath
 			glob /= '**' if recursive
 			glob /= pattern
 
-			raw_entries = Dir.glob(glob)
+			raw_entries = Dir.glob(glob, File::FNM_DOTMATCH).reject { |e| e =~  %r{(^|/)(\.|\.\.)$} }
 			entries = FilepathList.new(raw_entries)
 
 			return entries
@@ -979,3 +1066,5 @@ class Filepath
 
 	include SearchMethods
 end
+
+# This is free software released into the public domain (CC0 license).
diff --git a/spec/filepath_spec.rb b/spec/filepath_spec.rb
index b71cb70..ca1fef8 100644
--- a/spec/filepath_spec.rb
+++ b/spec/filepath_spec.rb
@@ -22,6 +22,7 @@ describe Filepath do
 			['foo', '.', 'foo'],
 			['foo', '..', '.'],
 			['foo/bar', 'baz', 'foo/bar/baz'],
+			['foo', '/bar', 'foo/bar'],
 			['', 'foo/bar', './foo/bar'],
 		]
 		test_data.each do |base, extra, result|
@@ -246,6 +247,20 @@ describe Filepath do
 		end
 	end
 
+	describe "#add_extension" do
+		test_data = [
+			['foo', 'e1', 'foo.e1'],
+			['foo.e1', 'e2', 'foo.e1.e2'],
+			['foo.e1.e2', 'e3', 'foo.e1.e2.e3'],
+		]
+		test_data.each do |path, ext, result|
+			it "turns `#{path}` with `#{ext}` into `#{result}`" do
+				new = Filepath.new(path).add_extension(ext)
+				new.basename.to_s.should == result
+			end
+		end
+	end
+
 	describe "=~" do
 		it "matches `/foo/bar` with /foo/" do
 			Filepath.new('/foo/bar').should =~ /foo/
@@ -313,6 +328,18 @@ describe Filepath do
 		end
 	end
 
+	describe "#expanded_tilde" do
+		it "expands the tilde to the user home directory" do
+			home = ENV['HOME']
+			ENV['HOME'] = '/home/mel'
+			path = "~/.config".as_path
+			path_expanded = path.expanded_tilde
+			ENV['HOME'] = home
+
+			path_expanded.should eq("/home/mel/.config")
+		end
+	end
+
 	describe "#each_segment" do
 		it "goes through all the segments of an absolute path" do
 			steps = []

Debdiff

[The following lists of changes regard files as different if they have different names, permissions or owners.]

Files in second set of .debs but not in first

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/filepath-0.8.dev.gemspec

Files in first set of .debs but not in second

-rw-r--r--  root/root   /usr/share/rubygems-integration/all/specifications/filepath-0.7.gemspec

No differences were encountered in the control files

More details

Full run details