[SCM] ci-tooling packaging branch, master, updated. ba1b52193112a7a652f32c8ea25de340feb5e806

Rohan Garg rohangarg-guest at moszumanska.debian.org
Wed Apr 1 14:43:34 UTC 2015


Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=ba1b521

The following commit has been merged in the master branch:
commit ba1b52193112a7a652f32c8ea25de340feb5e806
Author: Rohan Garg <rohan at garg.io>
Date:   Wed Apr 1 16:43:04 2015 +0200

    Add OS module to parse /etc/os-release
---
 lib/{lsb.rb => os.rb}         |  8 ++++----
 test/data/test_os/test_consts |  9 +++++++++
 test/data/test_os/test_parse  |  9 +++++++++
 test/test_os.rb               | 39 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 4 deletions(-)

diff --git a/lib/lsb.rb b/lib/os.rb
similarity index 77%
copy from lib/lsb.rb
copy to lib/os.rb
index a8fbc26..4eb7045 100644
--- a/lib/lsb.rb
+++ b/lib/os.rb
@@ -1,9 +1,9 @@
 require 'shellwords'
 
-# Wrapper around lsb-release. Makes values available as non-introspectable
+# Wrapper around os-release. Makes values available as non-introspectable
 # constants. For runtime introspection to_h should be used instead.
-module LSB
-  @file = '/etc/lsb-release'
+module OS
+  @file = '/etc/os-release'
 
   def self.const_missing(name)
     return to_h[name] if to_h.key?(name)
@@ -13,7 +13,7 @@ module LSB
   module_function
 
   def to_h
-    @hash ||= LSB.parse(File.read(@file).split($/))
+    @hash ||= OS.parse(File.read(@file).split($/))
   end
 
   def reset
diff --git a/test/data/test_os/test_consts b/test/data/test_os/test_consts
new file mode 100644
index 0000000..6eaf810
--- /dev/null
+++ b/test/data/test_os/test_consts
@@ -0,0 +1,9 @@
+NAME="Medbuntu"
+VERSION="15.01 (Magical Ponies)"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Medbuntu 15.01"
+VERSION_ID="15.01"
+HOME_URL="http://www.medubuntu.com/"
+SUPPORT_URL="http://help.ubuntu.com/"
+BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
diff --git a/test/data/test_os/test_parse b/test/data/test_os/test_parse
new file mode 100644
index 0000000..6eaf810
--- /dev/null
+++ b/test/data/test_os/test_parse
@@ -0,0 +1,9 @@
+NAME="Medbuntu"
+VERSION="15.01 (Magical Ponies)"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Medbuntu 15.01"
+VERSION_ID="15.01"
+HOME_URL="http://www.medubuntu.com/"
+SUPPORT_URL="http://help.ubuntu.com/"
+BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
diff --git a/test/test_os.rb b/test/test_os.rb
new file mode 100644
index 0000000..31733d3
--- /dev/null
+++ b/test/test_os.rb
@@ -0,0 +1,39 @@
+require_relative '../lib/os'
+
+# Test os
+class OSTest < Test::Unit::TestCase
+  def setup
+    script_base_path = File.expand_path(File.dirname(__FILE__))
+    script_name = File.basename(__FILE__, '.rb')
+    @datadir = File.join(script_base_path, 'data', script_name)
+
+    @orig_file = OS.instance_variable_get(:@file)
+    OS.instance_variable_set(:@file, File.join(@datadir, method_name))
+    OS.reset
+  end
+
+  def teardown
+    OS.instance_variable_set(:@file, @orig_file)
+    OS.reset
+  end
+
+  def test_parse
+    ref = { :BUG_REPORT_URL => 'http://bugs.launchpad.net/ubuntu/',
+           :HOME_URL => 'http://www.medubuntu.com/',
+           :ID=>'ubuntu',
+      :ID_LIKE=>"debian",
+      :NAME=>"Medbuntu",
+      :PRETTY_NAME=>"Medbuntu 15.01",
+      :SUPPORT_URL=>"http://help.ubuntu.com/",
+      :VERSION=>"15.01 (Magical Ponies)",
+      :VERSION_ID=>"15.01"}
+    assert_equal(ref, OS.to_h)
+  end
+
+  def test_consts
+    assert_equal('Medbuntu', OS::NAME)
+    assert_raise NameError do
+      OS::FOOOOOOOOOOOOOOO
+    end
+  end
+end

-- 
ci-tooling packaging



More information about the pkg-kde-commits mailing list