tzispa_rig 0.2.4 → 0.2.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/tzispa/rig/binder.rb +2 -2
- data/lib/tzispa/rig/parsernext.rb +0 -1
- data/lib/tzispa/rig/template.rb +59 -7
- data/lib/tzispa/rig/version.rb +2 -2
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aef6c491f3383fc7cbd791222d9a35f5ba1503ed
|
4
|
+
data.tar.gz: 75e0bc0bbf5d889882d886645c283027c6180575
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 071b901ee6482b8609a743688dc4fd9a1c996d124522c75e91ee2109f5a95887a1e5fab41ec6eccfb7541238d018ff6e48afc66658859cc5e739baf605432794
|
7
|
+
data.tar.gz: 87e18aaae6a446409b51dfcd3943845819786457696742277cc6ffac45c042d58a116f236c3b7a463f9f9f59d24a49633807ae414536ebb185fa7066d8f64963
|
data/CHANGELOG.md
CHANGED
data/lib/tzispa/rig/binder.rb
CHANGED
@@ -96,11 +96,11 @@ module Tzispa
|
|
96
96
|
@source_object.send method, *args, &generator
|
97
97
|
end
|
98
98
|
|
99
|
-
def loop_item(
|
99
|
+
def loop_item(params=nil)
|
100
100
|
(LoopItem.new self).tap { |item|
|
101
101
|
params.each{ |k,v|
|
102
102
|
item.data[k] = v
|
103
|
-
}
|
103
|
+
} if params
|
104
104
|
}
|
105
105
|
end
|
106
106
|
|
data/lib/tzispa/rig/template.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'forwardable'
|
4
|
+
require 'fileutils'
|
5
|
+
require 'tzispa/utils/string'
|
6
|
+
require 'tzispa/rig'
|
7
|
+
|
3
8
|
module Tzispa
|
4
9
|
module Rig
|
5
10
|
|
@@ -24,13 +29,13 @@ module Tzispa
|
|
24
29
|
@modified != File.mtime(@file)
|
25
30
|
end
|
26
31
|
|
27
|
-
def
|
28
|
-
::File.
|
32
|
+
def exist?
|
33
|
+
::File.exist?(@file)
|
29
34
|
end
|
30
35
|
|
31
36
|
def load!
|
32
37
|
begin
|
33
|
-
raise NotFound.new("Template file '#{@file}' not found") unless
|
38
|
+
raise NotFound.new("Template file '#{@file}' not found") unless exist?
|
34
39
|
::File.open(@file, 'r:UTF-8') { |f|
|
35
40
|
@content = String.new
|
36
41
|
@modified = f.mtime
|
@@ -45,6 +50,12 @@ module Tzispa
|
|
45
50
|
self
|
46
51
|
end
|
47
52
|
|
53
|
+
def create(content=nil)
|
54
|
+
::File.open(@file, "w") { |f|
|
55
|
+
f.puts content
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
48
59
|
end
|
49
60
|
|
50
61
|
|
@@ -73,8 +84,7 @@ module Tzispa
|
|
73
84
|
@domain = domain
|
74
85
|
@format = format || DEFAULT_FORMAT
|
75
86
|
end
|
76
|
-
|
77
|
-
super "#{@domain.path}/rig/#{@type.to_s.downcase}/#{@subdomain+'/' if @subdomain}#{@name}.#{RIG_EXTENSION}.#{@format}"
|
87
|
+
super "#{path}/#{@name}.#{RIG_EXTENSION}.#{@format}"
|
78
88
|
end
|
79
89
|
|
80
90
|
def parse!
|
@@ -90,6 +100,17 @@ module Tzispa
|
|
90
100
|
@parser.render binder, context
|
91
101
|
end
|
92
102
|
|
103
|
+
def path
|
104
|
+
"#{@domain.path}/rig/#{@type.to_s.downcase}#{'/'+@subdomain if @subdomain}"
|
105
|
+
end
|
106
|
+
|
107
|
+
def create
|
108
|
+
FileUtils.mkdir_p(path) unless Dir.exist? path
|
109
|
+
puts "path = #{Dir.exist? path}"
|
110
|
+
super
|
111
|
+
create_binder
|
112
|
+
end
|
113
|
+
|
93
114
|
def is_block?
|
94
115
|
@type == :block
|
95
116
|
end
|
@@ -110,9 +131,21 @@ module Tzispa
|
|
110
131
|
@params.data
|
111
132
|
end
|
112
133
|
|
134
|
+
def binder_require
|
135
|
+
"rig/#{@type}/#{@subdomain+'/' if @subdomain}#{@name.downcase}"
|
136
|
+
end
|
137
|
+
|
138
|
+
def binder_namespace
|
139
|
+
"#{TzString.camelize @domain.name}::Rig::#{@type.to_s.capitalize}#{'::' + TzString.camelize(@subdomain) if @subdomain}"
|
140
|
+
end
|
141
|
+
|
142
|
+
def binder_class_name
|
143
|
+
TzString.camelize @name
|
144
|
+
end
|
145
|
+
|
113
146
|
def binder_class
|
114
|
-
@domain.require
|
115
|
-
TzString.constantize "#{
|
147
|
+
@domain.require binder_require
|
148
|
+
TzString.constantize "#{binder_namespace}::#{binder_class_name}"
|
116
149
|
end
|
117
150
|
|
118
151
|
private
|
@@ -122,6 +155,25 @@ module Tzispa
|
|
122
155
|
@type = value
|
123
156
|
end
|
124
157
|
|
158
|
+
def create_binder
|
159
|
+
::File.open("#{domain.path}/#{binder_require}.rb", "w") { |f|
|
160
|
+
binder_code = TzString.new
|
161
|
+
f.puts binder_code.indenter("require 'tzispa/rig/binder'\n\n")
|
162
|
+
level = 0
|
163
|
+
binder_namespace.split('::').each { |ns|
|
164
|
+
f.puts binder_code.indenter("module #{ns}\n", level > 0 ? 2 : 0).to_s
|
165
|
+
level += 1
|
166
|
+
}
|
167
|
+
f.puts binder_code.indenter("\nclass #{binder_class_name} < Tzispa::Rig::TemplateBinder\n\n", 2)
|
168
|
+
f.puts binder_code.indenter("def bind!", 2)
|
169
|
+
f.puts binder_code.indenter("end\n\n")
|
170
|
+
f.puts binder_code.unindenter("end", 2)
|
171
|
+
binder_namespace.split('::').each { |ns|
|
172
|
+
f.puts binder_code.unindenter("end\n", 2)
|
173
|
+
}
|
174
|
+
} if @type == :block
|
175
|
+
end
|
176
|
+
|
125
177
|
end
|
126
178
|
|
127
179
|
|
data/lib/tzispa/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzispa_helpers
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.1.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: tzispa_utils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.1
|
41
41
|
description: General purpose template engine
|
42
42
|
email:
|
43
43
|
- japinero@area-integral.com
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.4.8
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: General purpose template engine
|