rubrowser 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -7
- data/lib/parser/directory.rb +6 -21
- data/lib/parser/file.rb +9 -14
- data/lib/rubrowser.rb +1 -1
- data/lib/server.rb +7 -11
- data/rubrowser.gemspec +0 -2
- data/views/index.erb +16 -0
- metadata +2 -42
- data/views/index.haml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0be17d7b269962a4124e4c71d0960ee14612f32d
|
4
|
+
data.tar.gz: 8b24607f58b580bae77e5e9d39b0fe71ab6fd2cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4eef0ad580d87429db8b111dedca2a9e7258e094adf0694f9243a3ec2e7b323c4f47cf21458f300cbaaf594dc849eb6ab1c4f9b6d2b3f4c130d8a7b8815a83a
|
7
|
+
data.tar.gz: 5849d5b884678343377d5c670f0055bdbd42865a637f983da412a39ef9e6b4d4b06b628be8690fc4f4c1de5090b80a60ebdcbf53d3d0059f4bdea9fa822e988c
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rubrowser (0.1.
|
5
|
-
haml (~> 4.0, >= 4.0.0)
|
6
|
-
parallel (~> 1.9, >= 1.9.0)
|
4
|
+
rubrowser (0.1.4)
|
7
5
|
parser (~> 2.3, >= 2.3.0)
|
8
6
|
|
9
7
|
GEM
|
10
8
|
remote: https://rubygems.org/
|
11
9
|
specs:
|
12
10
|
ast (2.3.0)
|
13
|
-
haml (4.0.7)
|
14
|
-
tilt
|
15
|
-
parallel (1.9.0)
|
16
11
|
parser (2.3.1.2)
|
17
12
|
ast (~> 2.2)
|
18
|
-
tilt (2.0.5)
|
19
13
|
|
20
14
|
PLATFORMS
|
21
15
|
ruby
|
data/lib/parser/directory.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'parser/factory'
|
2
|
-
require 'parallel'
|
3
|
-
|
4
1
|
module Rubrowser
|
5
2
|
module Parser
|
6
3
|
class Directory
|
@@ -8,37 +5,25 @@ module Rubrowser
|
|
8
5
|
|
9
6
|
def initialize(directory)
|
10
7
|
@directory = directory
|
11
|
-
|
12
|
-
|
8
|
+
files = Dir.glob(::File.join(directory, '**', '*.rb'))
|
9
|
+
@parsers = files.map { |f| File.new(f) }
|
13
10
|
end
|
14
11
|
|
15
12
|
def parse
|
16
|
-
|
17
|
-
self
|
13
|
+
parsers.each(&:parse)
|
18
14
|
end
|
19
15
|
|
20
16
|
def definitions
|
21
|
-
parsers.map(&:definitions).map(&:to_a).reduce(:+)
|
17
|
+
parsers.map(&:definitions).map(&:to_a).reduce(:+)
|
22
18
|
end
|
23
19
|
|
24
20
|
def occurences
|
25
|
-
parsers.map(&:occurences).map(&:to_a).reduce(:+)
|
26
|
-
end
|
27
|
-
|
28
|
-
def count
|
29
|
-
parsers.map(&:count).reduce(:+)
|
21
|
+
parsers.map(&:occurences).map(&:to_a).reduce(:+)
|
30
22
|
end
|
31
23
|
|
32
24
|
private
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
def read
|
37
|
-
files = Dir.glob(::File.join(directory, '**', '*.rb'))
|
38
|
-
self.parsers = Parallel.map(files) do |file|
|
39
|
-
Factory.build(file)
|
40
|
-
end.compact
|
41
|
-
end
|
26
|
+
attr_reader :parsers
|
42
27
|
end
|
43
28
|
end
|
44
29
|
end
|
data/lib/parser/file.rb
CHANGED
@@ -9,7 +9,7 @@ module Rubrowser
|
|
9
9
|
|
10
10
|
def initialize(file)
|
11
11
|
@file = file
|
12
|
-
@definitions =
|
12
|
+
@definitions = []
|
13
13
|
@occurences = []
|
14
14
|
end
|
15
15
|
|
@@ -19,25 +19,20 @@ module Rubrowser
|
|
19
19
|
code = f.read
|
20
20
|
ast = ::Parser::CurrentRuby.parse(code)
|
21
21
|
constants = parse_block(ast)
|
22
|
-
|
23
|
-
|
22
|
+
@definitions = constants[:definitions].uniq
|
23
|
+
@occurences = constants[:occurences].uniq
|
24
24
|
end
|
25
25
|
end
|
26
|
-
self
|
27
26
|
end
|
28
27
|
|
29
28
|
def file_valid?(file)
|
30
|
-
!::File.symlink?(file) &&
|
31
|
-
|
32
|
-
|
33
|
-
def count
|
34
|
-
1
|
29
|
+
!::File.symlink?(file) &&
|
30
|
+
::File.file?(file) &&
|
31
|
+
::File.size(file) <= FILE_SIZE_LIMIT
|
35
32
|
end
|
36
33
|
|
37
34
|
private
|
38
35
|
|
39
|
-
attr_writer :definitions, :occurences
|
40
|
-
|
41
36
|
def parse_block(node, parents = [])
|
42
37
|
return { definitions: [], occurences: [] } unless node.is_a?(::Parser::AST::Node)
|
43
38
|
|
@@ -85,10 +80,10 @@ module Rubrowser
|
|
85
80
|
{ definitions: [], occurences: constants }
|
86
81
|
end
|
87
82
|
|
88
|
-
def merge_constants(
|
83
|
+
def merge_constants(c1, c2)
|
89
84
|
{
|
90
|
-
definitions:
|
91
|
-
occurences:
|
85
|
+
definitions: c1[:definitions] + c2[:definitions],
|
86
|
+
occurences: c1[:occurences] + c2[:occurences]
|
92
87
|
}
|
93
88
|
end
|
94
89
|
|
data/lib/rubrowser.rb
CHANGED
data/lib/server.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'webrick'
|
2
|
-
require 'haml'
|
3
2
|
require 'data'
|
4
3
|
require 'json'
|
4
|
+
require 'erb'
|
5
5
|
|
6
6
|
module Rubrowser
|
7
7
|
class Server < WEBrick::HTTPServer
|
8
|
+
include ERB::Util
|
9
|
+
|
8
10
|
def self.start(paths)
|
9
11
|
new(paths).start
|
10
12
|
end
|
@@ -28,12 +30,7 @@ module Rubrowser
|
|
28
30
|
|
29
31
|
def root(path)
|
30
32
|
return file(path) if file?(path)
|
31
|
-
|
32
|
-
haml :index,
|
33
|
-
locals: {
|
34
|
-
constants: data.constants,
|
35
|
-
occurences: data.occurences
|
36
|
-
}
|
33
|
+
erb :index
|
37
34
|
end
|
38
35
|
|
39
36
|
def file?(path)
|
@@ -45,11 +42,10 @@ module Rubrowser
|
|
45
42
|
File.read(resolve_file_path("/public#{path}"))
|
46
43
|
end
|
47
44
|
|
48
|
-
def
|
49
|
-
path = resolve_file_path("/views/#{template}.
|
45
|
+
def erb(template)
|
46
|
+
path = resolve_file_path("/views/#{template}.erb")
|
50
47
|
file = File.open(path).read
|
51
|
-
|
52
|
-
Haml::Engine.new(file, options).render(self, locals)
|
48
|
+
ERB.new(file).result binding
|
53
49
|
end
|
54
50
|
|
55
51
|
def resolve_file_path(path)
|
data/rubrowser.gemspec
CHANGED
data/views/index.erb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
|
5
|
+
<title>Rubrowser</title>
|
6
|
+
<link href='/css/application.css' media='all' rel='stylesheet'>
|
7
|
+
<script src='/javascript/d3.js' type='text/javascript'></script>
|
8
|
+
<script src='/javascript/jquery.js' type='text/javascript'></script>
|
9
|
+
<script src='/javascript/application.js' type='text/javascript'></script>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div class='dependency_graph'>
|
13
|
+
<svg data-constants="<%=h data.constants.to_json%>" data-occurences="<%=h data.occurences.to_json%>"></svg>
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
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.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emad Elsaid
|
@@ -30,46 +30,6 @@ dependencies:
|
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.3.0
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: parallel
|
35
|
-
requirement: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - "~>"
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '1.9'
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 1.9.0
|
43
|
-
type: :runtime
|
44
|
-
prerelease: false
|
45
|
-
version_requirements: !ruby/object:Gem::Requirement
|
46
|
-
requirements:
|
47
|
-
- - "~>"
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.9'
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: 1.9.0
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: haml
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '4.0'
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: 4.0.0
|
63
|
-
type: :runtime
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '4.0'
|
70
|
-
- - ">="
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
version: 4.0.0
|
73
33
|
description: A ruby interactive dependency graph visualizer
|
74
34
|
email:
|
75
35
|
- blazeeboy@gmail.com
|
@@ -96,7 +56,7 @@ files:
|
|
96
56
|
- public/javascript/jquery.js
|
97
57
|
- readme.md
|
98
58
|
- rubrowser.gemspec
|
99
|
-
- views/index.
|
59
|
+
- views/index.erb
|
100
60
|
homepage: https://github.com/blazeeboy/rubrowser
|
101
61
|
licenses:
|
102
62
|
- MIT
|
data/views/index.haml
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
!!!
|
2
|
-
%html
|
3
|
-
%head
|
4
|
-
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
|
5
|
-
%title Rubrowser
|
6
|
-
%link{ rel: "stylesheet", media: "all", href: "/css/application.css"}
|
7
|
-
%script{:src => "/javascript/d3.js", :type => "text/javascript"}
|
8
|
-
%script{:src => "/javascript/jquery.js", :type => "text/javascript"}
|
9
|
-
%script{:src => "/javascript/application.js", :type => "text/javascript"}
|
10
|
-
%body
|
11
|
-
.dependency_graph
|
12
|
-
%svg{ data: { constants: constants.to_json, occurences: occurences.to_json } }
|