yarrow 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/yarrow/config.rb +5 -5
- data/lib/yarrow/content/expansion.rb +6 -41
- data/lib/yarrow/content/expansion_strategy.rb +51 -0
- data/lib/yarrow/content/graph.rb +2 -2
- data/lib/yarrow/content/manifest.rb +4 -4
- data/lib/yarrow/content/model.rb +46 -0
- data/lib/yarrow/content/policy.rb +48 -0
- data/lib/yarrow/content/resource.rb +29 -0
- data/lib/yarrow/content/source.rb +70 -3
- data/lib/yarrow/content/tree_expansion.rb +15 -6
- data/lib/yarrow/generator.rb +1 -1
- data/lib/yarrow/schema/definitions.rb +30 -0
- data/lib/yarrow/schema/dictionary.rb +49 -0
- data/lib/yarrow/schema/entity.rb +51 -0
- data/lib/yarrow/schema/types.rb +73 -0
- data/lib/yarrow/schema/value.rb +46 -0
- data/lib/yarrow/schema.rb +28 -119
- data/lib/yarrow/symbols.rb +15 -0
- data/lib/yarrow/version.rb +1 -1
- data/lib/yarrow.rb +10 -3
- data/yarrow.gemspec +1 -1
- metadata +18 -12
- data/lib/yarrow/content/collection_expander.rb +0 -241
- data/lib/yarrow/content/object_type.rb +0 -42
- data/lib/yarrow/content/source_collector.rb +0 -78
@@ -1,78 +0,0 @@
|
|
1
|
-
module Yarrow
|
2
|
-
module Content
|
3
|
-
# Collects a digraph of all directories and files underneath the given input
|
4
|
-
# directory.
|
5
|
-
class SourceCollector
|
6
|
-
def self.collect(input_dir)
|
7
|
-
Mementus::Graph.new(is_mutable: true) do
|
8
|
-
root = create_node do |root|
|
9
|
-
root.label = :root
|
10
|
-
end
|
11
|
-
|
12
|
-
root_dir_entry = Pathname.new(input_dir)
|
13
|
-
|
14
|
-
root_dir = create_node do |dir|
|
15
|
-
dir.label = :directory
|
16
|
-
dir.props = {
|
17
|
-
name: root_dir_entry.basename.to_s,
|
18
|
-
path: root_dir_entry.to_s,
|
19
|
-
entry: root_dir_entry
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
create_edge do |child|
|
24
|
-
child.label = :child
|
25
|
-
child.from = root.id
|
26
|
-
child.to = root_dir.id
|
27
|
-
end
|
28
|
-
|
29
|
-
directories = {
|
30
|
-
root_dir_entry.to_s => root_dir.id
|
31
|
-
}
|
32
|
-
|
33
|
-
Pathname.glob("#{input_dir}/**/**").each do |entry|
|
34
|
-
if entry.directory?
|
35
|
-
content_node = create_node do |dir|
|
36
|
-
dir.label = :directory
|
37
|
-
# dir.props[:name] = entry.basename.to_s
|
38
|
-
# dir.props[:slug] = entry.basename.to_s
|
39
|
-
# dir.props[:path] = entry.to_s
|
40
|
-
# dir.props[:entry] = entry
|
41
|
-
dir.props = {
|
42
|
-
name: entry.basename.to_s,
|
43
|
-
path: entry.to_s,
|
44
|
-
entry: entry
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
directories[entry.to_s] = content_node.id
|
49
|
-
else
|
50
|
-
content_node = create_node do |file|
|
51
|
-
file.label = :file
|
52
|
-
# file.props[:name] = entry.basename.to_s
|
53
|
-
# file.props[:slug] = entry.basename.sub_ext('').to_s
|
54
|
-
# file.props[:path] = entry.to_s
|
55
|
-
# file.props[:entry] = entry
|
56
|
-
|
57
|
-
file.props = {
|
58
|
-
name: entry.basename.to_s,
|
59
|
-
ext: entry.extname.to_s,
|
60
|
-
path: entry.to_s,
|
61
|
-
entry: entry
|
62
|
-
}
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
if directories.key?(entry.dirname.to_s)
|
67
|
-
create_edge do |edge|
|
68
|
-
edge.label = :child
|
69
|
-
edge.from = directories[entry.dirname.to_s]
|
70
|
-
edge.to = content_node
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|