[PATCH 5/6 conductor] add ruby 1.9 support to conductor

Jason Guiditta jguiditt at redhat.com
Fri Feb 17 17:12:19 UTC 2012


On 16/02/12 17:09 -0500, Mo Morsi wrote:

Ok, this one didn't quite work for me.  I tested it on my current f16
install (since we need to keep it working there for quite some time
yet), and running the test you changed (after rebuilding/reinstalling
rpms) got me the following errors:

Failures:

   1) Instance should return csv header string for export
        Failure/Error: reader = CSV::Reader.create(Instance.csv_export([FactoryGirl.create(:instance)]))
        TypeError:
          can't convert Hash into String
        # ./app/models/instance.rb:397:in `csv_export'
        # ./spec/models/instance_spec.rb:254

   2) Instance should return csv string for export
        Failure/Error: export_string = Instance.csv_export([instance]).gsub(/\s+/,"")
        TypeError:
          can't convert Hash into String
        # ./app/models/instance.rb:397:in
        # `csv_export'
        # ./spec/models/instance_spec.rb:266

Any thoughts?

-j

>---
> aeolus-conductor.spec.in         |   22 ++++++++++++++++++----
> src/Gemfile                      |    4 +++-
> src/app/models/instance.rb       |    4 +++-
> src/config/application.rb        |    2 +-
> src/spec/models/instance_spec.rb |    9 ++++++++-
> 5 files changed, 33 insertions(+), 8 deletions(-)
>
>diff --git a/aeolus-conductor.spec.in b/aeolus-conductor.spec.in
>index e6a2659..b8e38f1 100644
>--- a/aeolus-conductor.spec.in
>+++ b/aeolus-conductor.spec.in
>@@ -1,6 +1,14 @@
> %global app_root %{_datadir}/%{name}
> %global doc_root %{_datadir}/%{name}-doc
>
>+%if 0%{?fedora} > 16
>+%global rubyver 1.9.3
>+%global rubyabi 1.9.1
>+%else
>+%global rubyver 1.8.1
>+%global rubyabi 1.8
>+%endif
>+
> Name:     aeolus-conductor
> Version:  @VERSION@
> Release:  0%{?dist}
>@@ -17,8 +25,8 @@ URL:      http://aeolusproject.org
> # cp aeolus-conductor-0.3.0.tar.gz ~/rpmbuild/SOURCES
> Source0:    aeolus-conductor-%{version}.tar.gz
>
>-Requires: ruby >= 1.8.1
>-Requires: ruby(abi) = 1.8
>+Requires: ruby >= %{rubyver}
>+Requires: ruby(abi) = %{rubyabi}
> Requires: rubygem(rails) >= 3.0.7
> Requires: rubygem(haml) >= 3.1
> Requires: rubygem(nokogiri) >= 1.4.0
>@@ -31,16 +39,21 @@ Requires: rubygem(json)
> Requires: rubygem(rack-restful_submit)
> Requires: rubygem(uuidtools)
> Requires: rubygem(sqlite3)
>-Requires: rubygem(fastercsv)
> Requires: rubygem(rails_warden)
> Requires: rubygem(aeolus-image) >= 0.1.0-4
> Requires: rubygem(pg)
>-Requires: rubygem(ruby-net-ldap)
> Requires: rubygem(oauth)
> Requires: rubygem(rake)
> Requires: postgresql
> Requires: postgresql-server
>
>+%if 0%{?fedora} > 16
>+Requires: rubygem(net-ldap)
>+%else
>+Requires: rubygem(fastercsv)
>+Requires: rubygem(ruby-net-ldap)
>+%endif
>+
> # to ensure the service is actually started
> # and is accessible in the init script
> Requires: curl
>@@ -90,6 +103,7 @@ Requires: rubygem(vcr)
> Requires: rubygem(factory_girl_rails)
> Requires: rubygem(webmock)
> Requires: rubygem(launchy)
>+Requires: rubygem(minitest)
>
> %description devel
> Tests and other development tools for the Aeolus Conductor.
>diff --git a/src/Gemfile b/src/Gemfile
>index 2d8e8df..7f26313 100644
>--- a/src/Gemfile
>+++ b/src/Gemfile
>@@ -17,11 +17,13 @@ gem 'pg'
> gem 'thin'
> gem 'json'
> gem 'railties'
>-gem 'fastercsv'
> gem 'rails_warden'
> gem 'ruby-net-ldap'
> gem 'aeolus-image'
> gem 'oauth'
>+platforms :ruby_18 do
>+  gem 'fastercsv'
>+end
> group :development, :test do
>   gem 'rspec-rails'
>   gem 'rspec-core'
>diff --git a/src/app/models/instance.rb b/src/app/models/instance.rb
>index f705295..0e70919 100644
>--- a/src/app/models/instance.rb
>+++ b/src/app/models/instance.rb
>@@ -57,6 +57,8 @@
> # Filters added to this controller apply to all controllers in the application.
> # Likewise, all the methods added will be available for all controllers.
>
>+require 'csv'
>+
> require 'util/deployable_xml'
> require 'util/instance_config_xml'
>
>@@ -388,7 +390,7 @@ class Instance < ActiveRecord::Base
>   end
>
>   def self.csv_export(instances)
>-    csv_string = FasterCSV.generate(:col_sep => ";", :row_sep => "\r\n") do |csv|
>+    csv_string = CSV.generate(:col_sep => ";", :row_sep => "\r\n") do |csv|
>       event_attributes = Event.new.attributes.keys.reject {|key| key if key == "created_at" || key == "updated_at"}
>
>       csv << event_attributes.map {|event| event.capitalize }
>diff --git a/src/config/application.rb b/src/config/application.rb
>index f2295ab..e67ac78 100644
>--- a/src/config/application.rb
>+++ b/src/config/application.rb
>@@ -39,7 +39,7 @@ else
>   require 'pg'
>   require 'thin'
>   require 'json'
>-  require 'fastercsv'
>+  require 'fastercsv' if RUBY_VERSION =~ /1\.8\..*/  # no longer needed in ruby 1.9+
>   require 'nokogiri'
>   #require 'railties'
>
>diff --git a/src/spec/models/instance_spec.rb b/src/spec/models/instance_spec.rb
>index 792c9a7..8508036 100644
>--- a/src/spec/models/instance_spec.rb
>+++ b/src/spec/models/instance_spec.rb
>@@ -16,6 +16,8 @@
>
> require 'spec_helper'
>
>+require 'csv'
>+
> describe Instance do
>   before(:each) do
>     @quota = FactoryGirl.create :quota
>@@ -219,7 +221,12 @@ describe Instance do
>   end
>
>   it "should return csv header string for export" do
>-    reader = CSV::Reader.create(Instance.csv_export([FactoryGirl.create(:instance)]))
>+    reader = nil
>+    if CSV.const_defined?(:Reader)
>+      reader = CSV::Reader.create(Instance.csv_export([FactoryGirl.create(:instance)]))
>+    else
>+      reader = CSV.parse(Instance.csv_export([FactoryGirl.create(:instance)]))
>+    end
>     header = reader.shift
>       ['Status_code','Event_time','Summary','Source_type','Description','Source_id'].each do |attribute|
>         header[0].split(';').include?(attribute).should be_true
>-- 
>1.7.6.5
>



More information about the aeolus-devel mailing list