summaryrefslogtreecommitdiff
path: root/ruby
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2008-11-14 21:27:02 +0000
committerRafael H. Schloming <rhs@apache.org>2008-11-14 21:27:02 +0000
commit853b1c3bc9accad7f187c8226a3d60b975ee47a3 (patch)
treee5f5d0b41573e4707c677f3905768dfabfee316e /ruby
parentd25c617ad6e83e460f0fd1f693429fa1ec9756b7 (diff)
downloadqpid-python-853b1c3bc9accad7f187c8226a3d60b975ee47a3.tar.gz
added config.rb for packaging customization of spec location
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@714152 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ruby')
-rw-r--r--ruby/Rakefile6
-rw-r--r--ruby/lib/qpid/config.rb33
-rw-r--r--ruby/lib/qpid/spec010.rb90
3 files changed, 72 insertions, 57 deletions
diff --git a/ruby/Rakefile b/ruby/Rakefile
index 66e0fed226..2a11e0b4f9 100644
--- a/ruby/Rakefile
+++ b/ruby/Rakefile
@@ -8,12 +8,6 @@ PKG_NAME='ruby-qpid'
PKG_VERSION='0.10.2'
GEM_NAME='qpid'
-AMQP_SPEC_SRC=Pathname.new("../specs").realpath
-AMQP_SPEC_PATH=["/usr/share/amqp", AMQP_SPEC_SRC].join(File::PATH_SEPARATOR)
-AMQP_SPEC_FILES = FileList["amqp.0-10-qpid-errata.xml"]
-
-ENV["AMQP_SPEC_PATH"] = AMQP_SPEC_PATH unless ENV["AMQP_SPEC_PATH"]
-
#
# Additional files for clean/clobber
#
diff --git a/ruby/lib/qpid/config.rb b/ruby/lib/qpid/config.rb
new file mode 100644
index 0000000000..1a0942d5d5
--- /dev/null
+++ b/ruby/lib/qpid/config.rb
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+module Qpid
+ module Config
+
+ def self.amqp_spec
+ dirs = [File::expand_path(File::join(File::dirname(__FILE__), "../../../specs")),
+ "/usr/share/amqp"]
+ dirs.each do |d|
+ spec = File::join(d, "amqp.0-10-qpid-errata.xml")
+ return spec if File::exists? spec
+ end
+ end
+
+ end
+end
diff --git a/ruby/lib/qpid/spec010.rb b/ruby/lib/qpid/spec010.rb
index 517c5a168a..4c1e46b910 100644
--- a/ruby/lib/qpid/spec010.rb
+++ b/ruby/lib/qpid/spec010.rb
@@ -25,8 +25,6 @@ module Qpid::Spec010
include Qpid::Spec
- AMQP_SPEC_DEFAULT_DIR = "/usr/share/amqp"
-
# XXX: workaround for ruby bug/missfeature
Reference = Reference
Loader = Loader
@@ -435,63 +433,53 @@ module Qpid::Spec010
# XXX: could be shared
def self.load(spec = nil)
- return spec if spec.is_a?(Qpid::Spec010::Spec)
- if spec.nil?
- # FIXME: Need to add a packaging setup in here so we know where
- # the installed spec is going to be.
- specfile = nil
- if ENV['AMQP_SPEC']
- specfile = ENV['AMQP_SPEC']
- else
- topdir = File::dirname(File::dirname(File::expand_path(__FILE__)))
- specfile = File::join(topdir, "../../specs", "amqp.0-10-qpid-errata.xml")
- end
+ return spec if spec.is_a?(Qpid::Spec010::Spec)
+ if spec.nil?
+ # FIXME: Need to add a packaging setup in here so we know where
+ # the installed spec is going to be.
+ specfile = nil
+ if ENV['AMQP_SPEC']
+ specfile = ENV['AMQP_SPEC']
else
- specfile = spec
- end
-
- unless Pathname.new(specfile).absolute?
- path = ENV["AMQP_SPEC_PATH"] || AMQP_SPEC_DEFAULT_DIR
-
- p = path.split(File::PATH_SEPARATOR).collect { |p|
- Pathname.new(p).join(specfile)
- }.find { |p| p.file? }
- raise "Can not find file for spec #{spec}" unless p
- specfile = p.to_s
+ require "qpid/config"
+ specfile = Qpid::Config.amqp_spec
end
+ else
+ specfile = spec
+ end
- specfile_cache = spec_cache(specfile)
- # FIXME: Check that cache is newer than specfile
- if File::exist?(specfile_cache)
- begin
- spec = File::open(specfile_cache, "r") do |f|
- Marshal::load(f)
- end
- return spec
- rescue
- # Ignore, will load from XML
- end
+ specfile_cache = spec_cache(specfile)
+ # FIXME: Check that cache is newer than specfile
+ if File::exist?(specfile_cache)
+ begin
+ spec = File::open(specfile_cache, "r") do |f|
+ Marshal::load(f)
+ end
+ return spec
+ rescue
+ # Ignore, will load from XML
end
+ end
- doc = File::open(specfile, "r") { |f| Document.new(f) }
- spec = Loader010.new().load(doc.root)
- spec.traverse! do |o|
- if o.is_a?(Reference)
- o.resolve(spec)
- else
- o
- end
+ doc = File::open(specfile, "r") { |f| Document.new(f) }
+ spec = Loader010.new().load(doc.root)
+ spec.traverse! do |o|
+ if o.is_a?(Reference)
+ o.resolve(spec)
+ else
+ o
end
+ end
- spec.children.each { |c| c.parent = spec }
+ spec.children.each { |c| c.parent = spec }
- begin
- FileUtils::mkdir_p(File::dirname(specfile_cache))
- File::open(specfile_cache, "w") { |f| Marshal::dump(spec, f) }
- rescue
- # Ignore, we are fine without the cached spec
- end
- return spec
+ begin
+ FileUtils::mkdir_p(File::dirname(specfile_cache))
+ File::open(specfile_cache, "w") { |f| Marshal::dump(spec, f) }
+ rescue
+ # Ignore, we are fine without the cached spec
+ end
+ return spec
end
end