module_mapper 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/module_mapper/map.rb +25 -11
- data/lib/module_mapper/parser.rb +8 -11
- data/lib/module_mapper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c14f20067cca3e597cbc430a37960a5225d5454
|
4
|
+
data.tar.gz: 48440dc095a6699db2e91abe662ae2a69ff911a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f350849614f71e1f9d6e9232ed92d8ed6df59b76fefbe6b23cefcbbba24d63412be8d4c7e83391318706f4d4f28901dc85548522bbe0feb0087a0944f8d0fab
|
7
|
+
data.tar.gz: d030f384e61902078d0fdb545c3bef2310cf92f45e2273e77c94d3b049faf09d3a1cced2ba937fbcd95c9b8563c663ba6dc444e7d7e79dc5620b076698bceb47
|
data/lib/module_mapper/map.rb
CHANGED
@@ -2,17 +2,31 @@ module ModuleMapper
|
|
2
2
|
module Map
|
3
3
|
|
4
4
|
def self.from(content:, filename:)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
orig_stderr = $stderr.clone
|
6
|
+
orig_stdout = $stdout.clone
|
7
|
+
$stderr.reopen File.new('/dev/null', 'w')
|
8
|
+
$stdout.reopen File.new('/dev/null', 'w')
|
9
|
+
begin
|
10
|
+
parser = Analyst.for_source(content)
|
11
|
+
containers = parser.top_level_entities.select{|e| e.respond_to? :all_methods}
|
12
|
+
containers << containers.map(&:classes)
|
13
|
+
containers.flatten!.reject!{ |container| container.all_methods.empty? }
|
14
|
+
containers.map do |container|
|
15
|
+
{
|
16
|
+
module_name: container.full_name,
|
17
|
+
filename: filename
|
18
|
+
}
|
19
|
+
end
|
20
|
+
rescue
|
21
|
+
containers = [
|
22
|
+
{
|
23
|
+
module_name: "Unknown",
|
24
|
+
filename: filename
|
25
|
+
}
|
26
|
+
]
|
27
|
+
ensure
|
28
|
+
$stdout.reopen orig_stdout
|
29
|
+
$stderr.reopen orig_stderr
|
16
30
|
end
|
17
31
|
end
|
18
32
|
|
data/lib/module_mapper/parser.rb
CHANGED
@@ -9,24 +9,21 @@ module ModuleMapper
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def report
|
12
|
-
|
13
|
-
|
12
|
+
file_reader.source_files.each do |source_file|
|
13
|
+
maps(source_file).each do |mmap|
|
14
|
+
puts "#{mmap[:filename]}\t#{mmap[:module_name]}"
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def
|
20
|
-
|
21
|
+
def maps(source_file)
|
22
|
+
ModuleMapper::Map.from(filename: source_file.filename, content: source_file.contents)
|
21
23
|
end
|
22
24
|
|
23
|
-
def
|
24
|
-
@
|
25
|
-
ModuleMapper::Map.from(
|
26
|
-
filename: source_file.filename,
|
27
|
-
content: source_file.contents
|
28
|
-
)
|
29
|
-
end.flatten
|
25
|
+
def file_reader
|
26
|
+
@file_reader ||= ModuleMapper::FileReader.new(self.paths_to_files)
|
30
27
|
end
|
31
28
|
|
32
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: module_mapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CoralineAda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: analyst
|