datagnan 1.2.0 → 1.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/datagnan.rb +21 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 881e2804b0516deffd9baa0fdd07a6b4dd9e5aa6
4
- data.tar.gz: 3435fc4132a7ad4f77c84a0f8f78906bf058c527
3
+ metadata.gz: f088e30bfb4123a90aeb0a53ccdc911ee805c572
4
+ data.tar.gz: 6ed257beac94a08f8dc9e485a32086188384234c
5
5
  SHA512:
6
- metadata.gz: 65388ecda133e1669acf4cfea36067b8b203ab2fe67ed15ac25c91e40300957970f5c797621bfcd8af71bd778c2f5bba37c4b8f089b119620a3f06a3201fb674
7
- data.tar.gz: 17245b721d824eef3654a2acce9a1cb7736019329f1a8d113e4f5834564750212f618157847508a26bdabd03fd23289b04363777bd6d55e50c20b6850976f499
6
+ metadata.gz: 1131dcf4d53e201502c926da2881870f87cabc5e6777643dd4342605a2fb641c284248da42db7928c1198f1d7f73f99092958ce19616f318456b7797d7d5c482
7
+ data.tar.gz: 6b3fa249e0972186eae0f50c1bff35ba2bc5c34d235d19c6ca5d135cab2b8b7521858560ed8c3742257bbd71a4bd7201734af36977d476d0632283afd95b420c
@@ -94,10 +94,14 @@ class Datagnan
94
94
  # puts "Datagnan.write after vars ( root = #{root.to_xml} )"
95
95
  ## replace data-attrs
96
96
  data_attrs(vars, root)
97
- data_attr(vars, root)
98
97
  ## debug
99
98
  # puts "Datagnan.write after attrs ( vars = #{vars} )"
100
99
  # puts "Datagnan.write after attrs ( root = #{root.to_xml} )"
100
+ ## replace data-attr-*
101
+ data_attr(vars, root)
102
+ ## debug
103
+ # puts "Datagnan.write after attr ( vars = #{vars} )"
104
+ # puts "Datagnan.write after attr ( root = #{root.to_xml} )"
101
105
  ## result
102
106
  return self
103
107
  end
@@ -127,7 +131,7 @@ private
127
131
  ## :path_filters = { /^\// => '', '/' => '.' }
128
132
  ## path => 'foo.bar'
129
133
  @options[:path_filters].each { |key, val| path.gsub!(key, val) }
130
-
134
+
131
135
  dot_keys = path.split('.')
132
136
  dot_keys = dot_keys.drop_while do |dot_key|
133
137
  ## debug
@@ -199,12 +203,17 @@ private
199
203
  root.xpath("//@*[starts-with(name(), 'data-attr-')]").each do |attr|
200
204
  node = attr.element
201
205
 
202
- key = attr.name.sub!('data-attr-', '')
206
+ key = attr.name.sub(/^data\-attr\-/, '')
203
207
  val = attr.value
204
208
 
205
209
  var = find_value(val, vars)
210
+ ## debug
211
+ # puts "-- Datagnan.data_attr each after find_value ( var = #{var} )"
212
+ # puts "-- Datagnan.data_attr each after find_value ( var.to_s = #{var.to_s} )"
206
213
 
207
- unless var.nil?
214
+ unless var.nil? || var == false
215
+ ## debug
216
+ # puts "-- Datagnan.data_attr each before insert ( node.to_xml = #{node.to_xml} )"
208
217
  node.attributes.insert(
209
218
  node.attributes.index(attr),
210
219
  Oga::XML::Attribute.new(
@@ -213,9 +222,15 @@ private
213
222
  :element => node
214
223
  )
215
224
  )
225
+ ## debug
226
+ # puts "-- Datagnan.data_attr each after insert ( node.to_xml = #{node.to_xml} )"
216
227
  end
217
228
  node.unset(attr.name)
229
+ ## debug
230
+ # puts "-- Datagnan.data_attr each ( node.to_xml = #{node.to_xml} )"
218
231
  end
232
+ ## debug
233
+ # puts "-- Datagnan.data_attr after ( root.to_xml = #{root.to_xml} )"
219
234
  end
220
235
 
221
236
  ## node attributes
@@ -240,7 +255,7 @@ private
240
255
  ## debug
241
256
  # puts "-- Datagnan.data_attrs each attr ( var = #{var} )"
242
257
 
243
- unless var.nil?
258
+ unless var.nil? || var == false
244
259
  node.attributes.insert(
245
260
  node.attributes.index(node_data_attrs),
246
261
  Oga::XML::Attribute.new(
@@ -346,7 +361,7 @@ def datagnan(template_file, options = {}, local_vars = {})
346
361
  # beginning_time = Time.now
347
362
  ## default options
348
363
  options[:scope] ||= self
349
- options[:views_dir] = File.realpath(options[:views_dir] || (options[:scope].settings.views if options[:scope].settings) || "./views")
364
+ options[:views_dir] = File.realpath(options[:views_dir] || (options[:scope].settings.views if options[:scope].respond_to? :settings) || "./views")
350
365
  options[:layout_file] = File.join(options[:views_dir], options[:layout_file] || 'layout.html')
351
366
  (options[:local_vars] ||= {}).merge! local_vars
352
367
 
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.2.0
4
+ version: 1.2.1
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-21 00:00:00.000000000 Z
12
+ date: 2015-05-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oga