deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject [21/50] [abbrv] git commit: Use require_relative gem instead of copies of the same boilerplate
Date Mon, 30 Jul 2012 14:29:17 GMT
Use require_relative gem instead of copies of the same boilerplate

We'll need a convenient way to use require_relative from many places,
especially test files. Copying the same boilerplate code all over the place
is too tedious for this - writing "require 'require_relative'" is much more
concise.


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

Branch: refs/heads/master
Commit: 7208ddab56cee1494b16bbf147fbfffd6d3efc6c
Parents: 1d380fc
Author: David Lutterkort <lutter@redhat.com>
Authored: Thu Jul 26 15:58:41 2012 -0700
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Fri Jul 27 13:55:43 2012 +0200

----------------------------------------------------------------------
 server/deltacloud-core.gemspec    |    1 +
 server/lib/cimi/models.rb         |    8 +-------
 server/lib/deltacloud/api.rb      |    8 +-------
 server/lib/deltacloud/core_ext.rb |    8 +-------
 server/lib/deltacloud_rack.rb     |    8 +-------
 server/spec/spec_helper.rb        |    9 +--------
 server/tests/test_helper.rb       |    9 +--------
 7 files changed, 7 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/deltacloud-core.gemspec
----------------------------------------------------------------------
diff --git a/server/deltacloud-core.gemspec b/server/deltacloud-core.gemspec
index 9716427..25d31df 100644
--- a/server/deltacloud-core.gemspec
+++ b/server/deltacloud-core.gemspec
@@ -76,6 +76,7 @@ Gem::Specification.new do |s|
   s.add_dependency('net-ssh', '>= 2.0.0')
   s.add_dependency('thin', '>= 1.2.5')
   s.add_dependency('nokogiri', '>= 1.4.3')
+  s.add_dependency('require_relative')
 
 # dependencies for various cloud providers:
 # RHEV-M

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/lib/cimi/models.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
index 1214497..d88d4b8 100644
--- a/server/lib/cimi/models.rb
+++ b/server/lib/cimi/models.rb
@@ -17,13 +17,7 @@ module CIMI
   module Model; end
 end
 
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
+require 'require_relative'
 
 require_relative './models/schema'
 require_relative './models/base'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/lib/deltacloud/api.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/api.rb b/server/lib/deltacloud/api.rb
index 23d96e1..56416bc 100644
--- a/server/lib/deltacloud/api.rb
+++ b/server/lib/deltacloud/api.rb
@@ -16,13 +16,7 @@
 require 'rubygems'
 require 'ostruct'
 
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
+require 'require_relative'
 
 require_relative 'core_ext'
 require_relative 'models'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/lib/deltacloud/core_ext.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/core_ext.rb b/server/lib/deltacloud/core_ext.rb
index b448adb..7db0c16 100644
--- a/server/lib/deltacloud/core_ext.rb
+++ b/server/lib/deltacloud/core_ext.rb
@@ -14,13 +14,7 @@
 # under the License.
 #
 
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
+require 'require_relative'
 
 require_relative './core_ext/array'
 require_relative './core_ext/hash'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/lib/deltacloud_rack.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud_rack.rb b/server/lib/deltacloud_rack.rb
index c30be3b..28b3045 100644
--- a/server/lib/deltacloud_rack.rb
+++ b/server/lib/deltacloud_rack.rb
@@ -13,13 +13,7 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
+require 'require_relative'
 
 require_relative './deltacloud/core_ext'
 require_relative './sinatra/rack_logger'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/spec/spec_helper.rb
----------------------------------------------------------------------
diff --git a/server/spec/spec_helper.rb b/server/spec/spec_helper.rb
index 47b8672..643873e 100644
--- a/server/spec/spec_helper.rb
+++ b/server/spec/spec_helper.rb
@@ -18,14 +18,7 @@ require 'rubygems'
 require 'pp'
 require 'rspec/core'
 require 'xmlsimple'
-
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
+require 'require_relative'
 
 require_relative '../lib/deltacloud/core_ext.rb'
 require_relative '../lib/cimi/models.rb'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/7208ddab/server/tests/test_helper.rb
----------------------------------------------------------------------
diff --git a/server/tests/test_helper.rb b/server/tests/test_helper.rb
index 42effb1..f97f570 100644
--- a/server/tests/test_helper.rb
+++ b/server/tests/test_helper.rb
@@ -1,4 +1,5 @@
 require 'pp'
+require 'require_relative'
 
 ENV['RACK_ENV'] = 'test'
 
@@ -10,14 +11,6 @@ if ENV['COVERAGE']
   end
 end
 
-unless Kernel.respond_to?(:require_relative)
-  module Kernel
-    def require_relative(path)
-      require File.join(File.dirname(caller[0]), path.to_str)
-    end
-  end
-end
-
 require 'time'
 
 # This code was originally copied from:


Mime
View raw message