[rubygem-openstack-compute] Initial import (#784857)

Bohuslav Kabrda bkabrda at fedoraproject.org
Fri Jan 27 13:24:19 UTC 2012


commit a54adfcfcb899e66272aac98368aa2914546f623
Author: Bohuslav Kabrda <bkabrda at redhat.com>
Date:   Fri Jan 27 14:24:11 2012 +0100

    Initial import (#784857)

 .gitignore                                     |    2 +
 openstack-compute-fix-tests-for-ruby-1.9.patch |   41 +++++++++++
 rubygem-openstack-compute.spec                 |   92 ++++++++++++++++++++++++
 sources                                        |    2 +
 4 files changed, 137 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..3adb85a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/openstack-compute-1.1.5-test.tgz
+/openstack-compute-1.1.5.gem
diff --git a/openstack-compute-fix-tests-for-ruby-1.9.patch b/openstack-compute-fix-tests-for-ruby-1.9.patch
new file mode 100644
index 0000000..88e0f0b
--- /dev/null
+++ b/openstack-compute-fix-tests-for-ruby-1.9.patch
@@ -0,0 +1,41 @@
+commit 0210aad858840d4a1ce6ce2ebd921242b4b0dbed
+Author: Bohuslav Kabrda <bkabrda at redhat.com>
+Date:   Thu Jan 26 14:25:17 2012 +0100
+
+    Make the metadata methods work with Ruby 1.9
+
+diff --git a/lib/openstack/compute/metadata.rb b/lib/openstack/compute/metadata.rb
+index ec4574e..43992ba 100644
+--- a/lib/openstack/compute/metadata.rb
++++ b/lib/openstack/compute/metadata.rb
+@@ -55,6 +55,7 @@ module Compute
+         response = @connection.req('POST', @base_url, :data => json)
+         @metadata = JSON.parse(response.body)['metadata']
+       else
++        keys = [keys] unless keys.is_a? Array
+         keys.each { |key|
+           next if not @metadata.has_key?(key)
+           json = JSON.generate(:meta => { key => @metadata[key] })
+@@ -69,6 +70,7 @@ module Compute
+         @metadata = JSON.parse(response.body)['metadata']
+       else
+         @metadata = {} if @metadata == nil
++        keys = [keys] unless keys.is_a? Array
+         keys.each { |key|
+           response = @connection.req('GET', "#{@base_url}/#{key}")
+           next if response.code == "404"
+@@ -80,12 +82,14 @@ module Compute
+ 
+     def delete(keys)
+       return if @metadata.nil?
++      keys = [keys] unless keys.is_a? Array
+       keys.each { |key|
+         @metadata.delete(key)
+       }
+     end
+ 
+     def delete!(keys)
++      keys = [keys] unless keys.is_a? Array
+       keys.each { |key|
+         @connection.req('DELETE', "#{@base_url}/#{key}")
+         @metadata.delete(key) if not @metadata.nil?
diff --git a/rubygem-openstack-compute.spec b/rubygem-openstack-compute.spec
new file mode 100644
index 0000000..3b99897
--- /dev/null
+++ b/rubygem-openstack-compute.spec
@@ -0,0 +1,92 @@
+# Generated from openstack-compute-1.1.5.gem by gem2rpm -*- rpm-spec -*-
+%global gem_name openstack-compute
+%global rubyabi 1.9.1
+
+Summary: OpenStack Compute Ruby API
+Name: rubygem-%{gem_name}
+Version: 1.1.5
+Release: 2%{?dist}
+Group: Development/Languages
+License: MIT
+URL: https://launchpad.net/ruby-openstack-compute
+Source0: http://rubygems.org/gems/%{gem_name}-%{version}.gem
+# To get tests:
+# git clone https://github.com/rackspace/ruby-openstack-compute.git && cd ruby-openstack-compute
+# git checkout v1.1.5
+# tar -czvf openstack-compute-1.1.5-test.tgz test
+Source1: %{gem_name}-%{version}-test.tgz
+# Fixes the library to work properly with Ruby 1.9
+# https://github.com/rackspace/ruby-openstack-compute/pull/11
+Patch0: openstack-compute-fix-tests-for-ruby-1.9.patch
+Requires: ruby(abi) = %{rubyabi}
+Requires: ruby(rubygems) 
+Requires: rubygem(json) 
+BuildRequires: rubygems-devel
+BuildRequires: rubygem(mocha)
+BuildRequires: rubygem(minitest)
+BuildRequires: rubygem(json)
+BuildArch: noarch
+Provides: rubygem(%{gem_name}) = %{version}
+
+%description
+Ruby Openstack Compute binding for the v1.0 OSAPI.
+Currently supports both v1.0 and v2.0 (keystone) auth.
+
+%package doc
+Summary: Documentation for %{name}
+Group: Documentation
+Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
+
+%description doc
+Documentation for %{name}
+
+%prep
+%setup -q -c -T
+mkdir -p .%{gem_dir}
+gem install --local --install-dir .%{gem_dir} \
+            --force %{SOURCE0}
+
+pushd .%{gem_instdir}
+%patch0 -p1
+popd
+
+%build
+
+%install
+mkdir -p %{buildroot}%{gem_dir}
+cp -a .%{gem_dir}/* \
+        %{buildroot}%{gem_dir}/
+# Remove the unneeded shebang.
+sed -i '1d' %{buildroot}%{gem_libdir}/openstack/compute.rb
+
+%check
+pushd .%{gem_instdir}
+# move tests into place, fix them so that they use minitest
+tar xvzf %{SOURCE1}
+sed -i "s|^gem 'test-unit'||" test/test_helper.rb
+testrb test/*_test.rb
+popd
+
+%files
+%dir %{gem_instdir}
+%{gem_libdir}
+%exclude %{gem_cache}
+%{gem_spec}
+%doc %{gem_instdir}/COPYING
+# VERSION file is needed for runtime
+%{gem_instdir}/VERSION
+
+%files doc
+%doc %{gem_docdir}
+%doc %{gem_instdir}/README.rdoc
+
+%changelog
+* Fri Jan 27 2012 Bohuslav Kabrda <bkabrda at redhat.com> - 1.1.5-2
+- Switched from test-unit to minitest.
+- Renamed the patch not to incorporate version.
+- Unpacking test suite in %%check, so that it doesn't get into the RPM.
+- Removed the unneeded shebang from one file.
+
+* Thu Jan 26 2012 Bohuslav Kabrda <bkabrda at redhat.com> - 1.1.5-1
+- Initial package
diff --git a/sources b/sources
index e69de29..538db70 100644
--- a/sources
+++ b/sources
@@ -0,0 +1,2 @@
+60d7b7dc6b14728c336c20c253d872e1  openstack-compute-1.1.5-test.tgz
+4cddf6a610e51f633bdcc067c310f022  openstack-compute-1.1.5.gem


More information about the scm-commits mailing list