-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
447 additions
and
27 deletions.
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Gem | ||
class Dependency | ||
property name : String | ||
property requirements : Array(String) | ||
|
||
def initialize(@name, @requirements) | ||
end | ||
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 |
---|---|---|
|
@@ -2,6 +2,8 @@ module Molinillo | |
class TestUI | ||
include UI | ||
|
||
@output : IO? | ||
|
||
def output | ||
@output ||= if debug? | ||
STDERR | ||
|
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,27 @@ | ||
require "./spec_helper" | ||
|
||
module Molinillo | ||
describe ResolutionState do | ||
describe DependencyState do | ||
it "pops a possibility state" do | ||
state = DependencyState(Nil, String, String).new( | ||
"name", | ||
%w(requirement1 requirement2 requirement3), | ||
DependencyGraph(Nil, String).new, | ||
"requirement", | ||
%w(possibility1 possibility), | ||
0, | ||
{} of String => Nil, | ||
[] of Nil | ||
) | ||
possibility_state = state.pop_possibility_state | ||
# %w(name requirements activated requirement conflicts).each do |attr| | ||
# expect(possibility_state.send(attr)).to eq(state.send(attr)) | ||
# end | ||
possibility_state.should be_a(PossibilityState(Nil, String, String)) | ||
possibility_state.depth.should eq(state.depth + 1) | ||
possibility_state.possibilities.should eq(%w(possibility)) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
module Molinillo | ||
# @!visibility private | ||
module Delegates | ||
# Delegates all {Molinillo::ResolutionState} methods to a `#state` property. | ||
module ResolutionState(R, S) | ||
# (see Molinillo::ResolutionState#name) | ||
def name | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.name | ||
end | ||
|
||
# (see Molinillo::ResolutionState#requirements) | ||
def requirements | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.requirements | ||
end | ||
|
||
# (see Molinillo::ResolutionState#activated) | ||
def activated | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.activated | ||
end | ||
|
||
# (see Molinillo::ResolutionState#requirement) | ||
def requirement | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.requirement | ||
end | ||
|
||
# (see Molinillo::ResolutionState#possibilities) | ||
def possibilities | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.possibilities | ||
end | ||
|
||
# (see Molinillo::ResolutionState#depth) | ||
def depth | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.depth | ||
end | ||
|
||
# (see Molinillo::ResolutionState#conflicts) | ||
def conflicts | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.conflicts | ||
end | ||
|
||
# (see Molinillo::ResolutionState#unused_unwind_options) | ||
def unused_unwind_options | ||
current_state = state || Molinillo::ResolutionState(R, S).empty | ||
current_state.unused_unwind_options | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
module Molinillo | ||
module Delegates | ||
# Delegates all {Molinillo::SpecificationProvider} methods to a | ||
# `#specification_provider` property. | ||
module SpecificationProvider | ||
# (see Molinillo::SpecificationProvider#search_for) | ||
def search_for(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.search_for(dependency) | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#dependencies_for) | ||
def dependencies_for(specification) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.dependencies_for(specification) | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#requirement_satisfied_by?) | ||
def requirement_satisfied_by?(requirement, activated, spec) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.requirement_satisfied_by?(requirement, activated, spec) | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#name_for) | ||
def name_for(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for(dependency) | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#name_for_explicit_dependency_source) | ||
def name_for_explicit_dependency_source | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for_explicit_dependency_source | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#name_for_locking_dependency_source) | ||
def name_for_locking_dependency_source | ||
with_no_such_dependency_error_handling do | ||
specification_provider.name_for_locking_dependency_source | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#sort_dependencies) | ||
def sort_dependencies(dependencies, activated, conflicts) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.sort_dependencies(dependencies, activated, conflicts) | ||
end | ||
end | ||
|
||
# (see Molinillo::SpecificationProvider#allow_missing?) | ||
def allow_missing?(dependency) | ||
with_no_such_dependency_error_handling do | ||
specification_provider.allow_missing?(dependency) | ||
end | ||
end | ||
|
||
# Ensures any raised {NoSuchDependencyError} has its | ||
# {NoSuchDependencyError#required_by} set. | ||
# @yield | ||
private def with_no_such_dependency_error_handling | ||
yield | ||
rescue error # TODO : NoSuchDependencyError | ||
if state | ||
# TODO | ||
# vertex = activated.vertex_named(name_for(error.dependency)) | ||
# error.required_by += vertex.incoming_edges.map { |e| e.origin.name } | ||
# error.required_by << name_for_explicit_dependency_source unless vertex.explicit_requirements.empty? | ||
end | ||
raise error | ||
end | ||
end | ||
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
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
Oops, something went wrong.