-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement autoloading #289
Draft
ekohl
wants to merge
4
commits into
theforeman:master
Choose a base branch
from
ekohl:autoloader
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/usr/bin/env ruby | ||
|
||
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'kafo')) | ||
require 'kafo_configure' | ||
$LOAD_PATH.unshift File.expand_path(File.join(__dir__, '..', 'lib')) | ||
require 'kafo' | ||
result = Kafo::KafoConfigure.run | ||
exit result.nil? ? 0 : result.exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
# encoding: UTF-8 | ||
|
||
require 'kafo/version' | ||
require 'kafo/kafo_configure' | ||
|
||
# First of all we have to store ENV variable, requiring facter can override them | ||
module Kafo | ||
module ENV | ||
LANG = ::ENV['LANG'] | ||
end | ||
|
||
autoload :BaseContext, 'kafo/base_context' | ||
autoload :ColorScheme, 'kafo/color_scheme' | ||
autoload :Condition, 'kafo/condition' | ||
autoload :ConditionError, 'kafo/exceptions' | ||
autoload :Configuration, 'kafo/configuration' | ||
autoload :ConfigurationException, 'kafo/exceptions' | ||
autoload :DataType, 'kafo/data_type' | ||
autoload :DataTypeParser, 'kafo/data_type_parser' | ||
autoload :DataTypes, 'kafo/data_type' # This is inconsistent | ||
autoload :ExecutionEnvironment, 'kafo/execution_environment' | ||
autoload :ExitHandler, 'kafo/exit_handler' | ||
autoload :FactWriter, 'kafo/fact_writer' | ||
autoload :HelpBuilders, 'kafo/help_builders' | ||
autoload :HieraConfigurer, 'kafo/hiera_configurer' | ||
autoload :HookContext, 'kafo/hook_context' | ||
autoload :Hooking, 'kafo/hooking' | ||
autoload :KafoConfigure, 'kafo/kafo_configure' | ||
autoload :Logger, 'kafo/logger' | ||
autoload :Logging, 'kafo/logging' | ||
autoload :MigrationContext, 'kafo/migration_context' | ||
autoload :Migrations, 'kafo/migrations' | ||
autoload :Param, 'kafo/param' | ||
autoload :ParamBuilder, 'kafo/param_builder' | ||
autoload :ParamGroup, 'kafo/param_group' | ||
autoload :ParserCacheReader, 'kafo/parser_cache_reader' | ||
autoload :ParserCacheWriter, 'kafo/parser_cache_writer' | ||
autoload :ParserError, 'kafo/exceptions' | ||
autoload :ProgressBar, 'kafo/progress_bar' | ||
autoload :ProgressBars, 'kafo/progress_bars' | ||
autoload :PuppetCommand, 'kafo/puppet_command' | ||
autoload :PuppetConfigurer, 'kafo/puppet_configurer' | ||
autoload :PuppetLogParser, 'kafo/puppet_log_parser' | ||
autoload :PuppetModule, 'kafo/puppet_module' | ||
autoload :ScenarioManager, 'kafo/scenario_manager' | ||
autoload :Store, 'kafo/store' | ||
autoload :StringHelper, 'kafo/string_helper' | ||
autoload :SystemChecker, 'kafo/system_checker' | ||
autoload :TypeError, 'kafo/exceptions' | ||
autoload :Wizard, 'kafo/wizard' | ||
end | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Kafo | ||
module HelpBuilders | ||
autoload :Advanced, 'kafo/help_builders/advanced' | ||
autoload :Base, 'kafo/help_builders/base' | ||
autoload :Basic, 'kafo/help_builders/basic' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,9 @@ | ||
# encoding: UTF-8 | ||
|
||
# First of all we have to store ENV variable, requiring facter can override them | ||
module Kafo | ||
module ENV | ||
LANG = ::ENV['LANG'] | ||
end | ||
end | ||
|
||
require 'pty' | ||
require 'clamp' | ||
require 'kafo/color_scheme' | ||
require 'kafo_parsers/exceptions' | ||
require 'kafo/exceptions' | ||
require 'kafo/migrations' | ||
require 'kafo/store' | ||
require 'kafo/configuration' | ||
require 'kafo/logger' | ||
require 'kafo/string_helper' | ||
require 'kafo/help_builder' | ||
require 'kafo/wizard' | ||
require 'kafo/system_checker' | ||
require 'kafo/puppet_command' | ||
require 'kafo/puppet_log_parser' | ||
require 'kafo/progress_bar' | ||
require 'kafo/hooking' | ||
require 'kafo/exit_handler' | ||
require 'kafo/scenario_manager' | ||
require 'kafo/execution_environment' | ||
require 'kafo/logging' | ||
|
||
module Kafo | ||
class KafoConfigure < Clamp::Command | ||
class KafoConfigure < ::Clamp::Command | ||
include StringHelper | ||
|
||
class << self | ||
|
@@ -446,6 +419,7 @@ def run_installation | |
log_parser = PuppetLogParser.new | ||
logger = Logger.new('configure') | ||
|
||
require 'pty' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I dislike these mid-code requires. They can hide errors, and lead to missing libraries at runtime. |
||
PTY.spawn(*PuppetCommand.format_command(command)) do |stdin, stdout, pid| | ||
begin | ||
stdin.each do |line| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# encoding: UTF-8 | ||
require 'kafo/logging' | ||
|
||
module Kafo | ||
class Logger | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'kafo/base_context' | ||
|
||
module Kafo | ||
class MigrationContext < BaseContext | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'yaml' | ||
require 'kafo/migration_context' | ||
|
||
module Kafo | ||
class Migrations | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# encoding: UTF-8 | ||
require 'kafo/condition' | ||
require 'kafo/data_type' | ||
|
||
module Kafo | ||
class Param | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
# encoding: UTF-8 | ||
require 'kafo/param_group' | ||
|
||
module Kafo | ||
class ParamBuilder | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'kafo/version' | ||
|
||
module Kafo | ||
class ParserCacheReader | ||
attr_accessor :force | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'kafo/version' | ||
|
||
module Kafo | ||
class ParserCacheWriter | ||
def self.write(modules) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Kafo | ||
module ProgressBars | ||
autoload :Colored, 'kafo/progress_bars/colored' | ||
autoload :BlackWhite, 'kafo/progress_bars/black_white' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'test_helper' | ||
require 'kafo/fact_writer' | ||
|
||
module Kafo | ||
describe FactWriter do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'test_helper' | ||
require 'kafo/hiera_configurer' | ||
|
||
module Kafo | ||
describe HieraConfigurer do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'test_helper' | ||
require 'kafo/parser_cache_writer' | ||
|
||
module Kafo | ||
describe ParserCacheReader do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
require 'test_helper' | ||
require 'kafo/parser_cache_writer' | ||
require 'tempfile' | ||
|
||
module Kafo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
require 'kafo_parsers/parsers' | ||
|
||
class TestParser | ||
attr_reader :manifest_file | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems overly verbose compared to something more automatic -- https://github.com/theforeman/tool_belt/blob/master/lib/tool_belt.rb#L2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is that tool_belt is loading it all up front where
autoload
is lazy loading. You can also copy the pattern used by autoloaded to automatically convert file names to class/module names.