reqwire 0.0.0 → 0.0.1
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.
- data/lib/reqwire.rb +27 -7
- metadata +1 -1
data/lib/reqwire.rb
CHANGED
|
@@ -9,7 +9,7 @@ class Reqwire
|
|
|
9
9
|
@path_rel
|
|
10
10
|
@path_abs
|
|
11
11
|
|
|
12
|
-
attr_accessor :children, :path_abs, :path_rel
|
|
12
|
+
attr_accessor :children, :path_abs, :path_rel, :out
|
|
13
13
|
|
|
14
14
|
def initialize(params)
|
|
15
15
|
@fname = params[:fname]
|
|
@@ -50,14 +50,12 @@ class Reqwire
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
def
|
|
54
|
-
resolve()
|
|
55
|
-
yield(@path_abs, @path_rel, @out)
|
|
53
|
+
def findParents()
|
|
56
54
|
res = []
|
|
57
55
|
Dir.glob(File.join(projectDir(), '**', '*')) do |path|
|
|
58
|
-
out = StringIO.new("", "w+")
|
|
59
56
|
next if File.directory?(path)
|
|
60
57
|
next if @children[path]
|
|
58
|
+
out = StringIO.new("", "w+")
|
|
61
59
|
req = Reqwire.new(
|
|
62
60
|
:fname => path,
|
|
63
61
|
:repo => [projectDir()],
|
|
@@ -65,9 +63,31 @@ class Reqwire
|
|
|
65
63
|
)
|
|
66
64
|
req.resolve()
|
|
67
65
|
if req.children[@path_abs] then
|
|
68
|
-
|
|
66
|
+
res << req
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
res
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def revert(visited = {}, &handler)
|
|
73
|
+
resolve()
|
|
74
|
+
if !visited[@path_abs] then
|
|
75
|
+
yield(@path_abs, @path_rel, @out)
|
|
76
|
+
end
|
|
77
|
+
visited[path_abs] = true
|
|
78
|
+
parents = findParents()
|
|
79
|
+
deep = []
|
|
80
|
+
parents.each do |parent|
|
|
81
|
+
if !visited[parent.path_abs] then
|
|
82
|
+
yield(parent.path_abs, parent.path_rel, parent.out)
|
|
83
|
+
visited[parent.path_abs] = true
|
|
84
|
+
deep << parent
|
|
69
85
|
end
|
|
70
|
-
|
|
86
|
+
end
|
|
87
|
+
deep.each do |req|
|
|
88
|
+
req.revert(visited) do |abs, rel, out|
|
|
89
|
+
yield(abs, rel, out)
|
|
90
|
+
end
|
|
71
91
|
end
|
|
72
92
|
end
|
|
73
93
|
|