rubrowser 0.1.5 → 0.1.6
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/d3.rb +1 -1
- data/lib/parser/directory.rb +2 -2
- data/lib/parser/file.rb +2 -0
- data/lib/rubrowser.rb +1 -1
- data/lib/tree.rb +2 -2
- data/readme.md +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89bd09805ec1de06cd644cdeaea90d6476b30198
|
4
|
+
data.tar.gz: aca07615cb33ab42ac46b36e605c5f736df98d56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b93d8dd79f946fa1d6f25e582646b5231ae7ba2d0694a8aa01528e1c35a5c5aae7dd686a1b86907717a6ad3589b2e8caf3dcdd35c03994accee42988a2cee4
|
7
|
+
data.tar.gz: cdb14c5309c34579a627837f57ba0b36198973cc52666f52dba291caa82d73b400cd2a0e8cd76292ee16b13cde701a40948a36bbacdcd028fa96ca8d3ae68504
|
data/Gemfile.lock
CHANGED
data/lib/d3.rb
CHANGED
@@ -24,7 +24,7 @@ module Rubrowser
|
|
24
24
|
|
25
25
|
def node_occurences(node)
|
26
26
|
occurences = []
|
27
|
-
occurences += node.children.map { |n| node_occurences(n) }.reduce(:+)
|
27
|
+
occurences += node.children.map { |n| node_occurences(n) }.reduce([], :+)
|
28
28
|
|
29
29
|
occurences += node.occurences.map { |n| {source: node.id, target: n.id } }.to_a
|
30
30
|
occurences
|
data/lib/parser/directory.rb
CHANGED
@@ -14,11 +14,11 @@ module Rubrowser
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def definitions
|
17
|
-
parsers.map(&:definitions).map(&:to_a).reduce(:+)
|
17
|
+
parsers.map(&:definitions).map(&:to_a).reduce([], :+)
|
18
18
|
end
|
19
19
|
|
20
20
|
def occurences
|
21
|
-
parsers.map(&:occurences).map(&:to_a).reduce(:+)
|
21
|
+
parsers.map(&:occurences).map(&:to_a).reduce([], :+)
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
data/lib/parser/file.rb
CHANGED
data/lib/rubrowser.rb
CHANGED
data/lib/tree.rb
CHANGED
@@ -5,8 +5,8 @@ module Rubrowser
|
|
5
5
|
def self.from_parsers(parsers)
|
6
6
|
return Tree.new if parsers.empty?
|
7
7
|
|
8
|
-
definitions = parsers.map(&:definitions).reduce(:+).uniq
|
9
|
-
occurences = parsers.map(&:occurences).reduce(:+).uniq
|
8
|
+
definitions = parsers.map(&:definitions).reduce([], :+).uniq
|
9
|
+
occurences = parsers.map(&:occurences).reduce([], :+).uniq
|
10
10
|
Tree.new.tap do |tree|
|
11
11
|
definitions.each { |definition| tree.add_child(definition) }
|
12
12
|
occurences.each { |occurence| tree.add_occurence(*occurence.first) }
|
data/readme.md
CHANGED
@@ -10,6 +10,14 @@ this project is so small that the visualization looks like so
|
|
10
10
|
|
11
11
|
the idea is that the project opens every `.rb` file and parse it with `parser` gem then list all modules and classes definitions, and all constants that are listed inside this module/class and link them together, there are couple things you need to keep in mind:
|
12
12
|
|
13
|
+
Here are some output examples
|
14
|
+
|
15
|
+
| Gem | Visualization |
|
16
|
+
| ------------- |:-------------:|
|
17
|
+
| rack-1.6.4/lib |  |
|
18
|
+
| actioncable-5.0.0/lib |  |
|
19
|
+
| railties-5.0.0/lib |  |
|
20
|
+
|
13
21
|
* if your file doesn't have a valid ruby syntax it won't be parsed and will cause the gem to stop
|
14
22
|
* if you reference a class that is not defined in your project it won't be in the graph, we only display the graph of classes/modules you defined
|
15
23
|
* the server analyze your code once upon the script starts if you changed your code you'll have to restart rubrowser
|