Class: DTK::Network::Client::DependencyTree
- Inherits:
-
Object
- Object
- DTK::Network::Client::DependencyTree
show all
- Extended by:
- RestWrapper
- Includes:
- RestWrapper
- Defined in:
- lib/client/dependency_tree.rb,
lib/client/dependency_tree/cache.rb,
lib/client/dependency_tree/resolver.rb,
lib/client/dependency_tree/activated.rb,
lib/client/dependency_tree/candidates.rb
Defined Under Namespace
Classes: Activated, Cache, Candidates, Resolver
Constant Summary
collapse
- LOCK_FILE =
"dtk.module.lock"
Class Method Summary
collapse
Instance Method Summary
collapse
rest_delete, rest_get, rest_post
Constructor Details
#initialize(module_ref, opts = {}) ⇒ DependencyTree
Returns a new instance of DependencyTree.
15
16
17
18
19
20
21
22
23
|
# File 'lib/client/dependency_tree.rb', line 15
def initialize(module_ref, opts = {})
@module_ref = module_ref
@module_directory = opts[:module_directory] || module_ref.repo_dir
@parsed_module = opts[:parsed_module]
@cache = Cache.new
@activated = Activated.new
@candidates = Candidates.new
@development_mode = opts[:development_mode]
end
|
Class Method Details
.compute(module_ref, opts = {}) ⇒ Object
49
50
51
|
# File 'lib/client/dependency_tree.rb', line 49
def self.compute(module_ref, opts = {})
new(module_ref, opts).compute
end
|
.compute_and_save_to_file(module_ref, opts = {}) ⇒ Object
43
44
45
46
47
|
# File 'lib/client/dependency_tree.rb', line 43
def self.compute_and_save_to_file(module_ref, opts = {})
activated = compute(module_ref, opts)
ModuleDir.create_file_with_content("#{module_ref.repo_dir}/#{LOCK_FILE}", YAML.dump(activated.to_h))
activated
end
|
.get_or_create(module_ref, opts = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/client/dependency_tree.rb', line 25
def self.get_or_create(module_ref, opts = {})
content = nil
module_ref = convert_to_module_ref(module_ref) unless module_ref.is_a?(ModuleRef)
update_lock_file = opts[:update_lock_file]
yaml_content = FileHelper.get_content?("#{module_ref.repo_dir}/#{LOCK_FILE}")
if yaml_content && !update_lock_file
content = YAML.load(yaml_content)
raise_error_if_dependencies_changed!(content, opts[:parsed_module])
elsif opts[:save_to_file] || update_lock_file
content = compute_and_save_to_file(module_ref, opts)
else
content = compute(module_ref, opts)
end
ret_required_format(content, opts[:format])
end
|
Instance Method Details
#compute ⇒ Object
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/client/dependency_tree.rb', line 53
def compute
dependencies = (ret_dependencies || []).map do |pm_ref|
ModuleRef::Dependency.create_local_or_remote(pm_ref)
end
activate_dependencies(dependencies)
@activated
sort_activated_dependencies(@activated)
end
|