kurangu 0.0.1 → 0.0.2
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/lib/kurangu.rb +10 -9
- data/lib/trace.rb +5 -3
- 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: c878be455c92153388c28789fa52dd75cf8af897
|
4
|
+
data.tar.gz: 11199180b1f492e70c92e479c0435ad4e30c594f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c965377a60f1e88885d69b9a5b092534441ab008c3ed3c439c2534e47f83735b53625c7e588254168c26439ef4a0850fe96045371a1440d9bb76fe75a6a70c32
|
7
|
+
data.tar.gz: 860f00f76c6513fff33f7711a85355388339a69cace2a469664442891edd7ac2dc61e4695f844d85dad71031cf4944fcf880f81de3c1f6365435605f97efb2ce
|
data/lib/kurangu.rb
CHANGED
@@ -9,9 +9,9 @@ class Kurangu
|
|
9
9
|
system(ruby, "-r", trace_file, input_file)
|
10
10
|
end
|
11
11
|
|
12
|
-
def print_annotations
|
12
|
+
def print_annotations(paths_file)
|
13
13
|
puts "\nthe annotations generated are:\n"
|
14
|
-
File.open(
|
14
|
+
File.open(paths_file, "r") do |f|
|
15
15
|
f.each_line do |annotation_file|
|
16
16
|
puts annotation_file
|
17
17
|
File.open(annotation_file, "r") do |f|
|
@@ -25,8 +25,8 @@ class Kurangu
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def generate_annotated_files
|
29
|
-
File.open(
|
28
|
+
def generate_annotated_files(paths_file)
|
29
|
+
File.open(paths_file, "r") do |f|
|
30
30
|
f.each_line do |annotation_path|
|
31
31
|
original_path = annotation_path.chomp('.annotations')
|
32
32
|
annotated_path = "#{original_path}.annotated"
|
@@ -61,8 +61,8 @@ class Kurangu
|
|
61
61
|
FileUtils.mv(annotated_path, original_path)
|
62
62
|
end
|
63
63
|
|
64
|
-
def apply_annotations
|
65
|
-
File.open(
|
64
|
+
def apply_annotations(paths_file)
|
65
|
+
File.open(paths_file, "r") do |f|
|
66
66
|
f.each_line do |annotation_path|
|
67
67
|
original_path = annotation_path.chomp('.annotations')
|
68
68
|
annotated_path = "#{original_path}.annotated"
|
@@ -79,10 +79,11 @@ class Kurangu
|
|
79
79
|
|
80
80
|
def run(input_file_path)
|
81
81
|
input_file = File.expand_path(input_file_path)
|
82
|
+
paths_file = "#{File.dirname(input_file)}/annotations_paths.txt"
|
82
83
|
self.generate_annotations(input_file)
|
83
|
-
self.print_annotations
|
84
|
-
self.generate_annotated_files
|
85
|
-
self.apply_annotations
|
84
|
+
self.print_annotations(paths_file)
|
85
|
+
self.generate_annotated_files(paths_file)
|
86
|
+
self.apply_annotations(paths_file)
|
86
87
|
self.run_rdl(input_file)
|
87
88
|
end
|
88
89
|
end
|
data/lib/trace.rb
CHANGED
@@ -13,8 +13,9 @@ def generate_signature(line, parameters, parameter_types, return_types)
|
|
13
13
|
"#{line} type '(#{joined_parameters.join(", ")}) -> #{return_types.join(" or ")}'"
|
14
14
|
end
|
15
15
|
|
16
|
-
def write_annotations_paths(paths)
|
17
|
-
|
16
|
+
def write_annotations_paths(dir, paths)
|
17
|
+
paths_file = "#{dir}/annotations_paths.txt"
|
18
|
+
IO.write(paths_file, paths.to_a.join("\n"))
|
18
19
|
end
|
19
20
|
|
20
21
|
def write_annotations(path, signatures)
|
@@ -33,7 +34,8 @@ trace_return = TracePoint.new(:return) do |t|
|
|
33
34
|
line = t.self.method(t.method_id).source_location[1]
|
34
35
|
signatures[s] = generate_signature(line, parameter_list[s], parameter_types[s], return_types[s])
|
35
36
|
path = "#{t.path}.annotations"
|
36
|
-
|
37
|
+
dir = File.dirname(t.path)
|
38
|
+
write_annotations_paths(dir, paths.add(path))
|
37
39
|
write_annotations(path, signatures)
|
38
40
|
end
|
39
41
|
end
|