datagnan 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/datagnan.rb +43 -34
- 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: 4ff29956adae77378e8f4d320693f2319e3995bb
|
4
|
+
data.tar.gz: e1401f2e12ed8faa80beb219b701145a0a0f0c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abf4aa468a7d5ac4d0242f61239fa9da1555d10f5c1996e1661c5f8e4cd1e44a353ccb796381929c8a759fc798454dd6926248b2d81c084568134f634f20f02b
|
7
|
+
data.tar.gz: d982e33c22ebafc62fc1820e9e170038769a41d61f34c1da2f6145acda568815c55eb8ba1925c30e5ec25260721390b56e4c87543bb5a64e4b7fc4c4709702a8
|
data/lib/datagnan.rb
CHANGED
@@ -124,44 +124,49 @@ private
|
|
124
124
|
## debug
|
125
125
|
# puts "-- Datagnan.find_value ( path = #{path} )"
|
126
126
|
# puts "-- Datagnan.find_value ( vars = #{vars} )"
|
127
|
+
# beginning_time = Time.now
|
127
128
|
var = vars
|
128
|
-
path.split('.')
|
129
|
+
dot_keys = path.split('.')
|
130
|
+
dot_keys = dot_keys.drop_while do |dot_key|
|
129
131
|
## debug
|
130
|
-
# puts "
|
131
|
-
# puts "
|
132
|
-
|
133
|
-
|
132
|
+
# puts "-- Datagnan.find_value drop_while ( dot_key = #{dot_key} )"
|
133
|
+
# puts "-- Datagnan.find_value drop_while ( var.has_key?(dot_key) = #{var.has_key?(dot_key)} )" if var.is_a?(Hash)
|
134
|
+
var.is_a?(Hash) ?
|
135
|
+
(var.has_key?(dot_key) ?
|
136
|
+
var = var[dot_key] :
|
137
|
+
false
|
138
|
+
) :
|
139
|
+
false
|
140
|
+
end
|
141
|
+
## debug
|
142
|
+
# puts "-- Datagnan.find_value after drop_while ( var = #{var} )"
|
143
|
+
# puts "-- Datagnan.find_value after drop_while ( dot_keys = #{dot_keys} )"
|
144
|
+
# puts "-- Datagnan.find_value before eval ( dot_keys = #{dot_keys} )"
|
145
|
+
|
146
|
+
|
147
|
+
begin
|
148
|
+
## debug
|
149
|
+
# puts "-- Datagnan.find_value before eval ( var.instance_eval(dot_keys.join('.')) = #{var.instance_eval(dot_keys.join('.'))} )"
|
150
|
+
var = var.instance_eval(dot_keys.join('.'))
|
151
|
+
rescue Exception => e
|
152
|
+
begin
|
134
153
|
## debug
|
135
|
-
# puts "-- Datagnan.find_value
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
( var[key].nil? ?
|
146
|
-
( @scope.respond_to?(key) ?
|
147
|
-
@scope.send(key) :
|
148
|
-
( class_exists?(key) ?
|
149
|
-
Module.const_get(key) :
|
150
|
-
nil
|
151
|
-
)
|
152
|
-
) :
|
153
|
-
var[key]
|
154
|
-
) :
|
155
|
-
( var.respond_to?(key) ?
|
156
|
-
var.send(key) :
|
157
|
-
nil
|
158
|
-
)
|
159
|
-
)
|
154
|
+
# puts "-- Datagnan.find_value before eval ( @scope.instance_eval('var.'+dot_keys.join('.')) = #{@scope.instance_eval('var.'+dot_keys.join('.'))} )" if dot_keys.any?
|
155
|
+
var = @scope.instance_eval('var.'+dot_keys.join('.'))
|
156
|
+
rescue Exception => e
|
157
|
+
begin
|
158
|
+
## debug
|
159
|
+
# puts "-- Datagnan.find_value before eval ( @scope.instance_eval(dot_keys.join('.')) = #{@scope.instance_eval(dot_keys.join('.'))} )"
|
160
|
+
var = @scope.instance_eval(dot_keys.join('.'))
|
161
|
+
rescue
|
162
|
+
var = nil
|
163
|
+
end
|
160
164
|
end
|
161
|
-
end
|
162
|
-
|
163
|
-
#
|
164
|
-
#
|
165
|
+
end if dot_keys.any?
|
166
|
+
## debug
|
167
|
+
# puts "-- Datagnan.find_value result ( var = #{var} )"
|
168
|
+
# end_time = Time.now
|
169
|
+
# puts "Time elapsed for find_value #{(end_time - beginning_time)*1000} milliseconds"
|
165
170
|
var
|
166
171
|
end
|
167
172
|
|
@@ -307,6 +312,7 @@ end
|
|
307
312
|
# @param [Hash] locals
|
308
313
|
# local variables for filling the template
|
309
314
|
def datagnan(template_file, options = {}, locals = {})
|
315
|
+
# beginning_time = Time.now
|
310
316
|
## default options
|
311
317
|
scope = options.delete(:scope) || self
|
312
318
|
views = File.realpath(options.delete(:views) || scope.settings.views || "./views")
|
@@ -322,5 +328,8 @@ def datagnan(template_file, options = {}, locals = {})
|
|
322
328
|
# puts "-- datagnan ( layout = #{html} )"
|
323
329
|
end
|
324
330
|
|
331
|
+
# end_time = Time.now
|
332
|
+
# puts "Time elapsed for datagnan #{(end_time - beginning_time)*1000} milliseconds"
|
333
|
+
|
325
334
|
return html
|
326
335
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datagnan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-05-
|
12
|
+
date: 2015-05-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oga
|