datagnan 1.1.1 → 1.1.2

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 +27 -41
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ab6c13f241c6ea685e9a2e7ad01972240bf7952
4
- data.tar.gz: 50b65b4dc8ca57571b64936be1508859a80c3fce
3
+ metadata.gz: b5a0ec06c2a125c4ad17814577c507cc9ef89b99
4
+ data.tar.gz: af543be0c33c5a149802a8b3c9029fe0f00bdd23
5
5
  SHA512:
6
- metadata.gz: 9d8ca7ab6a3d5b44f2905c95be8dc7d56f59e6aec3841af958b938987032d9af85ef8b57492ba7d7a545f65014ef2fb39286c60a48df850397f8c3d33f436d34
7
- data.tar.gz: 82295ca0a84925b8b8a248606cf08ad3860ef3ebe57f6cab6b906d8fc406066296fbbfafd654007d74dde1400b689906a26fa4b29752caa6181518a65da91cd5
6
+ metadata.gz: 38bde6c095066e835795ed3950cc5fbc93990e50f60d8f786562f8f1d84a3ece6e1ac54b0c4ba5c78cab681f9e0938804f16bb10f3e224848bf81f1530f37d15
7
+ data.tar.gz: bc0c93d748cd7adf1b1a9a3dc8816d5eacbf1469f35da59ff24e3cecb880c31f1a3139754fcbe120252a3311942add7cb84d98d3edcbb5fea2f631404479b421
@@ -6,15 +6,12 @@ class Datagnan
6
6
  attr_accessor :doc, :vars
7
7
 
8
8
  ## Constructor
9
- # @param [String] file_path
10
- # path to .html-template file
11
- # @param [Hash] options
12
- # options for parsing and filling the template
13
- # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
14
- # @option options [Object] :scope (self) Scope for variables
15
- # @option options [Hash] :locals (locals || {}) Local variables for filling the template
16
- # @param [Hash] locals
17
- # local variables for filling the template
9
+ # @param [String] file_path path to .html-template file
10
+ # @param [Hash] options options for parsing and filling the template
11
+ # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
12
+ # @option options [Object] :scope (self) Scope for variables
13
+ # @option options [Hash] :locals (locals || {}) Local variables for filling the template
14
+ # @param [Hash] locals local variables for filling the template
18
15
  def initialize(file_path, options = {}, locals = {})
19
16
  @doc = Oga.parse_html(File.read(file_path))
20
17
  ## debug
@@ -30,15 +27,12 @@ class Datagnan
30
27
  ## Create Datagnan instance and return this.
31
28
  ## Can receive implicity block for 'yield.
32
29
  ## Like File.open(file_path)
33
- # @param [String] file_path
34
- # path to .html-template file
35
- # @param [Hash] options
36
- # options for parsing and filling the template
37
- # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
38
- # @option options [Object] :scope (self) Scope for variables
39
- # @option options [Hash] :locals (locals || {}) Local variables for filling the template
40
- # @param [Hash] locals
41
- # local variables for filling the template
30
+ # @param [String] file_path path to .html-template file
31
+ # @param [Hash] options options for parsing and filling the template
32
+ # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
33
+ # @option options [Object] :scope (self) Scope for variables
34
+ # @option options [Hash] :locals (locals || {}) Local variables for filling the template
35
+ # @param [Hash] locals local variables for filling the template
42
36
  def self.open(file_path, options = {}, locals = {})
43
37
  obj = Datagnan.new(file_path, options, locals).write
44
38
  yield obj if block_given?
@@ -47,15 +41,12 @@ class Datagnan
47
41
 
48
42
  ## Create Datagnan instance and return the filling with variables HTML-template as String.
49
43
  ## Like File.read(file_path)
50
- # @param [String] file_path
51
- # path to .html-template file
52
- # @param [Hash] options
53
- # options for parsing and filling the template
54
- # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
55
- # @option options [Object] :scope (self) Scope for variables
56
- # @option options [Hash] :locals (locals || {}) Local variables for filling the template
57
- # @param [Hash] locals
58
- # local variables for filling the template
44
+ # @param [String] file_path path to .html-template file
45
+ # @param [Hash] options options for parsing and filling the template
46
+ # @option options [String] :attrs_sep (";") Separate string for 'data-attrs' attribute
47
+ # @option options [Object] :scope (self) Scope for variables
48
+ # @option options [Hash] :locals (locals || {}) Local variables for filling the template
49
+ # @param [Hash] locals local variables for filling the template
59
50
  def self.read(file_path, options = {}, locals = {})
60
51
  Datagnan.new(file_path, options, locals).write.read
61
52
  end
@@ -69,10 +60,8 @@ class Datagnan
69
60
 
70
61
  ## Parse and replace
71
62
  ## Like File.new.write
72
- # @param [Hash] vars
73
- # variables for filling the template
74
- # @param [Oga::XML::Document] root
75
- # HTML-element for fill it
63
+ # @param [Hash] vars variables for filling the template
64
+ # @param [Oga::XML::Document] root HTML-element for fill it
76
65
  def write(vars = {}, root = nil)
77
66
  ## debug
78
67
  # puts "Datagnan.write ( vars = #{vars} )"
@@ -280,22 +269,19 @@ private
280
269
  end
281
270
 
282
271
  ## Helper function (for Sinatra, primarily)
283
- # @param [String] file_path
284
- # path to .html-template file
285
- # @param [Hash] options
286
- # options for parsing and filling the template
287
- # @option options [Object] :scope (self) Scope for variables
288
- # @option options [String] :views (scope.settings.views || "./views") Path to views directory
289
- # @option options [Hash] :locals (locals || {}) Local variables for filling the template
290
- # @param [Hash] locals
291
- # local variables for filling the template
272
+ # @param [String] file_path path to .html-template file
273
+ # @param [Hash] options options for parsing and filling the template
274
+ # @option options [Object] :scope (self) Scope for variables
275
+ # @option options [String] :views (scope.settings.views || "./views") Path to views directory
276
+ # @option options [Hash] :locals (locals || {}) Local variables for filling the template
277
+ # @param [Hash] locals local variables for filling the template
292
278
  def datagnan(template_file, options = {}, locals = {})
293
279
  ## default options
294
280
  scope = options.delete(:scope) || self
295
281
  views = File.realpath(options.delete(:views) || scope.settings.views || "./views")
296
282
  locals = options.delete(:locals) || locals || {}
297
283
 
298
- html = Datagnan.read(views+'/'+template_file+'.html', :scope => scope, :locals => locals)
284
+ html = Datagnan.read(views+'/'+template_file.to_s+'.html', :scope => scope, :locals => locals)
299
285
  ## debug
300
286
  # puts "-- datagnan ( template = #{html} )"
301
287
  if File.exist?(views+'/layout.html')
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.1
4
+ version: 1.1.2
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-04-30 00:00:00.000000000 Z
12
+ date: 2015-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oga