Revision b5eca9b3
Added by Michael Moll almost 6 years ago
.rubocop_todo.yml | ||
---|---|---|
Style/DoubleNegation:
|
||
Enabled: false
|
||
|
||
# Offense count: 48
|
||
# Cop supports --auto-correct.
|
||
Style/ExpandPathArguments:
|
||
Enabled: false
|
||
|
||
# Offense count: 19
|
||
# Configuration parameters: EnforcedStyle.
|
||
# SupportedStyles: each, for
|
Rakefile | ||
---|---|---|
require File.expand_path('../config/application', __FILE__)
|
||
require File.expand_path('config/application', __dir__)
|
||
require 'rake'
|
||
require 'rake/testtask'
|
||
include Rake::DSL
|
app/registries/foreman/plugin/report_scanner_registry.rb | ||
---|---|---|
require_dependency File.expand_path('../../../../services/report_scanner/puppet_report_scanner', __FILE__)
|
||
require_dependency File.expand_path('../../../services/report_scanner/puppet_report_scanner', __dir__)
|
||
|
||
module Foreman
|
||
class Plugin
|
bin/bundle | ||
---|---|---|
#!/usr/bin/env ruby
|
||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||
load Gem.bin_path('bundler', 'bundle')
|
bin/rails | ||
---|---|---|
#!/usr/bin/env ruby
|
||
begin
|
||
load File.expand_path('../spring', __FILE__)
|
||
load File.expand_path('spring', __dir__)
|
||
rescue LoadError => e
|
||
raise unless e.message.include?('spring')
|
||
end
|
||
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
||
APP_PATH = File.expand_path('../config/application', __dir__)
|
||
require_relative '../config/boot'
|
||
require 'rails/commands'
|
bin/rake | ||
---|---|---|
#!/usr/bin/env ruby
|
||
begin
|
||
load File.expand_path('../spring', __FILE__)
|
||
load File.expand_path('spring', __dir__)
|
||
rescue LoadError => e
|
||
raise unless e.message.include?('spring')
|
||
end
|
config/application.rb | ||
---|---|---|
if defined?(Rake.application) && Rake.application.top_level_tasks.grep(/jenkins/).any?
|
||
ENV['RAILS_ENV'] ||= 'test'
|
||
end
|
||
require File.expand_path('../boot', __FILE__)
|
||
require File.expand_path('boot', __dir__)
|
||
require 'apipie/middleware/checksum_in_headers'
|
||
require 'rails/all'
|
||
|
||
require File.expand_path('../../config/settings', __FILE__)
|
||
require File.expand_path('../../lib/foreman/dynflow', __FILE__)
|
||
require File.expand_path('../config/settings', __dir__)
|
||
require File.expand_path('../lib/foreman/dynflow', __dir__)
|
||
|
||
if File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
|
||
if File.exist?(File.expand_path('../Gemfile.in', __dir__))
|
||
# If there is a Gemfile.in file, we will not use Bundler but BundlerExt
|
||
# gem which parses this file and loads all dependencies from the system
|
||
# rathern then trying to download them from rubygems.org. It always
|
||
# loads all gemfile groups.
|
||
require 'bundler_ext'
|
||
BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :all)
|
||
BundlerExt.system_require(File.expand_path('../Gemfile.in', __dir__), :all)
|
||
|
||
class Foreman::Consoletie < Rails::Railtie
|
||
console { Foreman.setup_console }
|
||
... | ... | |
# load the corresponding bit of fog
|
||
require 'fog/ovirt' if defined?(::OVIRT)
|
||
|
||
require_dependency File.expand_path('../../app/models/application_record.rb', __FILE__)
|
||
require_dependency File.expand_path('../../lib/foreman.rb', __FILE__)
|
||
require_dependency File.expand_path('../../lib/timed_cached_store.rb', __FILE__)
|
||
require_dependency File.expand_path('../../lib/foreman/exception', __FILE__)
|
||
require_dependency File.expand_path('../../lib/core_extensions', __FILE__)
|
||
require_dependency File.expand_path('../../lib/foreman/logging', __FILE__)
|
||
require_dependency File.expand_path('../../lib/foreman/http_proxy', __FILE__)
|
||
require_dependency File.expand_path('../../lib/middleware/catch_json_parse_errors', __FILE__)
|
||
require_dependency File.expand_path('../../lib/middleware/logging_context', __FILE__)
|
||
require_dependency File.expand_path('../../lib/middleware/telemetry', __FILE__)
|
||
require_dependency File.expand_path('../app/models/application_record.rb', __dir__)
|
||
require_dependency File.expand_path('../lib/foreman.rb', __dir__)
|
||
require_dependency File.expand_path('../lib/timed_cached_store.rb', __dir__)
|
||
require_dependency File.expand_path('../lib/foreman/exception', __dir__)
|
||
require_dependency File.expand_path('../lib/core_extensions', __dir__)
|
||
require_dependency File.expand_path('../lib/foreman/logging', __dir__)
|
||
require_dependency File.expand_path('../lib/foreman/http_proxy', __dir__)
|
||
require_dependency File.expand_path('../lib/middleware/catch_json_parse_errors', __dir__)
|
||
require_dependency File.expand_path('../lib/middleware/logging_context', __dir__)
|
||
require_dependency File.expand_path('../lib/middleware/telemetry', __dir__)
|
||
|
||
if SETTINGS[:support_jsonp]
|
||
if File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
|
||
BundlerExt.system_require(File.expand_path('../../Gemfile.in', __FILE__), :jsonp)
|
||
if File.exist?(File.expand_path('../Gemfile.in', __dir__))
|
||
BundlerExt.system_require(File.expand_path('../Gemfile.in', __dir__), :jsonp)
|
||
else
|
||
Bundler.require(:jsonp)
|
||
end
|
||
... | ... | |
end
|
||
|
||
def self.setup_console
|
||
ENV['IRBRC'] = File.expand_path('../irbrc', __FILE__)
|
||
ENV['IRBRC'] = File.expand_path('irbrc', __dir__)
|
||
User.current = User.anonymous_console_admin
|
||
Rails.logger.warn "Console started with '#{User.current.login}' user, call User.current= to change it"
|
||
end
|
config/boot.rb | ||
---|---|---|
require 'rubygems'
|
||
|
||
unless File.exist?(File.expand_path('../../Gemfile.in', __FILE__))
|
||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||
unless File.exist?(File.expand_path('../Gemfile.in', __dir__))
|
||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
||
end
|
config/boot_settings.rb | ||
---|---|---|
require 'erb'
|
||
require 'yaml'
|
||
|
||
dist_settings_file = File.expand_path('../settings.yaml.dist', __FILE__)
|
||
dist_settings_file = File.expand_path('settings.yaml.dist', __dir__)
|
||
SETTINGS = File.exist?(dist_settings_file) ? YAML.load(ERB.new(File.read(dist_settings_file)).result) || {} : {}
|
||
|
||
settings_file = File.expand_path('../settings.yaml', __FILE__)
|
||
settings_file = File.expand_path('settings.yaml', __dir__)
|
||
if File.exist?(settings_file)
|
||
settings = YAML.load(ERB.new(File.read(settings_file)).result)
|
||
SETTINGS[:rails] = settings[:rails] if settings[:rails]
|
config/environment.rb | ||
---|---|---|
# Load the rails application
|
||
require File.expand_path('../application', __FILE__)
|
||
require File.expand_path('application', __dir__)
|
||
|
||
# Initialize the rails application
|
||
Foreman::Application.initialize!
|
lib/foreman/http_proxy.rb | ||
---|---|---|
end
|
||
end
|
||
|
||
require_dependency File.expand_path('../http_proxy/excon_connection_extension', __FILE__)
|
||
require_dependency File.expand_path('../http_proxy/net_http_extension', __FILE__)
|
||
require_dependency File.expand_path('../http_proxy/rest_client_extension', __FILE__)
|
||
require_dependency File.expand_path('http_proxy/excon_connection_extension', __dir__)
|
||
require_dependency File.expand_path('http_proxy/net_http_extension', __dir__)
|
||
require_dependency File.expand_path('http_proxy/rest_client_extension', __dir__)
|
lib/foreman/logging.rb | ||
---|---|---|
build_console_appender
|
||
# we need to postpone loading of the silenced logger
|
||
# to the time the Logging::LEVELS is initialized
|
||
require_dependency File.expand_path('../silenced_logger', __FILE__)
|
||
require_dependency File.expand_path('silenced_logger', __dir__)
|
||
end
|
||
|
||
def add_loggers(loggers = {})
|
lib/tasks/backup.rake | ||
---|---|---|
desc <<-END_DESC
|
||
Make a dump of your database
|
||
|
||
Foreman will make a dump of your database at the provided location, or it will put it in #{File.expand_path('../../../db', __FILE__)} if no destination file is provided.
|
||
Foreman will make a dump of your database at the provided location, or it will put it in #{File.expand_path('../../db', __dir__)} if no destination file is provided.
|
||
A valid config/database.yml file with the database details is needed to perform this operation.
|
||
|
||
Available conditions:
|
||
* destination => path to dump output file (defaults to #{File.expand_path('../../../db', __FILE__)}/foreman.EPOCH.sql)
|
||
* destination => path to dump output file (defaults to #{File.expand_path('../../db', __dir__)}/foreman.EPOCH.sql)
|
||
* tables => optional comma separated list of tables (you can use regex to match multiple)
|
||
Specifies the list of tables to include in the dump.
|
||
This option works for postgres and mysql only.
|
||
... | ... | |
|
||
task :dump => :environment do
|
||
config = Rails.configuration.database_configuration[Rails.env]
|
||
backup_dir = File.expand_path('../../../db', __FILE__)
|
||
backup_dir = File.expand_path('../../db', __dir__)
|
||
backup_name = ENV['destination'] || File.join(backup_dir, "foreman.#{Time.now.to_i}")
|
||
unless ENV["destination"].present?
|
||
if config["adapter"] == "sqlite3"
|
lib/tasks/gettext.rake | ||
---|---|---|
require "gettext_i18n_rails"
|
||
require "gettext_i18n_rails/tasks"
|
||
require "gettext_i18n_rails_js/task"
|
||
require File.expand_path("../../../lib/foreman/gettext/support.rb", __FILE__)
|
||
require File.expand_path('../../lib/foreman/gettext/support.rb', __dir__)
|
||
|
||
namespace :gettext do
|
||
# redefine locale path to be taken from current directory (for plugins)
|
script/foreman-config | ||
---|---|---|
#!/usr/bin/env ruby
|
||
|
||
require 'optparse'
|
||
defaults = { :foreman_path => File.expand_path("../..", __FILE__),
|
||
defaults = { :foreman_path => File.expand_path('..', __dir__),
|
||
:environment => "production"}
|
||
options = defaults.dup
|
||
warn 'foreman-config script is deprecated. Please consider using `foreman-rake config` instead'
|
test/benchmark/benchmark_helper.rb | ||
---|---|---|
require 'benchmark/ips'
|
||
|
||
require File.expand_path('../../../config/environment', __FILE__)
|
||
require File.expand_path('../../config/environment', __dir__)
|
||
|
||
unless Rails.env.production? && !Rails.configuration.database_configuration["production"]["migrate"]
|
||
puts "Rais must be in production and database must have migrations turned off!"
|
test/controllers/compute_resources_controller_test.rb | ||
---|---|---|
|
||
context 'with pagelets' do
|
||
setup do
|
||
@controller.prepend_view_path File.expand_path('../../static_fixtures', __FILE__)
|
||
@controller.prepend_view_path File.expand_path('../static_fixtures', __dir__)
|
||
Pagelets::Manager.add_pagelet('compute_resources/show', :main_tabs,
|
||
:name => 'TestTab',
|
||
:id => 'my-special-id',
|
test/controllers/hostgroups_controller_test.rb | ||
---|---|---|
|
||
context 'with pagelets' do
|
||
setup do
|
||
@controller.prepend_view_path File.expand_path('../../static_fixtures', __FILE__)
|
||
@controller.prepend_view_path File.expand_path('../static_fixtures', __dir__)
|
||
Pagelets::Manager.add_pagelet('hostgroups/_form', :main_tabs,
|
||
:name => 'TestTab',
|
||
:id => 'my-special-id',
|
test/controllers/hosts_controller_test.rb | ||
---|---|---|
|
||
context 'with pagelets' do
|
||
setup do
|
||
@controller.prepend_view_path File.expand_path('../../static_fixtures', __FILE__)
|
||
@controller.prepend_view_path File.expand_path('../static_fixtures', __dir__)
|
||
Pagelets::Manager.add_pagelet('hosts/show', :main_tabs,
|
||
:name => 'TestTab',
|
||
:id => 'my-special-id',
|
test/helpers/pagelets_helper_test.rb | ||
---|---|---|
include PageletsIsolation
|
||
|
||
setup do
|
||
controller.prepend_view_path File.expand_path('../../static_fixtures/views', __FILE__)
|
||
controller.prepend_view_path File.expand_path('../static_fixtures/views', __dir__)
|
||
self.stubs(:virtual_path).returns("nonexisting/path")
|
||
end
|
||
|
test/integration/smart_proxy_test.rb | ||
---|---|---|
|
||
setup do
|
||
@view_paths = SmartProxiesController.view_paths
|
||
SmartProxiesController.prepend_view_path File.expand_path('../../static_fixtures/views', __FILE__)
|
||
SmartProxiesController.prepend_view_path File.expand_path('../static_fixtures/views', __dir__)
|
||
end
|
||
|
||
def teardown
|
test/integration_test_helper.rb | ||
---|---|---|
ENV["RAILS_ENV"] = "test"
|
||
require File.expand_path('../../config/environment', __FILE__)
|
||
require File.expand_path('../config/environment', __dir__)
|
||
require 'rails/test_help'
|
||
require 'mocha/mini_test'
|
||
require 'capybara/rails'
|
test/test_helper.rb | ||
---|---|---|
|
||
ENV["RAILS_ENV"] = "test"
|
||
require 'minitest/mock'
|
||
require File.expand_path('../../config/environment', __FILE__)
|
||
require File.expand_path('../config/environment', __dir__)
|
||
require 'rails/test_help'
|
||
require 'mocha/minitest'
|
||
require 'factory_bot_rails'
|
test/unit/rabl_test.rb | ||
---|---|---|
rendered = Rabl.render(@media,
|
||
'api/v2/test/one',
|
||
:format => :json,
|
||
:view_path => File.expand_path('../../../test/static_fixtures/views', __FILE__))
|
||
:view_path => File.expand_path('../../test/static_fixtures/views', __dir__))
|
||
loaded = JSON.load(rendered)
|
||
assert_equal Hash, loaded.class
|
||
assert_equal @media.name, loaded['name']
|
test/unit/tasks/seeds_test.rb | ||
---|---|---|
def seed
|
||
# Authorisation is disabled usually when run from a rake db:* task
|
||
as_admin do
|
||
load File.expand_path('../../../../db/seeds.rb', __FILE__)
|
||
load File.expand_path('../../../db/seeds.rb', __dir__)
|
||
end
|
||
end
|
||
|
Also available in: Unified diff
Fixes #23962 - Fix Style/ExpandPathArguments cop