[SCM] ci-tooling packaging branch, master, updated. d136fcce5d4d58c0238cdae0b72fb60090fd051e
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Thu Oct 15 13:41:03 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=4077839
The following commit has been merged in the master branch:
commit 4077839bd524ef486802a5f793c253487dae4147
Author: Harald Sitter <sitter at kde.org>
Date: Thu Oct 15 11:52:42 2015 +0200
new tarball class to handle origification and possibly extract
---
lib/ci/tarball.rb | 36 ++++++++++++++++++++++++++++++++++++
test/test_ci_tarball.rb | 29 +++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/lib/ci/tarball.rb b/lib/ci/tarball.rb
new file mode 100644
index 0000000..ca48b9f
--- /dev/null
+++ b/lib/ci/tarball.rb
@@ -0,0 +1,36 @@
+module CI
+ class Tarball
+ attr_reader :path
+
+ def initialize(path)
+ @path = File.absolute_path(path)
+ end
+
+ def to_s
+ @path
+ end
+ alias_method :to_str, :to_s
+
+ def orig?
+ self.class.orig?(@path)
+ end
+
+ def origify
+ return self if orig?
+ clone.origify!
+ end
+
+ def origify!
+ return nil if orig?
+ name = File.basename(@path)
+ dir = File.dirname(@path)
+ match = name.match(/(?<name>.+)-(?<version>[\d.]+)\.(?<ext>tar(.*))/)
+ @path = "#{dir}/#{match[:name]}_#{match[:version]}.orig.#{match[:ext]}"
+ self
+ end
+
+ def self.orig?(path)
+ !File.basename(path).match(/(.+)_([\d.]+)\.orig\.tar(.*)/).nil?
+ end
+ end
+end
diff --git a/test/test_ci_tarball.rb b/test/test_ci_tarball.rb
new file mode 100644
index 0000000..ef834a5
--- /dev/null
+++ b/test/test_ci_tarball.rb
@@ -0,0 +1,29 @@
+require_relative 'lib/testcase'
+
+require_relative '../lib/ci/tarball'
+
+module CI
+ class TarballTest < TestCase
+ def test_string
+ s = File.absolute_path('d_1.0.orig.tar')
+ t = Tarball.new(s)
+ assert_equal(s, t.to_s)
+ assert_equal(s, t.to_str)
+ assert_equal(s, "#{t}") # coerce
+ end
+
+ def test_orig
+ assert_false(Tarball.orig?('a-1.0.tar'))
+ assert_false(Tarball.orig?('b_1.0.tar'))
+ assert_false(Tarball.orig?('c-1.0.orig.tar'))
+ assert(Tarball.orig?('d_1.0.orig.tar'))
+ end
+
+ def test_origify
+ t = Tarball.new('d_1.0.orig.tar').origify
+ assert_equal('d_1.0.orig.tar', File.basename(t.path))
+ t = Tarball.new('a-1.0.tar').origify
+ assert_equal('a_1.0.orig.tar', File.basename(t.path))
+ end
+ end
+end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list