grimoire 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/grimoire/solver.rb +33 -1
- data/lib/grimoire/unit_score_keeper.rb +3 -1
- data/lib/grimoire/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a67e6b4597f818bf3075b20f3910be621cde2c8
|
4
|
+
data.tar.gz: 8d5e37c2641122b761c3c3c1128a77ad906d0430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb8424d75e0392beaa679ccdce8d7046d8bc37d061db0f628635f46d44952c508cca2f89f2e8a37edd110ee3df82b62ab63c64c103a30a910573472c99f34f41
|
7
|
+
data.tar.gz: b7a5c8769d2c75472eb3e1b0b3a0774a006eae9bfff8df0bfd02e04c9434b29f76e7d5416d236e63d8d5c0c85df349af2a169de0f0b8f7b16378658a276b3065
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# v0.2.2
|
2
|
+
* Provide origin solver to score keeper when requesting unit score
|
3
|
+
* Introduce Solver#prune_world! to remove extraneous units
|
4
|
+
|
1
5
|
# v0.2.0
|
2
6
|
* Use direct `#to_json` to prevent conversion errors on older ruby
|
3
7
|
* Add `UnitScoreKeeper#preferred_score` to provide some score meaning
|
data/lib/grimoire/solver.rb
CHANGED
@@ -17,16 +17,48 @@ module Grimoire
|
|
17
17
|
|
18
18
|
# @return [System] subset of full system based on requirements
|
19
19
|
attr_reader :world
|
20
|
+
# @return [System, NilClass] new system subset when pruning
|
21
|
+
attr_reader :new_world
|
20
22
|
|
21
23
|
def initialize(*_)
|
22
24
|
super
|
23
25
|
@world = System.new
|
26
|
+
@new_world = nil
|
24
27
|
@log = []
|
25
28
|
build_world(requirements.requirements, world, system)
|
26
29
|
@log.clear
|
27
30
|
world.scrub!
|
28
31
|
end
|
29
32
|
|
33
|
+
# After the world has been generated extraneous units will
|
34
|
+
# be included as a result of dependency constraints that may
|
35
|
+
# be too loose and are not actually required by any resolution
|
36
|
+
# that would be requested. This will run a second pass and remove
|
37
|
+
# extraneous items not required.
|
38
|
+
#
|
39
|
+
# @return [self]
|
40
|
+
# @note This must be called explicitly and is provided for
|
41
|
+
# resolving an entire system, not a single resolution path
|
42
|
+
def prune_world!
|
43
|
+
@new_world = System.new
|
44
|
+
requirements.requirements.each do |req|
|
45
|
+
world.units[req.name].each do |r_unit|
|
46
|
+
path = Solver.new(
|
47
|
+
:requirements => RequirementList.new(
|
48
|
+
:name => :world_pruner,
|
49
|
+
:requirements => [[r_unit.name, r_unit.version.version]]
|
50
|
+
),
|
51
|
+
:system => world,
|
52
|
+
:score_keeper => score_keeper
|
53
|
+
).generate!.pop
|
54
|
+
new_world.add_unit(*path.units)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
@world = new_world
|
58
|
+
@new_world = nil
|
59
|
+
self
|
60
|
+
end
|
61
|
+
|
30
62
|
# Build the world required for the solver (the subset of the
|
31
63
|
# entire system required by the requirements)
|
32
64
|
#
|
@@ -97,7 +129,7 @@ module Grimoire
|
|
97
129
|
# @return [Numeric] score
|
98
130
|
def score_unit(unit, score)
|
99
131
|
if(score_keeper)
|
100
|
-
score_keeper.score_for(unit, score) || score
|
132
|
+
score_keeper.score_for(unit, score, :solver => self) || score
|
101
133
|
else
|
102
134
|
score
|
103
135
|
end
|
@@ -15,8 +15,10 @@ module Grimoire
|
|
15
15
|
#
|
16
16
|
# @param unit [Unit]
|
17
17
|
# @param idx [Integer] current order index
|
18
|
+
# @param opts [Hash] extra options
|
19
|
+
# @option opts [Solver] :solver solver requesting score
|
18
20
|
# @return [Numeric]
|
19
|
-
def score_for(unit, idx)
|
21
|
+
def score_for(unit, idx, opts={})
|
20
22
|
raise NotImplementedError.new 'No scoring has been defined'
|
21
23
|
end
|
22
24
|
|
data/lib/grimoire/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grimoire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo
|