Skip to content

Commit

Permalink
Merge pull request #549 from inspec/relative
Browse files Browse the repository at this point in the history
Substitute require for require_relative
  • Loading branch information
tas50 authored Dec 24, 2019
2 parents cb6a357 + 045c3c8 commit 8972210
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 60 deletions.
10 changes: 5 additions & 5 deletions lib/train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
#
# Author:: Dominik Richter (<[email protected]>)

require "train/version"
require "train/options"
require "train/plugins"
require "train/errors"
require "train/platforms"
require_relative "train/version"
require_relative "train/options"
require_relative "train/plugins"
require_relative "train/errors"
require_relative "train/platforms"
require "uri"

module Train
Expand Down
4 changes: 2 additions & 2 deletions lib/train/extras.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Author:: Dominik Richter (<[email protected]>)

module Train::Extras
require "train/extras/command_wrapper"
require "train/extras/stat"
require_relative "extras/command_wrapper"
require_relative "extras/stat"

CommandResult = Struct.new(:stdout, :stderr, :exit_status)
LoginCommand = Struct.new(:command, :arguments)
Expand Down
2 changes: 1 addition & 1 deletion lib/train/extras/command_wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# author: Christoph Hartmann

require "base64"
require "train/errors"
require_relative "../errors"

module Train::Extras
# Define the interface of all command wrappers.
Expand Down
6 changes: 3 additions & 3 deletions lib/train/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# author: Christoph Hartmann
# author: Dominik Richter

require "train/file/local"
require "train/file/remote"
require "train/extras/stat"
require_relative "file/local"
require_relative "file/remote"
require_relative "extras/stat"

module Train
class File # rubocop:disable Metrics/ClassLength
Expand Down
4 changes: 2 additions & 2 deletions lib/train/file/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ def linked_to?(dst)

# subclass requires are loaded after Train::File::Local is defined
# to avoid superclass mismatch errors
require "train/file/local/unix"
require "train/file/local/windows"
require_relative "local/unix"
require_relative "local/windows"
2 changes: 1 addition & 1 deletion lib/train/file/local/unix.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8

require "shellwords"
require "train/extras/stat"
require_relative "../../extras/stat"

module Train
class File
Expand Down
10 changes: 5 additions & 5 deletions lib/train/file/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def detect_filename(path, sep)

# subclass requires are loaded after Train::File::Remote is defined
# to avoid superclass mismatch errors
require "train/file/remote/aix"
require "train/file/remote/linux"
require "train/file/remote/qnx"
require "train/file/remote/unix"
require "train/file/remote/windows"
require_relative "remote/aix"
require_relative "remote/linux"
require_relative "remote/qnx"
require_relative "remote/unix"
require_relative "remote/windows"
2 changes: 1 addition & 1 deletion lib/train/file/remote/aix.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

require "train/file/remote/unix"
require_relative "unix"

module Train
class File
Expand Down
2 changes: 1 addition & 1 deletion lib/train/file/remote/linux.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

require "train/file/remote/unix"
require_relative "unix"

module Train
class File
Expand Down
2 changes: 1 addition & 1 deletion lib/train/file/remote/qnx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# author: Christoph Hartmann
# author: Dominik Richter

require "train/file/remote/unix"
require_relative "unix"

module Train
class File
Expand Down
16 changes: 8 additions & 8 deletions lib/train/platforms.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# encoding: utf-8

require "train/platforms/common"
require "train/platforms/detect"
require "train/platforms/detect/scanner"
require "train/platforms/detect/specifications/os"
require "train/platforms/detect/specifications/api"
require "train/platforms/detect/uuid"
require "train/platforms/family"
require "train/platforms/platform"
require_relative "platforms/common"
require_relative "platforms/detect"
require_relative "platforms/detect/scanner"
require_relative "platforms/detect/specifications/os"
require_relative "platforms/detect/specifications/api"
require_relative "platforms/detect/uuid"
require_relative "platforms/family"
require_relative "platforms/platform"

module Train::Platforms
# Retrieve the current platform list
Expand Down
4 changes: 2 additions & 2 deletions lib/train/platforms/detect/helpers/os_common.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "train/platforms/detect/helpers/os_linux"
require "train/platforms/detect/helpers/os_windows"
require_relative "os_linux"
require_relative "os_windows"
require "rbconfig"

module Train::Platforms::Detect::Helpers
Expand Down
2 changes: 1 addition & 1 deletion lib/train/platforms/detect/scanner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

require "train/platforms/detect/helpers/os_common"
require_relative "helpers/os_common"

module Train::Platforms::Detect
class Scanner
Expand Down
2 changes: 1 addition & 1 deletion lib/train/plugin_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Load Train. We certainly need the plugin system, and also several other parts
# that are tightly coupled. Train itself is fairly light, and non-invasive.
require "train"
require_relative "../train"

# You can select from a number of test harnesses. Since Train is closely related
# to InSpec, and InSpec uses Spec-style controls in profile code, you will
Expand Down
4 changes: 2 additions & 2 deletions lib/train/plugins.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
# Author:: Dominik Richter (<[email protected]>)
# Author:: Christoph Hartmann (<[email protected]>)

require "train/errors"
require_relative "errors"

module Train
class Plugins
require "train/plugins/transport"
require_relative "plugins/transport"

class << self
# Retrieve the current plugin registry, containing all plugin names
Expand Down
8 changes: 4 additions & 4 deletions lib/train/plugins/base_connection.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# encoding: utf-8

require "train/errors"
require "train/extras"
require "train/file"
require_relative "../errors"
require_relative "../extras"
require_relative "../file"
require "logger"

class Train::Plugins::Transport
Expand Down Expand Up @@ -88,7 +88,7 @@ def to_json
end

def load_json(j)
require "train/transports/mock"
require_relative "../transports/mock"
j["files"].each do |path, jf|
@cache[:file][path] = Train::Transports::Mock::Connection::File.from_json(jf)
end
Expand Down
8 changes: 4 additions & 4 deletions lib/train/plugins/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
# Author:: Christoph Hartmann (<[email protected]>)

require "logger"
require "train/errors"
require "train/extras"
require "train/options"
require_relative "../errors"
require_relative "../extras"
require_relative "../options"

class Train::Plugins
class Transport
include Train::Extras
Train::Options.attach(self)

require "train/plugins/base_connection"
require_relative "base_connection"

# Initialize a new Transport object
#
Expand Down
8 changes: 4 additions & 4 deletions lib/train/transports/azure.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# encoding: utf-8

require "train/plugins"
require_relative "../plugins"
require "ms_rest_azure"
require "azure_mgmt_resources"
require "azure_graph_rbac"
require "azure_mgmt_key_vault"
require "socket"
require "timeout"
require "train/transports/helpers/azure/file_credentials"
require "train/transports/clients/azure/graph_rbac"
require "train/transports/clients/azure/vault"
require_relative "helpers/azure/file_credentials"
require_relative "clients/azure/graph_rbac"
require_relative "clients/azure/vault"

module Train::Transports
class Azure < Train.plugin(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/train/transports/gcp.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8

require "train/plugins"
require_relative "../plugins"
require "google/apis"
require "google/apis/cloudresourcemanager_v1"
require "google/apis/compute_v1"
Expand Down
6 changes: 3 additions & 3 deletions lib/train/transports/helpers/azure/file_credentials.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# encoding: utf-8

require "inifile"
require "train/transports/helpers/azure/file_parser"
require "train/transports/helpers/azure/subscription_number_file_parser"
require "train/transports/helpers/azure/subscription_id_file_parser"
require_relative "file_parser"
require_relative "subscription_number_file_parser"
require_relative "subscription_id_file_parser"

module Train::Transports
module Helpers
Expand Down
4 changes: 2 additions & 2 deletions lib/train/transports/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# author: Dominik Richter
# author: Christoph Hartmann

require "train/plugins"
require "train/errors"
require_relative "../plugins"
require_relative "../errors"
require "mixlib/shellout"

module Train::Transports
Expand Down
2 changes: 1 addition & 1 deletion lib/train/transports/mock.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require "train/plugins"
require_relative "../plugins"
require "digest"

module Train::Transports
Expand Down
6 changes: 3 additions & 3 deletions lib/train/transports/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

require "net/ssh"
require "net/scp"
require "train/errors"
require_relative "../errors"

module Train::Transports
# Wrapped exception for any internally raised SSH-related errors.
Expand All @@ -36,8 +36,8 @@ class SSHPTYFailed < Train::TransportError; end
class SSH < Train.plugin(1) # rubocop:disable Metrics/ClassLength
name "ssh"

require "train/transports/ssh_connection"
require "train/transports/cisco_ios_connection"
require_relative "ssh_connection"
require_relative "cisco_ios_connection"

# add options for submodules
include_options Train::Extras::CommandWrapper
Expand Down
4 changes: 2 additions & 2 deletions lib/train/transports/vmware.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# encoding: utf-8
require "train/plugins"
require_relative "../plugins"
require "open3"
require "ostruct"
require "json"
Expand Down Expand Up @@ -35,7 +35,7 @@ def initialize(options)
@powershell_binary = detect_powershell_binary

if @powershell_binary == :powershell
require "train/transports/local"
require_relative "local"
@powershell = Train::Transports::Local::Connection.new(options)
end

Expand Down

0 comments on commit 8972210

Please sign in to comment.