tidy up requires
It's really ugly to have to keep repeating File.dirname(__FILE__), so we use a temporary variable, even in the case of a single require. This minimises long "requires" lines and "requires" statements with needing line-breaks, and should make search-and-replace a bit easier if we later want to migrate to __dir__ (Ruby >= 2.0) or require_relative. http://stackoverflow.com/questions/4333286/ruby-require-vs-require-relative-best-practice-to-workaround-running-in-both I've deliberately rejected the pattern: require File.expand_path('../relative/path', __FILE__) because it relies on inconsistent semantics and inconsistent documentation in File.expand_path: http://stackoverflow.com/questions/4333286/ruby-require-vs-require-relative-best-practice-to-workaround-running-in-both#comment34147297_4333552
This commit is contained in:
parent
bb280de1e0
commit
c0e3907ba0
@ -1,2 +1,3 @@
|
||||
require File.expand_path('pacemaker/standard_cib_object.rb', File.dirname(__FILE__))
|
||||
require File.expand_path('pacemaker/runnable_resource.rb', File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('pacemaker/standard_cib_object.rb', this_dir)
|
||||
require File.expand_path('pacemaker/runnable_resource.rb', this_dir)
|
||||
|
@ -1,4 +1,4 @@
|
||||
require ::File.expand_path('standard_cib_object', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('standard_cib_object', File.dirname(__FILE__))
|
||||
|
||||
# Common code used by Pacemaker LWRP providers for resources supporting
|
||||
# the :run action.
|
||||
|
@ -1,5 +1,5 @@
|
||||
require ::File.expand_path('../../../pacemaker/cib_object',
|
||||
::File.dirname(__FILE__))
|
||||
File.dirname(__FILE__))
|
||||
|
||||
# Common code used by Pacemaker LWRP providers
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
require File.expand_path('../resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../mixins/resource_meta', File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../resource', this_dir)
|
||||
require File.expand_path('../mixins/resource_meta', this_dir)
|
||||
|
||||
class Pacemaker::Resource::Clone < Pacemaker::Resource
|
||||
TYPE = 'clone'
|
||||
|
@ -1,5 +1,6 @@
|
||||
require File.expand_path('../resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../mixins/resource_meta', File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../resource', this_dir)
|
||||
require File.expand_path('../mixins/resource_meta', this_dir)
|
||||
|
||||
class Pacemaker::Resource::Group < Pacemaker::Resource
|
||||
TYPE = 'group'
|
||||
|
@ -1,6 +1,8 @@
|
||||
require 'shellwords'
|
||||
require File.expand_path('../resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../mixins/resource_meta', File.dirname(__FILE__))
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../resource', this_dir)
|
||||
require File.expand_path('../mixins/resource_meta', this_dir)
|
||||
|
||||
class Pacemaker::Resource::Primitive < Pacemaker::Resource
|
||||
TYPE = 'primitive'
|
||||
|
@ -17,9 +17,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::RunnableResource
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::StandardCIBObject
|
||||
|
||||
|
@ -16,9 +16,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::RunnableResource
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::StandardCIBObject
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::RunnableResource
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker', ::File.dirname(__FILE__))
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker', this_dir)
|
||||
require ::File.expand_path('../libraries/chef/mixin/pacemaker', this_dir)
|
||||
|
||||
include Chef::Mixin::Pacemaker::RunnableResource
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
require ::File.expand_path('../libraries/pacemaker/cib_object',
|
||||
::File.dirname(__FILE__))
|
||||
this_dir = ::File.dirname(__FILE__)
|
||||
require ::File.expand_path('../libraries/pacemaker/cib_object', this_dir)
|
||||
|
||||
action :create do
|
||||
name = new_resource.name
|
||||
|
2
spec/fixtures/colocation_constraint.rb
vendored
2
spec/fixtures/colocation_constraint.rb
vendored
@ -1,5 +1,5 @@
|
||||
require ::File.expand_path('../../libraries/pacemaker/constraint/colocation',
|
||||
::File.dirname(__FILE__))
|
||||
File.dirname(__FILE__))
|
||||
|
||||
module Chef::RSpec
|
||||
module Pacemaker
|
||||
|
2
spec/fixtures/keystone_primitive.rb
vendored
2
spec/fixtures/keystone_primitive.rb
vendored
@ -1,5 +1,5 @@
|
||||
require ::File.expand_path('../../libraries/pacemaker/resource/primitive',
|
||||
::File.dirname(__FILE__))
|
||||
File.dirname(__FILE__))
|
||||
|
||||
module Chef::RSpec
|
||||
module Pacemaker
|
||||
|
2
spec/fixtures/location_constraint.rb
vendored
2
spec/fixtures/location_constraint.rb
vendored
@ -1,5 +1,5 @@
|
||||
require ::File.expand_path('../../libraries/pacemaker/constraint/location',
|
||||
::File.dirname(__FILE__))
|
||||
File.dirname(__FILE__))
|
||||
|
||||
module Chef::RSpec
|
||||
module Pacemaker
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
require 'mixlib/shellout'
|
||||
|
||||
require File.expand_path('../../libraries/pacemaker/cib_object',
|
||||
File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../libraries/pacemaker/cib_object', this_dir)
|
||||
|
||||
module Chef::RSpec
|
||||
module Pacemaker
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Shared code used to test providers of CIB objects
|
||||
|
||||
require File.expand_path('../helpers/cib_object', File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/cib_object', this_dir)
|
||||
|
||||
shared_context "a Pacemaker LWRP" do
|
||||
before(:each) do
|
||||
|
@ -3,7 +3,8 @@
|
||||
# for primitives is runnable (since primitives can be started
|
||||
# and stopped) but constraints cannot.
|
||||
|
||||
require File.expand_path('../helpers/provider', File.dirname(__FILE__))
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/provider', this_dir)
|
||||
|
||||
shared_examples "a runnable resource" do |fixture|
|
||||
def expect_running(running)
|
||||
|
@ -1,8 +1,10 @@
|
||||
require 'spec_helper'
|
||||
require 'mixlib/shellout'
|
||||
|
||||
require File.expand_path('../../../libraries/pacemaker', File.dirname(__FILE__))
|
||||
require File.expand_path('../../fixtures/keystone_primitive', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../libraries/pacemaker', this_dir)
|
||||
require File.expand_path('../../fixtures/keystone_primitive', this_dir)
|
||||
|
||||
describe Pacemaker::CIBObject do
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../../libraries/pacemaker/constraint/colocation',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/colocation_constraint', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/cib_object', File.dirname(__FILE__))
|
||||
this_dir)
|
||||
require File.expand_path('../../../fixtures/colocation_constraint', this_dir)
|
||||
require File.expand_path('../../../helpers/cib_object', this_dir)
|
||||
|
||||
describe Pacemaker::Constraint::Colocation do
|
||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::COLOCATION_CONSTRAINT.dup }
|
||||
|
@ -1,8 +1,10 @@
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../../libraries/pacemaker/constraint/location',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/location_constraint', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/cib_object', File.dirname(__FILE__))
|
||||
this_dir)
|
||||
require File.expand_path('../../../fixtures/location_constraint', this_dir)
|
||||
require File.expand_path('../../../helpers/cib_object', this_dir)
|
||||
|
||||
describe Pacemaker::Constraint::Location do
|
||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::LOCATION_CONSTRAINT.dup }
|
||||
|
@ -1,10 +1,10 @@
|
||||
require 'spec_helper'
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/clone',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/clone_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/cib_object', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/meta_examples',
|
||||
File.dirname(__FILE__))
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/clone', this_dir)
|
||||
require File.expand_path('../../../fixtures/clone_resource', this_dir)
|
||||
require File.expand_path('../../../helpers/cib_object', this_dir)
|
||||
require File.expand_path('../../../helpers/meta_examples', this_dir)
|
||||
|
||||
describe Pacemaker::Resource::Clone do
|
||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::CLONE_RESOURCE.dup }
|
||||
|
@ -1,4 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/group',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/resource_group', File.dirname(__FILE__))
|
||||
|
@ -1,10 +1,10 @@
|
||||
require 'spec_helper'
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/ms',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/ms_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/cib_object', File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/meta_examples',
|
||||
File.dirname(__FILE__))
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/ms', this_dir)
|
||||
require File.expand_path('../../../fixtures/ms_resource', this_dir)
|
||||
require File.expand_path('../../../helpers/cib_object', this_dir)
|
||||
require File.expand_path('../../../helpers/meta_examples', this_dir)
|
||||
|
||||
describe Pacemaker::Resource::MasterSlave do
|
||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::MS_RESOURCE.dup }
|
||||
|
@ -1,12 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../../libraries/pacemaker/resource/primitive',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../fixtures/keystone_primitive',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/cib_object',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../../helpers/meta_examples',
|
||||
File.dirname(__FILE__))
|
||||
this_dir)
|
||||
require File.expand_path('../../../fixtures/keystone_primitive', this_dir)
|
||||
require File.expand_path('../../../helpers/cib_object', this_dir)
|
||||
require File.expand_path('../../../helpers/meta_examples', this_dir)
|
||||
|
||||
describe Pacemaker::Resource::Primitive do
|
||||
let(:fixture) { Chef::RSpec::Pacemaker::Config::KEYSTONE_PRIMITIVE.dup }
|
||||
|
@ -1,8 +1,8 @@
|
||||
require 'spec_helper'
|
||||
require File.expand_path('../../../libraries/pacemaker/resource',
|
||||
File.dirname(__FILE__))
|
||||
require File.expand_path('../../fixtures/keystone_primitive',
|
||||
File.dirname(__FILE__))
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../../../libraries/pacemaker/resource', this_dir)
|
||||
require File.expand_path('../../fixtures/keystone_primitive', this_dir)
|
||||
|
||||
describe Pacemaker::Resource do
|
||||
describe "#running?" do
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/runnable_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/clone_resource', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/runnable_resource', this_dir)
|
||||
require File.expand_path('../fixtures/clone_resource', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerClone" do
|
||||
# for use inside examples:
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/provider', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/colocation_constraint', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/provider', this_dir)
|
||||
require File.expand_path('../fixtures/colocation_constraint', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerColocation" do
|
||||
# for use inside examples:
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/runnable_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/resource_group', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/runnable_resource', this_dir)
|
||||
require File.expand_path('../fixtures/resource_group', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerGroup" do
|
||||
# for use inside examples:
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/provider', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/location_constraint', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/provider', this_dir)
|
||||
require File.expand_path('../fixtures/location_constraint', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerLocation" do
|
||||
# for use inside examples:
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/runnable_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/ms_resource', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/runnable_resource', this_dir)
|
||||
require File.expand_path('../fixtures/ms_resource', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerMs" do
|
||||
# for use inside examples:
|
||||
|
@ -1,6 +1,8 @@
|
||||
require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
||||
require File.expand_path('../helpers/runnable_resource', File.dirname(__FILE__))
|
||||
require File.expand_path('../fixtures/keystone_primitive', File.dirname(__FILE__))
|
||||
require 'spec_helper'
|
||||
|
||||
this_dir = File.dirname(__FILE__)
|
||||
require File.expand_path('../helpers/runnable_resource', this_dir)
|
||||
require File.expand_path('../fixtures/keystone_primitive', this_dir)
|
||||
|
||||
describe "Chef::Provider::PacemakerPrimitive" do
|
||||
# for use inside examples:
|
||||
|
Loading…
x
Reference in New Issue
Block a user