datagnan 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datagnan.rb +43 -34
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c71b936e47fb8e7e80ea5cf3ea76978cce826dc3
4
- data.tar.gz: 7c972510249bdfad1f5bdfdd4de8dbb9a3f883dc
3
+ metadata.gz: 4ff29956adae77378e8f4d320693f2319e3995bb
4
+ data.tar.gz: e1401f2e12ed8faa80beb219b701145a0a0f0c97
5
5
  SHA512:
6
- metadata.gz: e14b7a4b3efb821b07fa868a6fe72260bd1c8ecbf35a0d8a183fad251b183f93ccaff92623342f11e42fbc05bb00ee41980687a0c7485b92e90f30c77df3d48a
7
- data.tar.gz: fd24893e237415ad72462619f6f6183a4684286d78f83e0a9984d8c9e48cab6f538e70e6f9b57695c6d4ba81bd7e4b77b2cb2d7aee8e8d30cfc646f705d9e3b8
6
+ metadata.gz: abf4aa468a7d5ac4d0242f61239fa9da1555d10f5c1996e1661c5f8e4cd1e44a353ccb796381929c8a759fc798454dd6926248b2d81c084568134f634f20f02b
7
+ data.tar.gz: d982e33c22ebafc62fc1820e9e170038769a41d61f34c1da2f6145acda568815c55eb8ba1925c30e5ec25260721390b56e4c87543bb5a64e4b7fc4c4709702a8
@@ -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('.').each do |dot_key|
129
+ dot_keys = path.split('.')
130
+ dot_keys = dot_keys.drop_while do |dot_key|
129
131
  ## debug
130
- # puts "dot_key.split ( dot_key = #{dot_key} )"
131
- # puts "dot_key.split ( dot_key.split = #{dot_key.split(/\[\'?([^\[\]]*[^\'])\'?\]/).reject(&:empty?)} )"
132
- dot_key.split(/\[\'?([^\[\]\']+)\'?\]/).reject(&:empty?).each do |key|
133
- ## var exist
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 split ( key = #{key} )"
136
- # puts "-- Datagnan.find_value split ( var = #{var} )"
137
- # puts "-- Datagnan.find_value split ( var[key].nil? = #{var[key].nil?} )" if var.is_a?(Hash)
138
- # puts "-- Datagnan.find_value split ( @scope.respond_to?(key) = #{@scope.respond_to?(key)} )"
139
- # puts "-- Datagnan.find_value split ( @scope.send(key) = #{@scope.send(key)} )" if @scope.respond_to?(key)
140
- # puts "-- Datagnan.find_value split ( var.respond_to?(key) = #{var.respond_to?(key)} )"
141
- # puts "-- Datagnan.find_value split ( var.send(key) = #{var.send(key)} )" if var.respond_to?(key)
142
- # puts "-- Datagnan.find_value split ( class_exists?(key) = #{class_exists?(key)} )"
143
- # puts "-- Datagnan.find_value split ( Module.const_get(key) = #{Module.const_get(key)} )" if class_exists?(key)
144
- var = ( var.is_a?(Hash) ?
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
- # puts "-- Datagnan.find_value ( var = #{var} )"
163
- # var = find_value(path, @vars) if var.nil? && vars != @vars
164
- # puts "-- Datagnan.find_value after recursive with @vars ( var = #{var} )"
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
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-17 00:00:00.000000000 Z
12
+ date: 2015-05-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oga