Module: Djin

Defined in:
lib/djin.rb,
lib/djin/cli.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_resolver.rb,
lib/djin/entities/main_config.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, IncludeResolver, Interpreter, MainConfig, MemoryCache, RemoteConfigRepository, RootCliParser, Task, TaskContract

Constant Summary collapse

VERSION =
'0.11.0'

Class Method Summary collapse

Class Method Details

.cacheObject



71
72
73
# File 'lib/djin.rb', line 71

def cache
  @cache ||= MemoryCache.new
end

.load_tasks!(*file_paths) ⇒ Object



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

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::Interpreter::InvalidConfigurationError => e
  error_name = e.class.name.split('::').last
  abort("[#{error_name}] #{e.message}")
end

.remote_config_repositoryObject



67
68
69
# File 'lib/djin.rb', line 67

def remote_config_repository
  @remote_config_repository ||= RemoteConfigRepository.new
end

.root_pathObject



75
76
77
# File 'lib/djin.rb', line 75

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

.stderrObject



91
92
93
# File 'lib/djin.rb', line 91

def stderr
  $stderr
end

.task_repositoryObject



63
64
65
# File 'lib/djin.rb', line 63

def task_repository
  @task_repository ||= TaskRepository.new
end

.tasksObject



59
60
61
# File 'lib/djin.rb', line 59

def tasks
  task_repository.all
end

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



79
80
81
# File 'lib/djin.rb', line 79

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

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



83
84
85
86
87
88
89
# File 'lib/djin.rb', line 83

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

  warn(message, type: type)

  warnings << message
end