deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject [2/2] git commit: Centralize where we store the current API version
Date Fri, 07 Sep 2012 23:14:31 GMT
Centralize where we store the current API version

We had way too many places where we stored the current API version;
forgetting to update one of them upon release spelled certain doom.

The version of the API is now kept in one place, lib/deltacloud/version.rb,
and everything that needs the current version loads it from there.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/4f7302fe
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/4f7302fe
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/4f7302fe

Branch: refs/heads/master
Commit: 4f7302fe05e2c91e8503c5e70df4b28520c03ed6
Parents: 021b900
Author: David Lutterkort <lutter@redhat.com>
Authored: Fri Sep 7 16:06:42 2012 -0700
Committer: David Lutterkort <lutter@redhat.com>
Committed: Fri Sep 7 16:06:42 2012 -0700

----------------------------------------------------------------------
 client/deltacloud-client.gemspec     |    3 ++-
 server/config.ru                     |    4 ++--
 server/deltacloud-core.gemspec       |    4 +++-
 server/lib/deltacloud/api.rb         |    3 +--
 server/lib/deltacloud/version.rb     |   19 +++++++++++++++++++
 server/lib/deltacloud_rack.rb        |    1 +
 server/tests/deltacloud/common.rb    |    2 +-
 server/tests/deltacloud/rack_test.rb |    6 +++---
 8 files changed, 32 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/client/deltacloud-client.gemspec
----------------------------------------------------------------------
diff --git a/client/deltacloud-client.gemspec b/client/deltacloud-client.gemspec
index 64c6f93..b5ede63 100644
--- a/client/deltacloud-client.gemspec
+++ b/client/deltacloud-client.gemspec
@@ -16,6 +16,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+Kernel::load File::join(File::dirname(__FILE__), '../server/lib/deltacloud/version.rb')
 
 Gem::Specification.new do |s|
   s.author = 'The Apache Software Foundation'
@@ -23,7 +24,7 @@ Gem::Specification.new do |s|
   s.email = 'dev@deltacloud.apache.org'
   s.name = 'deltacloud-client'
   s.description = %q{Deltacloud REST Client for API}
-  s.version = '1.0.2'
+  s.version = Deltacloud::API_VERSION
   s.summary = %q{Deltacloud REST Client}
   s.files = Dir['Rakefile', 'lib/**/*.rb']
   s.test_files= Dir.glob("specs/**/**")

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/config.ru
----------------------------------------------------------------------
diff --git a/server/config.ru b/server/config.ru
index b1ce2a8..26c22d6 100644
--- a/server/config.ru
+++ b/server/config.ru
@@ -24,7 +24,7 @@ load File.join(File.dirname(__FILE__), 'lib', 'deltacloud_rack.rb')
 
 Deltacloud::configure do |server|
   server.root_url '/api'
-  server.version '1.0.2'
+  server.version Deltacloud::API_VERSION
   server.klass 'Deltacloud::API'
   server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
   server.default_driver ENV['API_DRIVER']
@@ -32,7 +32,7 @@ end
 
 Deltacloud::configure(:cimi) do |server|
   server.root_url '/cimi'
-  server.version '1.0.2'
+  server.version Deltacloud::API_VERSION
   server.klass 'CIMI::API'
   server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
   server.default_driver ENV['API_DRIVER']

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/deltacloud-core.gemspec
----------------------------------------------------------------------
diff --git a/server/deltacloud-core.gemspec b/server/deltacloud-core.gemspec
index 3444391..9d761e6 100644
--- a/server/deltacloud-core.gemspec
+++ b/server/deltacloud-core.gemspec
@@ -14,6 +14,8 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
+Kernel::load File::join(File::dirname(__FILE__), './lib/deltacloud/version.rb')
+
 Gem::Specification.new do |s|
   s.author = 'The Apache Software Foundation'
   s.homepage = "http://www.deltacloud.org"
@@ -27,7 +29,7 @@ Gem::Specification.new do |s|
     which implements the REST interface.
   EOF
 
-  s.version = '1.0.2'
+  s.version = Deltacloud::API_VERSION
   s.date = Time.now
   s.summary = %q{Deltacloud REST API}
   s.files = [

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/lib/deltacloud/api.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/api.rb b/server/lib/deltacloud/api.rb
index 4007572..4208a1f 100644
--- a/server/lib/deltacloud/api.rb
+++ b/server/lib/deltacloud/api.rb
@@ -22,6 +22,7 @@ require_relative 'core_ext'
 require_relative 'models'
 require_relative 'drivers'
 require_relative 'helpers/driver_helper'
+require_relative 'version'
 
 module TestPoller
   # This method will pool the resource until condition is true
@@ -67,8 +68,6 @@ class StorageSnapshot; include TestPoller; end
 
 module Deltacloud
 
-  API_VERSION = '1.0.2'
-
   def self.drivers
     Drivers.driver_config
   end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/lib/deltacloud/version.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/version.rb b/server/lib/deltacloud/version.rb
new file mode 100644
index 0000000..e9a0e6b
--- /dev/null
+++ b/server/lib/deltacloud/version.rb
@@ -0,0 +1,19 @@
+#
+# 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 Deltacloud
+  API_VERSION = '1.0.2' unless defined?(API_VERSION)
+end

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/lib/deltacloud_rack.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud_rack.rb b/server/lib/deltacloud_rack.rb
index 7b01524..fe99be8 100644
--- a/server/lib/deltacloud_rack.rb
+++ b/server/lib/deltacloud_rack.rb
@@ -17,6 +17,7 @@ require 'require_relative' if RUBY_VERSION < '1.9'
 
 require_relative './deltacloud/core_ext'
 require_relative './sinatra/rack_logger'
+require_relative './deltacloud/version'
 
 module Deltacloud
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/tests/deltacloud/common.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/common.rb b/server/tests/deltacloud/common.rb
index a925d8c..27e6a5b 100644
--- a/server/tests/deltacloud/common.rb
+++ b/server/tests/deltacloud/common.rb
@@ -5,7 +5,7 @@ require_relative File.join('..', '..', 'lib', 'deltacloud_rack.rb')
 
 Deltacloud::configure do |server|
   server.root_url '/api'
-  server.version '1.0.2'
+  server.version Deltacloud::API_VERSION
   server.klass 'Deltacloud::API'
   server.logger Rack::DeltacloudLogger.setup(ENV['API_LOG'], ENV['API_VERBOSE'])
   server.default_driver :mock

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/4f7302fe/server/tests/deltacloud/rack_test.rb
----------------------------------------------------------------------
diff --git a/server/tests/deltacloud/rack_test.rb b/server/tests/deltacloud/rack_test.rb
index d672620..f6eb717 100644
--- a/server/tests/deltacloud/rack_test.rb
+++ b/server/tests/deltacloud/rack_test.rb
@@ -8,7 +8,7 @@ describe Deltacloud do
   before do
     Deltacloud::configure :cimi do |server|
       server.root_url '/cimi'
-      server.version '1.0.2'
+      server.version Deltacloud::API_VERSION
       server.klass 'CIMI'
       server.logger Logger
     end
@@ -37,8 +37,8 @@ describe Deltacloud do
     end
 
     it 'should provide the correct version' do
-      Deltacloud.config[:deltacloud].version.must_equal '1.0.2'
-      Deltacloud.config[:cimi].version.must_equal '1.0.2'
+      Deltacloud.config[:deltacloud].version.must_equal Deltacloud::API_VERSION
+      Deltacloud.config[:cimi].version.must_equal Deltacloud::API_VERSION
     end
 
     it 'should provide the logger facility' do


Mime
View raw message