qor_dsl 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.
- data/.gitignore +2 -1
- data/lib/qor_dsl/class_method.rb +13 -1
- data/lib/qor_dsl/node.rb +22 -0
- data/qor_dsl.gemspec +1 -1
- metadata +1 -1
data/.gitignore
CHANGED
data/lib/qor_dsl/class_method.rb
CHANGED
@@ -13,8 +13,20 @@ module Qor
|
|
13
13
|
@root || load
|
14
14
|
end
|
15
15
|
|
16
|
+
def default_configs(files)
|
17
|
+
@default_configs = files
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_config
|
21
|
+
if @default_configs.is_a?(Array)
|
22
|
+
@default_configs.select {|x| File.exist?(x) }[0]
|
23
|
+
else
|
24
|
+
@default_configs
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
16
28
|
def load(path=nil, opts={})
|
17
|
-
@load_path = path || @load_path
|
29
|
+
@load_path = path || @load_path || default_config
|
18
30
|
@root = (opts[:force] ? nil : @root) || load_file(@load_path)
|
19
31
|
@root
|
20
32
|
end
|
data/lib/qor_dsl/node.rb
CHANGED
@@ -8,6 +8,10 @@ module Qor
|
|
8
8
|
self.add_config(options[:config] || Qor::Dsl::Config.new('ROOT', self))
|
9
9
|
end
|
10
10
|
|
11
|
+
def inspect_name
|
12
|
+
"{#{config.__name}: #{name || 'nil'}}"
|
13
|
+
end
|
14
|
+
|
11
15
|
def add_config(config)
|
12
16
|
self.config = config
|
13
17
|
config.__node = self
|
@@ -19,6 +23,8 @@ module Qor
|
|
19
23
|
|
20
24
|
def children
|
21
25
|
@children ||= []
|
26
|
+
@children = @children.flatten.compact
|
27
|
+
@children
|
22
28
|
end
|
23
29
|
|
24
30
|
def config_options_for_child(type)
|
@@ -49,6 +55,22 @@ module Qor
|
|
49
55
|
def value
|
50
56
|
options[:value] || (block.nil? ? name : block.call)
|
51
57
|
end
|
58
|
+
|
59
|
+
def inspect
|
60
|
+
result = [
|
61
|
+
['name', inspect_name],
|
62
|
+
['parent', parent && parent.inspect_name],
|
63
|
+
['config', config.__name],
|
64
|
+
['children', children.map(&:inspect_name)],
|
65
|
+
['options', options],
|
66
|
+
['block', block]
|
67
|
+
].inject({}) do |s, value|
|
68
|
+
s[value[0]] = value[1] if value[1] && value[1].to_s.length > 0
|
69
|
+
s
|
70
|
+
end.inspect
|
71
|
+
|
72
|
+
"<Qor::Dsl::Node> #{result}"
|
73
|
+
end
|
52
74
|
end
|
53
75
|
end
|
54
76
|
end
|
data/qor_dsl.gemspec
CHANGED