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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: badb6ddb134dfb84c78ca1f1fccf87adca07323e
4
- data.tar.gz: 876d60b83c0df6d6edaee25064b141cb9ff05929
3
+ metadata.gz: 89bd09805ec1de06cd644cdeaea90d6476b30198
4
+ data.tar.gz: aca07615cb33ab42ac46b36e605c5f736df98d56
5
5
  SHA512:
6
- metadata.gz: 6a178d00941b0ebb744f0c999cf5ca0f530c3e5f27b2c052279dc6e0bc4296c54d6d78200438ad0f5e7cee4b34fc3d6a8760e0c8bb4feab356195a87f25e5287
7
- data.tar.gz: 8c2b27697a86960346f7e8c1edf04763166ddd02625a46974bb2862a6aba857c58e8d269f5f6a2f3a2c7bee7344079c7d59b0c69aad039857662f017147b3eff
6
+ metadata.gz: b4b93d8dd79f946fa1d6f25e582646b5231ae7ba2d0694a8aa01528e1c35a5c5aae7dd686a1b86907717a6ad3589b2e8caf3dcdd35c03994accee42988a2cee4
7
+ data.tar.gz: cdb14c5309c34579a627837f57ba0b36198973cc52666f52dba291caa82d73b400cd2a0e8cd76292ee16b13cde701a40948a36bbacdcd028fa96ca8d3ae68504
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubrowser (0.1.5)
4
+ rubrowser (0.1.6)
5
5
  parser (~> 2.3, >= 2.3.0)
6
6
 
7
7
  GEM
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(:+).to_a
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
@@ -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
@@ -23,6 +23,8 @@ module Rubrowser
23
23
  @occurences = constants[:occurences].uniq
24
24
  end
25
25
  end
26
+ rescue ::Parser::SyntaxError
27
+ warn "SyntaxError in #{file}"
26
28
  end
27
29
 
28
30
  def file_valid?(file)
data/lib/rubrowser.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rubrowser
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
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 | ![rake](http://i.imgur.com/4UsCo0a.png) |
18
+ | actioncable-5.0.0/lib | ![acioncable](http://i.imgur.com/Q0Xqjsz.png) |
19
+ | railties-5.0.0/lib | ![railties](http://i.imgur.com/31g10a1.png) |
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubrowser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emad Elsaid