mathviz 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/History.txt +11 -0
- data/Manifest.txt +1 -0
- data/README.rdoc +1 -1
- data/examples/E_mc2.png +0 -0
- data/examples/tax.rb +78 -0
- data/lib/mathviz.rb +176 -112
- data/spec/operation_spec.rb +6 -2
- data/spec/spec_helper.rb +2 -2
- data/tasks/idocs.rake +7 -2
- metadata +83 -76
data/.gemtest
ADDED
File without changes
|
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 1.1.0 2012-05-03
|
2
|
+
|
3
|
+
* Streamlined syntax for unit/operation extension
|
4
|
+
* Replace MathViz::Unit#binop with MathViz::Unit#binary_operator, or use the new shorthand syntax MathViz#binop
|
5
|
+
* When/Given/Then comment methods can set up default-to-input mode
|
6
|
+
* Collpase anonymous nodes with the same operation
|
7
|
+
* Print output filename
|
8
|
+
* Collapsed most of Binary/Unary into n-ary Operation
|
9
|
+
* Namespaced modules for extensions to core classes
|
10
|
+
* Tax example
|
11
|
+
|
1
12
|
=== 1.0.2 2010-09-04
|
2
13
|
|
3
14
|
* Set variable names as strings intead of symbols
|
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
@@ -10,7 +10,7 @@ Turn simple equations (a = b * c) into GraphViz dot files showing relationships,
|
|
10
10
|
|
11
11
|
== FEATURES/PROBLEMS:
|
12
12
|
|
13
|
-
* Adds one method to Object and several to Numeric (
|
13
|
+
* Adds one method to Object (by way of Graphable) and several to Numeric (by way Measurable, Unit, and NumericExtensions) If you use units of measure, each unit will appear on Numeric via module Unit.
|
14
14
|
* MathViz produces textual .dot files. You will need a viewer which supports dot files directly, or Graphviz to convert them to images yourself.
|
15
15
|
|
16
16
|
== SYNOPSIS:
|
data/examples/E_mc2.png
CHANGED
Binary file
|
data/examples/tax.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'mathviz'
|
2
|
+
|
3
|
+
class Numeric
|
4
|
+
def between(range)
|
5
|
+
[[self.to_f, range.max].min - range.min, 0].max
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class Range
|
10
|
+
include MathViz::Measurable
|
11
|
+
end
|
12
|
+
|
13
|
+
MathViz.new {
|
14
|
+
new_units :usd
|
15
|
+
binop :between
|
16
|
+
|
17
|
+
def pos(n)
|
18
|
+
n.max(0.usd)
|
19
|
+
end
|
20
|
+
|
21
|
+
When "I earn"
|
22
|
+
income = 39_527.usd
|
23
|
+
|
24
|
+
And "spend"
|
25
|
+
medical = 6_153.usd
|
26
|
+
contributions = 2_189.usd
|
27
|
+
property_tax = 3_830.usd
|
28
|
+
interest_paid = 9_055.usd
|
29
|
+
us_tax_paid = 7000.usd
|
30
|
+
il_tax_paid = 1800.usd
|
31
|
+
|
32
|
+
Given "IL tax rates (2012)"
|
33
|
+
il = const 0.05
|
34
|
+
il_deduction = 2000.usd
|
35
|
+
|
36
|
+
Then "IL tax"
|
37
|
+
il_deductions = (il_deduction + property_tax)
|
38
|
+
|
39
|
+
il_taxable = pos(income - il_deductions)
|
40
|
+
il_tax = il_taxable * il
|
41
|
+
il_tax_due = il_tax - il_tax_paid
|
42
|
+
|
43
|
+
Given "US tax rates (2012)"
|
44
|
+
ss = const 0.104
|
45
|
+
medicare = const 0.029
|
46
|
+
tax_brackets = {
|
47
|
+
0.10 => (0..8_700).usd,
|
48
|
+
0.15 => (8_700..35_350).usd,
|
49
|
+
0.25 => (35_350..85_650).usd,
|
50
|
+
0.28 => (85_650..178_650).usd,
|
51
|
+
0.33 => (178_650..388_350).usd,
|
52
|
+
}
|
53
|
+
standard_deduction = 5_950.usd
|
54
|
+
exception = 3_800.usd
|
55
|
+
|
56
|
+
Then "US tax"
|
57
|
+
ss_tax = income * ss
|
58
|
+
medicare_tax = income * medicare
|
59
|
+
welfare_tax = ss_tax + medicare_tax
|
60
|
+
|
61
|
+
itemized_deduction = property_tax + il_tax_paid + interest_paid + contributions
|
62
|
+
deduction = itemized_deduction.max(standard_deduction)
|
63
|
+
us_deductions = deduction + exception
|
64
|
+
us_taxable = pos(income - ss_tax/2 - medical - us_deductions)
|
65
|
+
|
66
|
+
# this removes some noise from the graph
|
67
|
+
applicable_brackets = tax_brackets.select do |rate, bracket|
|
68
|
+
bracket.to_value.min <= us_taxable.to_value
|
69
|
+
end
|
70
|
+
us_income_tax = applicable_brackets.map do |rate, bracket|
|
71
|
+
us_taxable.between(bracket) * rate
|
72
|
+
end.reduce(&:+)
|
73
|
+
|
74
|
+
us_tax = us_income_tax + welfare_tax
|
75
|
+
us_tax_due = us_tax - us_tax_paid
|
76
|
+
|
77
|
+
binding
|
78
|
+
}.dot
|
data/lib/mathviz.rb
CHANGED
@@ -3,7 +3,7 @@ require 'graphviz_r'
|
|
3
3
|
# Top level object.
|
4
4
|
class MathViz
|
5
5
|
# RubyGem version
|
6
|
-
VERSION = '1.0
|
6
|
+
VERSION = '1.1.0'
|
7
7
|
|
8
8
|
# Something to return instead of dividing by zero, etc.
|
9
9
|
Infinity = 1.0/0
|
@@ -30,18 +30,68 @@ class MathViz
|
|
30
30
|
MathViz::Input.new(x)
|
31
31
|
end
|
32
32
|
|
33
|
+
# Define new units (instance methods) on module MathViz::Units (where they will be picked up by everything including the module)
|
34
|
+
# Defined methods are essentialy aliases for #unit(name); see MathViz::Measurable / MathViz::Measured
|
35
|
+
def new_units(*units)
|
36
|
+
MathViz::Units.new_units(*units)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Define op as a binary operator
|
40
|
+
def binop(op)
|
41
|
+
MathViz::Term.binop op
|
42
|
+
MathViz::Unit.binop op
|
43
|
+
end
|
44
|
+
|
45
|
+
# Define op as unary operator
|
46
|
+
def unop(op)
|
47
|
+
MathViz::Term.unop op
|
48
|
+
end
|
49
|
+
|
33
50
|
# Save a Graphviz .dot file in the current directory, with name specified in the constructor. Triggers most of the actual processsing.
|
34
51
|
def dot
|
35
52
|
MathViz::Term.name_terms!(@env)
|
36
53
|
#puts MathViz::Term.list_terms(@env).map {|t| t.long}
|
37
54
|
graph = GraphvizR.new @name
|
38
|
-
|
39
|
-
t.to_dot(
|
40
|
-
g
|
55
|
+
MathViz::Term.list_terms(@env).flat_map(&:collapse).each {|t|
|
56
|
+
t.to_dot(graph)
|
41
57
|
}
|
42
58
|
|
43
|
-
|
44
|
-
graph.output(
|
59
|
+
filename = @name + '.dot'
|
60
|
+
graph.output(filename, 'dot')
|
61
|
+
puts "Wrote #{filename}"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Comment that identifies a set of inputs. Subsequent measured values will be marked as #input
|
65
|
+
def When(desc)
|
66
|
+
@@default_term = Input
|
67
|
+
end
|
68
|
+
|
69
|
+
# Comment that identifies a set of constants. Subsequent measured values will be marked as #const
|
70
|
+
def Given(desc)
|
71
|
+
@@default_term = Constant
|
72
|
+
end
|
73
|
+
|
74
|
+
# Comment that identifies a section of calculations on the inputs and constants.
|
75
|
+
def Then(desc)
|
76
|
+
@@default_term = Constant
|
77
|
+
end
|
78
|
+
|
79
|
+
# Comment which reads a little better than repetition.
|
80
|
+
def And(desc)
|
81
|
+
end
|
82
|
+
|
83
|
+
# internal method
|
84
|
+
def self.default_term
|
85
|
+
@@default_term ||= Constant
|
86
|
+
end
|
87
|
+
|
88
|
+
# Turn the object into a MathViz::Term (MathViz::Constant) if isn't already a MathViz::Term. This allows for operator parameters to be primitive values without needing MathViz#const, MathViz#input, or units.
|
89
|
+
def self.term(x)
|
90
|
+
if (x.kind_of?(MathViz::Term))
|
91
|
+
x
|
92
|
+
else
|
93
|
+
MathViz::Constant.new(x)
|
94
|
+
end
|
45
95
|
end
|
46
96
|
end
|
47
97
|
|
@@ -66,7 +116,7 @@ class MathViz::Unit
|
|
66
116
|
end
|
67
117
|
|
68
118
|
# Implement a simple binary operation. It verifies that the units match and returns the unit ERROR if not.
|
69
|
-
def
|
119
|
+
def binary_operator(other)
|
70
120
|
if (unit != other.unit)
|
71
121
|
#p "#{to_s} !+- #{other.to_s}"
|
72
122
|
return MathViz::Unit.new(:ERROR)
|
@@ -74,15 +124,19 @@ class MathViz::Unit
|
|
74
124
|
return self
|
75
125
|
end
|
76
126
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
alias_method
|
82
|
-
alias_method
|
83
|
-
alias_method
|
84
|
-
alias_method
|
85
|
-
alias_method
|
127
|
+
def self.binop(other)
|
128
|
+
alias_method other, :binary_operator
|
129
|
+
end
|
130
|
+
|
131
|
+
alias_method :+, :binary_operator
|
132
|
+
alias_method :-, :binary_operator
|
133
|
+
alias_method :<, :binary_operator
|
134
|
+
alias_method :>, :binary_operator
|
135
|
+
alias_method :==, :binary_operator
|
136
|
+
alias_method :max, :binary_operator
|
137
|
+
alias_method :min, :binary_operator
|
138
|
+
alias_method :&, :binary_operator
|
139
|
+
alias_method :|, :binary_operator
|
86
140
|
|
87
141
|
def *(other)
|
88
142
|
x = @unit.dup
|
@@ -120,7 +174,7 @@ class MathViz::Unit
|
|
120
174
|
|
121
175
|
# Produce a string of multiplied terms
|
122
176
|
def stream(units)
|
123
|
-
x = units.
|
177
|
+
x = units.flat_map {|u,power| [u] * power.abs }.join('*')
|
124
178
|
if (x.empty?)
|
125
179
|
return nil
|
126
180
|
else
|
@@ -164,14 +218,23 @@ end
|
|
164
218
|
module MathViz::Measurable
|
165
219
|
include MathViz::Units
|
166
220
|
|
167
|
-
# return
|
221
|
+
# return term wrapping self with the specified units; see also MathViz::Units::Class#new_units
|
168
222
|
def unit(x)
|
169
|
-
MathViz
|
223
|
+
MathViz.default_term.new(self).unit(x)
|
170
224
|
end
|
171
225
|
|
172
|
-
# return
|
226
|
+
# return term wrapping self with new units assigned to the denominator
|
173
227
|
def per
|
174
|
-
MathViz
|
228
|
+
MathViz.default_term.new(self).per
|
229
|
+
end
|
230
|
+
|
231
|
+
# api method for unwrapping terms
|
232
|
+
def to_value
|
233
|
+
if kind_of? Numeric
|
234
|
+
to_f
|
235
|
+
else
|
236
|
+
self
|
237
|
+
end
|
175
238
|
end
|
176
239
|
end
|
177
240
|
|
@@ -212,11 +275,15 @@ module MathViz::Measured
|
|
212
275
|
def units
|
213
276
|
@unit || MathViz::Unit.new
|
214
277
|
end
|
215
|
-
end
|
216
278
|
|
217
|
-
|
218
|
-
|
279
|
+
# api method for unwrapping terms
|
280
|
+
def to_value
|
281
|
+
to_f
|
282
|
+
end
|
283
|
+
end
|
219
284
|
|
285
|
+
# Namespaced extensions
|
286
|
+
module MathViz::NumericOperations
|
220
287
|
# Provide in operator form
|
221
288
|
def max(b)
|
222
289
|
[self, b].max
|
@@ -233,13 +300,23 @@ class Numeric
|
|
233
300
|
end
|
234
301
|
end
|
235
302
|
|
236
|
-
class
|
237
|
-
|
303
|
+
class Numeric
|
304
|
+
include MathViz::Measurable
|
305
|
+
include MathViz::NumericOperations
|
306
|
+
end
|
307
|
+
|
308
|
+
# Namespaced extensions
|
309
|
+
module MathViz::Graphable
|
310
|
+
# graph node title
|
238
311
|
def node
|
239
312
|
to_s
|
240
313
|
end
|
241
314
|
end
|
242
315
|
|
316
|
+
class Object
|
317
|
+
include MathViz::Graphable
|
318
|
+
end
|
319
|
+
|
243
320
|
# Base class for graphable objects. It also contain the operators, which return MathViz::Operation subclasses.
|
244
321
|
class MathViz::Term
|
245
322
|
include MathViz::Measured
|
@@ -269,14 +346,14 @@ class MathViz::Term
|
|
269
346
|
# Define op as a binary operator
|
270
347
|
def self.binop(op)
|
271
348
|
define_method(op) do |c|
|
272
|
-
MathViz::Operation
|
349
|
+
MathViz::Operation.new(op, self, c)
|
273
350
|
end
|
274
351
|
end
|
275
352
|
|
276
353
|
# Define op as an unary operator
|
277
354
|
def self.unop(op)
|
278
355
|
define_method(op) do
|
279
|
-
MathViz::Operation::Unary.new(
|
356
|
+
MathViz::Operation::Unary.new(op, self)
|
280
357
|
end
|
281
358
|
end
|
282
359
|
|
@@ -289,7 +366,7 @@ class MathViz::Term
|
|
289
366
|
|
290
367
|
# A string representation of the node's data, typically calculated value with units.
|
291
368
|
def data
|
292
|
-
f =
|
369
|
+
f = to_value
|
293
370
|
if (f.kind_of?(TrueClass) || f.kind_of?(FalseClass))
|
294
371
|
f.to_s
|
295
372
|
elsif (!f.respond_to? :finite?)
|
@@ -304,7 +381,7 @@ class MathViz::Term
|
|
304
381
|
end
|
305
382
|
|
306
383
|
def to_i
|
307
|
-
f =
|
384
|
+
f = to_value
|
308
385
|
return MathViz::Infinity unless f.finite?
|
309
386
|
f.to_i
|
310
387
|
end
|
@@ -344,6 +421,21 @@ class MathViz::Term
|
|
344
421
|
g[node] [:label => label, :shape => shape, :color => color, :style => style]
|
345
422
|
end
|
346
423
|
|
424
|
+
# Helper to avoid duplicate nodes
|
425
|
+
def generated?
|
426
|
+
!name.nil?
|
427
|
+
end
|
428
|
+
|
429
|
+
# Only valid after names have been assigned, which means not during graph construction
|
430
|
+
def anonymous?
|
431
|
+
!@name
|
432
|
+
end
|
433
|
+
|
434
|
+
# Stub
|
435
|
+
def collapse(parentop = nil)
|
436
|
+
[self]
|
437
|
+
end
|
438
|
+
|
347
439
|
private
|
348
440
|
@@anon_master = 'A'
|
349
441
|
|
@@ -359,10 +451,6 @@ class MathViz::Term
|
|
359
451
|
end
|
360
452
|
end
|
361
453
|
|
362
|
-
def anonymous?
|
363
|
-
!@name
|
364
|
-
end
|
365
|
-
|
366
454
|
public
|
367
455
|
|
368
456
|
##
|
@@ -425,12 +513,12 @@ class MathViz::Constant < MathViz::Term
|
|
425
513
|
# Debugging method; string with both name and value
|
426
514
|
def long
|
427
515
|
n = @name && (@name + " = ")
|
428
|
-
"(#{n}#{
|
516
|
+
"(#{n}#{to_value})"
|
429
517
|
end
|
430
518
|
|
431
519
|
# Forward to contained object
|
432
|
-
def
|
433
|
-
@a.
|
520
|
+
def to_value
|
521
|
+
@a.to_value
|
434
522
|
end
|
435
523
|
|
436
524
|
# Returns the units of the contained object (if any) or else it's own.
|
@@ -453,7 +541,7 @@ class MathViz::Constant < MathViz::Term
|
|
453
541
|
|
454
542
|
# Forward to contained object
|
455
543
|
def finite?
|
456
|
-
@a.finite?
|
544
|
+
@a.respond_to?(:finite?) ? @a.finite? : true
|
457
545
|
end
|
458
546
|
end
|
459
547
|
|
@@ -472,79 +560,18 @@ class MathViz::Input < MathViz::Constant
|
|
472
560
|
end
|
473
561
|
end
|
474
562
|
|
475
|
-
#
|
563
|
+
# n-ary operators
|
476
564
|
class MathViz::Operation < MathViz::Term
|
477
|
-
|
478
|
-
def term(x)
|
479
|
-
if (x.kind_of?(MathViz::Term))
|
480
|
-
x
|
481
|
-
else
|
482
|
-
MathViz::Constant.new(x)
|
483
|
-
end
|
484
|
-
end
|
485
|
-
|
486
|
-
# Graphviz node shape
|
487
|
-
def shape
|
488
|
-
:box
|
489
|
-
end
|
490
|
-
|
491
|
-
# Default Graphviz node color.
|
492
|
-
def color
|
493
|
-
:red
|
494
|
-
end
|
495
|
-
end
|
496
|
-
|
497
|
-
# Display and processing for single-value operators
|
498
|
-
class MathViz::Operation::Unary < MathViz::Operation
|
499
|
-
def initialize(a, op)
|
500
|
-
super()
|
501
|
-
@a = term(a)
|
502
|
-
@op = op
|
503
|
-
end
|
504
|
-
|
505
|
-
# Debugging method; return string of name and value.
|
506
|
-
def long
|
507
|
-
n = @name && (@name + " = ")
|
508
|
-
"(#{n}#{@a} #{@op} = #{to_f})"
|
509
|
-
end
|
510
|
-
|
511
|
-
# Extend Graphviz g with a representation of this object, and incoming connections
|
512
|
-
def to_dot(g)
|
513
|
-
super
|
514
|
-
(g[@a.node] >> g[node]) [:arrowhead => :normal, :headlabel => @op.to_s, :labeldistance => '2']
|
515
|
-
@a.to_dot(g) if (@a.respond_to?(:name) && @a.name.nil?)
|
516
|
-
end
|
517
|
-
|
518
|
-
# Apply the operator to create the derived value.
|
519
|
-
def to_f
|
520
|
-
return MathViz::Infinity unless @a.to_f.finite?
|
521
|
-
@a.to_f.__send__(@op)
|
522
|
-
end
|
523
|
-
|
524
|
-
# Forward to contained value
|
525
|
-
def units
|
526
|
-
@a.units
|
527
|
-
end
|
528
|
-
|
529
|
-
# Forward to contained value
|
530
|
-
def constant?
|
531
|
-
@a.constant?
|
532
|
-
end
|
533
|
-
end
|
534
|
-
|
535
|
-
# Display and processing for two-value operators
|
536
|
-
class MathViz::Operation::Binary < MathViz::Operation
|
537
|
-
def initialize(a, op, b)
|
565
|
+
def initialize(op, *operands)
|
538
566
|
super()
|
539
|
-
@a = term(a)
|
540
567
|
@op = op
|
541
|
-
@
|
568
|
+
@operands = operands.map{|x| MathViz.term(x)}
|
542
569
|
end
|
543
570
|
|
544
571
|
# Debugging method; returns string of names and values
|
545
572
|
def long
|
546
573
|
n = @name && (@name + " = ")
|
547
|
-
"(#{n}#{@
|
574
|
+
"(#{n}#{@op} #{@operands.join(',')} = #{to_value})"
|
548
575
|
end
|
549
576
|
|
550
577
|
# Graphviz node shape; differentiates comparison operators
|
@@ -567,27 +594,64 @@ class MathViz::Operation::Binary < MathViz::Operation
|
|
567
594
|
end
|
568
595
|
end
|
569
596
|
|
597
|
+
# Draws edges, and ensure the from nodes is drawn
|
598
|
+
def link_from(g, other, style, label)
|
599
|
+
if label
|
600
|
+
(g[other.to_s] >> g[node]) [:arrowhead => style, :headlabel => @op.to_s, :labeldistance => '2']
|
601
|
+
else
|
602
|
+
(g[other.to_s] >> g[node]) [:arrowhead => style]
|
603
|
+
end
|
604
|
+
other.to_dot(g) unless other.generated?
|
605
|
+
end
|
606
|
+
|
570
607
|
# Extend Graphviz g with a representation of this object, and incoming connections
|
571
608
|
def to_dot(g)
|
572
609
|
super
|
573
|
-
(g
|
574
|
-
|
575
|
-
@a.to_dot(g) if (@a.respond_to?(:name) && @a.name.nil?)
|
576
|
-
@b.to_dot(g) if (@b.respond_to?(:name) && @b.name.nil?)
|
610
|
+
link_from(g, @operands.first, :normal, false)
|
611
|
+
@operands.slice(1..-1).each {|x| link_from(g, x, :onormal, true)}
|
577
612
|
end
|
578
613
|
|
579
614
|
# Apply the operator to create the derived value.
|
580
|
-
def
|
581
|
-
|
615
|
+
def to_value
|
616
|
+
return MathViz::Infinity unless finite?
|
617
|
+
@operands.map(&:to_value).reduce(&@op)
|
582
618
|
end
|
583
619
|
|
584
620
|
# Apply the operator to create the derived units.
|
585
621
|
def units
|
586
|
-
@
|
622
|
+
@operands.map(&:units).reduce(&@op)
|
587
623
|
end
|
588
624
|
|
589
|
-
# True only if both operands are #constant?
|
590
625
|
def constant?
|
591
|
-
@
|
626
|
+
@operands.all?(&:constant?)
|
627
|
+
end
|
628
|
+
|
629
|
+
def finite?
|
630
|
+
@operands.all?(&:finite?)
|
631
|
+
end
|
632
|
+
|
633
|
+
# Combine anonymous nodes with the same operator to simply graph
|
634
|
+
def collapse(parentop = nil)
|
635
|
+
@operands = @operands.flat_map {|x| x.collapse(@op)}
|
636
|
+
if anonymous? && parentop == @op
|
637
|
+
@operands
|
638
|
+
else
|
639
|
+
[self]
|
640
|
+
end
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
# Special cases for unary operators
|
645
|
+
class MathViz::Operation::Unary < MathViz::Operation
|
646
|
+
# Apply the operator to create the derived value.
|
647
|
+
def to_value
|
648
|
+
return MathViz::Infinity unless finite?
|
649
|
+
@operands.map(&:to_value).map(&@op).first
|
650
|
+
end
|
651
|
+
|
652
|
+
# Extend Graphviz g with a representation of this object, and incoming connections
|
653
|
+
def to_dot(g)
|
654
|
+
super
|
655
|
+
@operands.each {|x| link_from(g, x, :normal, true)}
|
592
656
|
end
|
593
657
|
end
|
data/spec/operation_spec.rb
CHANGED
@@ -5,7 +5,11 @@ module MathViz::Units
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe MathViz::Operation do
|
8
|
-
describe
|
8
|
+
describe 'unary' do
|
9
|
+
it "does something" do
|
10
|
+
(MathViz::Constant.new(0.5).floor).data.should == "0"
|
11
|
+
end
|
12
|
+
|
9
13
|
it "can floor infinity" do
|
10
14
|
(MathViz::Constant.new(1.0/0).floor).data.should == "Infinity"
|
11
15
|
end
|
@@ -15,7 +19,7 @@ describe MathViz::Operation do
|
|
15
19
|
end
|
16
20
|
end
|
17
21
|
|
18
|
-
describe
|
22
|
+
describe 'binary' do
|
19
23
|
it "reports ints as ints" do
|
20
24
|
(MathViz::Constant.new(1) * 2).data.should == "2"
|
21
25
|
end
|
data/spec/spec_helper.rb
CHANGED
data/tasks/idocs.rake
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
task :idocs => [:redocs, 'README.rdoc', 'examples/E_mc2.png'] do |t|
|
2
|
-
mkdir 'doc/examples'
|
1
|
+
task :idocs => [:redocs, 'README.rdoc', 'examples/E_mc2.png', 'doc/examples'] do |t|
|
3
2
|
cp 'examples/E_mc2.png', 'doc/examples/'
|
4
3
|
end
|
4
|
+
|
5
|
+
directory 'doc/examples'
|
6
|
+
|
7
|
+
task :redocs => [:clobber_docs] do |t|
|
8
|
+
sh 'rdoc lib README.rdoc'
|
9
|
+
end
|
metadata
CHANGED
@@ -1,79 +1,91 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathviz
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 1
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
version: 1.0.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Justin Love
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-05-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: GraphvizR
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 5
|
31
|
-
- 1
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
32
21
|
version: 0.5.1
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rubyforge
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.5.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rdoc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
39
33
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
- 2
|
45
|
-
- 0
|
46
|
-
- 4
|
47
|
-
version: 2.0.4
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.10'
|
48
38
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: hoe
|
52
39
|
prerelease: false
|
53
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.10'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: newgem
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
54
49
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
- 2
|
60
|
-
- 6
|
61
|
-
- 2
|
62
|
-
version: 2.6.2
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.5.3
|
63
54
|
type: :development
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.5.3
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: hoe
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '3.0'
|
78
|
+
description: Turn simple equations (a = b * c) into GraphViz dot files showing relationships,
|
79
|
+
values, and units.
|
80
|
+
email:
|
67
81
|
- git@JustinLove.name
|
68
82
|
executables: []
|
69
|
-
|
70
83
|
extensions: []
|
71
|
-
|
72
|
-
extra_rdoc_files:
|
84
|
+
extra_rdoc_files:
|
73
85
|
- History.txt
|
74
86
|
- Manifest.txt
|
75
87
|
- README.rdoc
|
76
|
-
files:
|
88
|
+
files:
|
77
89
|
- History.txt
|
78
90
|
- Manifest.txt
|
79
91
|
- README.rdoc
|
@@ -82,6 +94,7 @@ files:
|
|
82
94
|
- examples/E_mc2.rb
|
83
95
|
- examples/dc.rb
|
84
96
|
- examples/first.rb
|
97
|
+
- examples/tax.rb
|
85
98
|
- lib/mathviz.rb
|
86
99
|
- spec/measurable_spec.rb
|
87
100
|
- spec/measured_spec.rb
|
@@ -89,38 +102,32 @@ files:
|
|
89
102
|
- spec/spec_helper.rb
|
90
103
|
- spec/unit_spec.rb
|
91
104
|
- tasks/idocs.rake
|
92
|
-
|
105
|
+
- .gemtest
|
93
106
|
homepage: http://github.com/JustinLove/mathviz
|
94
107
|
licenses: []
|
95
|
-
|
96
108
|
post_install_message:
|
97
|
-
rdoc_options:
|
109
|
+
rdoc_options:
|
98
110
|
- --main
|
99
111
|
- README.rdoc
|
100
|
-
require_paths:
|
112
|
+
require_paths:
|
101
113
|
- lib
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
115
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
|
109
|
-
version: "0"
|
110
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
121
|
none: false
|
112
|
-
requirements:
|
113
|
-
- -
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
|
116
|
-
- 0
|
117
|
-
version: "0"
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
118
126
|
requirements: []
|
119
|
-
|
120
127
|
rubyforge_project: mathviz
|
121
|
-
rubygems_version: 1.
|
128
|
+
rubygems_version: 1.8.24
|
122
129
|
signing_key:
|
123
130
|
specification_version: 3
|
124
|
-
summary: Turn simple equations (a = b * c) into GraphViz dot files showing relationships,
|
131
|
+
summary: Turn simple equations (a = b * c) into GraphViz dot files showing relationships,
|
132
|
+
values, and units.
|
125
133
|
test_files: []
|
126
|
-
|