Module: Djin

Defined in:
lib/djin.rb,
lib/djin/cli.rb,
lib/djin/errors.rb,
lib/djin/version.rb,
lib/djin/executor.rb,
lib/djin/interpreter.rb,
lib/djin/memory_cache.rb,
lib/djin/config_loader.rb,
lib/djin/entities/task.rb,
lib/djin/task_contract.rb,
lib/djin/entities/types.rb,
lib/djin/root_cli_parser.rb,
lib/djin/include_contract.rb,
lib/djin/entities/main_config.rb,
lib/djin/include_config_loader.rb,
lib/djin/entities/include_config.rb,
lib/djin/extensions/hash_extensions.rb,
lib/djin/entities/include_config/base.rb,
lib/djin/extensions/object_extensions.rb,
lib/djin/entities/include_config/local.rb,
lib/djin/interpreter/base_command_builder.rb,
lib/djin/interpreter/local_command_builder.rb,
lib/djin/interpreter/docker_command_builder.rb,
lib/djin/repositories/remote_config_repository.rb,
lib/djin/interpreter/docker_compose_command_builder.rb

Defined Under Namespace

Modules: HashExtensions, IncludeConfig, ObjectExtensions, Types Classes: CLI, ConfigLoader, Error, Executor, IncludeConfigLoader, IncludeContract, Interpreter, MainConfig, MemoryCache, RemoteConfigRepository, RootCliParser, Task, TaskContract

Constant Summary collapse

InvalidConfigurationError =
Class.new(StandardError)
InvalidConfigFileError =
Class.new(InvalidConfigurationError)
MissingVersionError =
Class.new(InvalidConfigurationError)
VersionNotSupportedError =
Class.new(InvalidConfigurationError)
InvalidSyntaxError =
Class.new(InvalidConfigurationError)
FileNotFoundError =
Class.new(InvalidConfigurationError)
TaskError =
Class.new(StandardError)
VERSION =
'0.11.7'

Class Method Summary collapse

Class Method Details

.cacheObject



73
74
75
# File 'lib/djin.rb', line 73

def cache
  @cache ||= MemoryCache.new
end

.load_tasks!(*file_paths) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/djin.rb', line 42

def load_tasks!(*file_paths)
  files = file_paths.presence || RootCliParser.parse![:files] || ['djin.yml']

  file_config = ConfigLoader.load_files!(*files)

  # TODO: Make all tasks be under 'tasks' key, passing only the tasks here
  tasks = Interpreter.load!(file_config)

  @task_repository = TaskRepository.new(tasks)

  remote_configs = file_config.include_configs.select { |f| f.type == :remote }
  @remote_config_repository = RemoteConfigRepository.new(remote_configs)

  CLI.load_tasks!(tasks)
rescue Djin::InvalidConfigurationError => e
  error_name = e.class.name.split('::').last
  abort("[#{error_name}] #{e.message}")
end

.remote_config_repositoryObject



69
70
71
# File 'lib/djin.rb', line 69

def remote_config_repository
  @remote_config_repository ||= RemoteConfigRepository.new
end

.root_pathObject



77
78
79
# File 'lib/djin.rb', line 77

def root_path
  Pathname.new File.expand_path(__dir__ + '/..')
end

.stderrObject



93
94
95
# File 'lib/djin.rb', line 93

def stderr
  $stderr
end

.task_repositoryObject



65
66
67
# File 'lib/djin.rb', line 65

def task_repository
  @task_repository ||= TaskRepository.new
end

.tasksObject



61
62
63
# File 'lib/djin.rb', line 61

def tasks
  task_repository.all
end

.warn(message, type: 'WARNING') ⇒ Object



81
82
83
# File 'lib/djin.rb', line 81

def warn(message, type: 'WARNING')
  stderr.puts "[#{type}] #{message}"
end

.warn_once(message, type: 'WARNING') ⇒ Object



85
86
87
88
89
90
91
# File 'lib/djin.rb', line 85

def warn_once(message, type: 'WARNING')
  return if warnings.include?(message)

  warn(message, type: type)

  warnings << message
end