cassowary-ruby 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/linear_expression.rb +6 -0
- data/lib/simplex_solver.rb +1 -1
- data/test/test_cassowary.rb +35 -1
- data/test/test_variables.rb +15 -0
- metadata +43 -47
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MTIwMTZhOTBiNjBiOGQ1NzU1NDk1YTc2YjYzZjEyOGQ5N2UxMGFhOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZjVlYjgwNGFiNGM5ZGFiNWExZTVhYzQzZmEwMjM5MDcyMTJhYmM2ZA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ODY0ZDI4NjhjODk3N2NhZWFlNzE4NDkxMjM5ZTFlNDY0ZjkwMzE3N2Q0YWY5
|
10
|
+
OTcxZWJmZmJlZjc1YmI4MGRkMjMwOTFlN2U3ZWY0Y2I2MDEwZjRlZTg2MDBm
|
11
|
+
NmJkNjI1MzZiYTcxNDUxY2Y2Njg4MTcxNTY5YWU0NTk3ZjQ5ZGE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NWNjZThlY2Q1YjMxODBkZDFlMDE0ZmU0YzIyMzhhNTExMzJkZWIyOTRiN2Iw
|
14
|
+
MDY4ODA3ZWFiNDE5MTAxN2RmYzc3OTJmOWJjNGIzZmIxZDkyM2Q1ZWUwMjg1
|
15
|
+
MDdmNzMzMjFiNjM1N2YzOGY4YWU2N2M3ZmRkOTJhMzkxY2U5NDU=
|
data/lib/linear_expression.rb
CHANGED
data/lib/simplex_solver.rb
CHANGED
data/test/test_cassowary.rb
CHANGED
@@ -139,7 +139,7 @@ class CassowaryTests < Test::Unit::TestCase
|
|
139
139
|
assert x.value.cl_approx 15
|
140
140
|
end
|
141
141
|
|
142
|
-
def
|
142
|
+
def test_edit1var
|
143
143
|
x = Variable.new name: 'x', value: 20
|
144
144
|
y = Variable.new name: 'y', value: 30
|
145
145
|
|
@@ -181,4 +181,38 @@ class CassowaryTests < Test::Unit::TestCase
|
|
181
181
|
|
182
182
|
solver.end_edit
|
183
183
|
end
|
184
|
+
|
185
|
+
def test_edit2vars
|
186
|
+
x = Variable.new name: 'x', value: 20
|
187
|
+
y = Variable.new name: 'y', value: 30
|
188
|
+
z = Variable.new name: 'z', value: 120
|
189
|
+
|
190
|
+
solver = SimplexSolver.new
|
191
|
+
solver.add_stay x, Strength::WeakStrength
|
192
|
+
solver.add_stay z, Strength::WeakStrength
|
193
|
+
solver.add_constraint z.cn_equal x*2 + y
|
194
|
+
assert x.value.cl_approx 20
|
195
|
+
assert y.value.cl_approx 80
|
196
|
+
assert z.value.cl_approx 120
|
197
|
+
|
198
|
+
solver.add_edit_var x, Strength::StrongStrength
|
199
|
+
solver.add_edit_var y, Strength::StrongStrength
|
200
|
+
solver.begin_edit
|
201
|
+
solver.suggest_value x, 10
|
202
|
+
solver.suggest_value y, 5
|
203
|
+
solver.resolve
|
204
|
+
assert x.value.cl_approx 10
|
205
|
+
assert y.value.cl_approx 5
|
206
|
+
assert z.value.cl_approx 25
|
207
|
+
|
208
|
+
solver.suggest_value x, -10
|
209
|
+
solver.suggest_value y, 15
|
210
|
+
solver.resolve
|
211
|
+
assert x.value.cl_approx -10
|
212
|
+
assert y.value.cl_approx 15
|
213
|
+
assert z.value.cl_approx -5
|
214
|
+
solver.end_edit
|
215
|
+
end
|
216
|
+
|
217
|
+
|
184
218
|
end
|
data/test/test_variables.rb
CHANGED
@@ -30,4 +30,19 @@ class VariablesTests < Test::Unit::TestCase
|
|
30
30
|
x = Cassowary::SlackVariable.new
|
31
31
|
assert_equal "<CV#0x" + x.object_id.to_s(16) + ">", x.inspect
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_evaluating_linear_expressions
|
35
|
+
x = Cassowary::Variable.new name: 'x', value: 20
|
36
|
+
expr = x / 10
|
37
|
+
assert expr.value == 2
|
38
|
+
|
39
|
+
expr *= 2
|
40
|
+
assert expr.value == 4
|
41
|
+
|
42
|
+
expr += 10
|
43
|
+
assert expr.value == 14
|
44
|
+
|
45
|
+
expr -= 3
|
46
|
+
assert expr.value == 11
|
47
|
+
end
|
33
48
|
end
|
metadata
CHANGED
@@ -1,52 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cassowary-ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 1
|
10
|
-
version: 0.5.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Tim Felgentreff
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2012-11-27 00:00:00 Z
|
11
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
19
12
|
dependencies: []
|
13
|
+
description: ! '## Cassowary
|
20
14
|
|
21
|
-
description: |
|
22
|
-
## Cassowary
|
23
15
|
[](https://travis-ci.org/timfel/cassowary)
|
24
|
-
|
16
|
+
|
17
|
+
|
25
18
|
Cassowary is an incremental constraint solving toolkit that
|
19
|
+
|
26
20
|
efficiently solves systems of linear equalities and
|
21
|
+
|
27
22
|
inequalities. Constraints may be either requirements or
|
23
|
+
|
28
24
|
preferences. Client code specifies the constraints to be maintained,
|
25
|
+
|
29
26
|
and the solver updates the constrained variables to have values that
|
27
|
+
|
30
28
|
satisfy the constraints.
|
31
|
-
|
29
|
+
|
30
|
+
|
32
31
|
This is a Ruby port of the Smalltalk version of Cassowary. The
|
32
|
+
|
33
33
|
original distribution can be found
|
34
|
+
|
34
35
|
[here](http://www.cs.washington.edu/research/constraints/cassowary/).
|
35
|
-
|
36
|
+
|
37
|
+
|
36
38
|
A technical report is included in the original distribution that
|
39
|
+
|
37
40
|
describes the algorithm, interface, and implementation of the
|
41
|
+
|
38
42
|
Cassowary solver. Additionally, the distribution contains toy sample
|
43
|
+
|
39
44
|
applications written in Smalltalk, C++, Java, and Python, and a more
|
45
|
+
|
40
46
|
complex example Java applet, the "Constraint Drawing Application".
|
41
47
|
|
48
|
+
'
|
42
49
|
email: tim@bithug.org
|
43
50
|
executables: []
|
44
|
-
|
45
51
|
extensions: []
|
46
|
-
|
47
52
|
extra_rdoc_files: []
|
48
|
-
|
49
|
-
files:
|
53
|
+
files:
|
50
54
|
- README.md
|
51
55
|
- LICENSE
|
52
56
|
- lib/linear_expression.rb
|
@@ -73,39 +77,31 @@ files:
|
|
73
77
|
- test/test_abstract_methods.rb
|
74
78
|
- test/test_cassowary.rb
|
75
79
|
homepage: https://github.com/timfel/cassowary-ruby
|
76
|
-
licenses:
|
80
|
+
licenses:
|
77
81
|
- MIT
|
82
|
+
metadata: {}
|
78
83
|
post_install_message:
|
79
84
|
rdoc_options: []
|
80
|
-
|
81
|
-
require_paths:
|
85
|
+
require_paths:
|
82
86
|
- lib
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
hash: 3
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
101
97
|
requirements: []
|
102
|
-
|
103
98
|
rubyforge_project:
|
104
|
-
rubygems_version:
|
99
|
+
rubygems_version: 2.0.a
|
105
100
|
signing_key:
|
106
|
-
specification_version:
|
107
|
-
summary: Cassowary is an incremental constraint solving toolkit that efficiently solves
|
108
|
-
|
101
|
+
specification_version: 4
|
102
|
+
summary: Cassowary is an incremental constraint solving toolkit that efficiently solves
|
103
|
+
systems of linear equalities and inequalities
|
104
|
+
test_files:
|
109
105
|
- test/test_helper.rb
|
110
106
|
- test/test_variables.rb
|
111
107
|
- test/test_ext.rb
|