mathviz 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +0 -1
- data/README.rdoc +0 -1
- data/examples/E_mc2.png +0 -0
- data/examples/E_mc2.rb +0 -1
- data/examples/dc.rb +0 -1
- data/examples/first.rb +1 -2
- data/lib/mathviz.rb +9 -10
- data/spec/measurable_spec.rb +1 -1
- data/spec/measured_spec.rb +1 -1
- data/spec/operation_spec.rb +1 -1
- data/spec/unit_spec.rb +1 -1
- metadata +48 -15
- data/examples/mathviz.rb +0 -1
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.rdoc
CHANGED
data/examples/E_mc2.png
CHANGED
Binary file
|
data/examples/E_mc2.rb
CHANGED
data/examples/dc.rb
CHANGED
data/examples/first.rb
CHANGED
data/lib/mathviz.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'graphviz_r'
|
3
2
|
|
4
3
|
# Top level object.
|
5
4
|
class MathViz
|
6
5
|
# RubyGem version
|
7
|
-
VERSION = '1.0.
|
6
|
+
VERSION = '1.0.1'
|
8
7
|
|
9
8
|
# Something to return instead of dividing by zero, etc.
|
10
9
|
Infinity = 1.0/0
|
@@ -60,7 +59,7 @@ class MathViz::Unit
|
|
60
59
|
@unit = Hash.new(0)
|
61
60
|
case h
|
62
61
|
when Hash; @unit.merge!(h); normalize!
|
63
|
-
when Symbol
|
62
|
+
when Symbol; @unit[h] = 1
|
64
63
|
end
|
65
64
|
@unit.freeze
|
66
65
|
freeze
|
@@ -248,7 +247,7 @@ class MathViz::Term
|
|
248
247
|
# Assign names to named MathViz::Terms, so the name can be effiently looked up from the MathViz::Term object.
|
249
248
|
def self.name_terms!(env)
|
250
249
|
eval("local_variables", env).each do |var|
|
251
|
-
value = eval(var, env)
|
250
|
+
value = eval(var.to_s, env)
|
252
251
|
if value.respond_to? :name=
|
253
252
|
value.name = var
|
254
253
|
end
|
@@ -258,7 +257,7 @@ class MathViz::Term
|
|
258
257
|
# Return a list of all MathViz::Terms accessible from a binding
|
259
258
|
def self.list_terms(env)
|
260
259
|
eval("local_variables", env).map { |var|
|
261
|
-
value = eval(var, env)
|
260
|
+
value = eval(var.to_s, env)
|
262
261
|
if (value.kind_of?(MathViz::Term))
|
263
262
|
value
|
264
263
|
else
|
@@ -560,11 +559,11 @@ class MathViz::Operation::Binary < MathViz::Operation
|
|
560
559
|
# Graphviz node color; differentiates basic mathematical operators (+, -, *, /)
|
561
560
|
def color
|
562
561
|
case @op
|
563
|
-
when
|
564
|
-
when
|
565
|
-
when
|
566
|
-
when
|
567
|
-
else
|
562
|
+
when :+; :green;
|
563
|
+
when :-; :yellow;
|
564
|
+
when :*; :blue;
|
565
|
+
when :/; :cyan;
|
566
|
+
else :red;
|
568
567
|
end
|
569
568
|
end
|
570
569
|
|
data/spec/measurable_spec.rb
CHANGED
data/spec/measured_spec.rb
CHANGED
data/spec/operation_spec.rb
CHANGED
data/spec/unit_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mathviz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 1.0.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Justin Love
|
@@ -9,29 +14,54 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-09-04 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: GraphvizR
|
17
|
-
|
18
|
-
|
19
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
20
25
|
requirements:
|
21
26
|
- - ">="
|
22
27
|
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 5
|
31
|
+
- 1
|
23
32
|
version: 0.5.1
|
24
|
-
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
36
|
+
name: rubyforge
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 2
|
45
|
+
- 0
|
46
|
+
- 4
|
47
|
+
version: 2.0.4
|
27
48
|
type: :development
|
28
|
-
|
29
|
-
|
49
|
+
version_requirements: *id002
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: hoe
|
52
|
+
prerelease: false
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
30
55
|
requirements:
|
31
56
|
- - ">="
|
32
57
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
58
|
+
segments:
|
59
|
+
- 2
|
60
|
+
- 6
|
61
|
+
- 2
|
62
|
+
version: 2.6.2
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
35
65
|
description: Turn simple equations (a = b * c) into GraphViz dot files showing relationships, values, and units.
|
36
66
|
email:
|
37
67
|
- git@JustinLove.name
|
@@ -52,7 +82,6 @@ files:
|
|
52
82
|
- examples/E_mc2.rb
|
53
83
|
- examples/dc.rb
|
54
84
|
- examples/first.rb
|
55
|
-
- examples/mathviz.rb
|
56
85
|
- lib/mathviz.rb
|
57
86
|
- spec/measurable_spec.rb
|
58
87
|
- spec/measured_spec.rb
|
@@ -71,21 +100,25 @@ rdoc_options:
|
|
71
100
|
require_paths:
|
72
101
|
- lib
|
73
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
74
104
|
requirements:
|
75
105
|
- - ">="
|
76
106
|
- !ruby/object:Gem::Version
|
107
|
+
segments:
|
108
|
+
- 0
|
77
109
|
version: "0"
|
78
|
-
version:
|
79
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
80
112
|
requirements:
|
81
113
|
- - ">="
|
82
114
|
- !ruby/object:Gem::Version
|
115
|
+
segments:
|
116
|
+
- 0
|
83
117
|
version: "0"
|
84
|
-
version:
|
85
118
|
requirements: []
|
86
119
|
|
87
120
|
rubyforge_project: mathviz
|
88
|
-
rubygems_version: 1.3.
|
121
|
+
rubygems_version: 1.3.7
|
89
122
|
signing_key:
|
90
123
|
specification_version: 3
|
91
124
|
summary: Turn simple equations (a = b * c) into GraphViz dot files showing relationships, values, and units.
|
data/examples/mathviz.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'mathviz')
|