zorglub 0.1.0 → 0.1.2

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.
data/spec/spec_helper.rb CHANGED
@@ -1,19 +1,19 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  begin
4
- require 'simplecov'
5
- SimpleCov.start do
6
- add_filter 'spec'
7
- end
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_filter 'spec'
7
+ end
8
8
  rescue LoadError
9
9
  end
10
10
 
11
11
  begin
12
- require 'coveralls'
13
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
14
- SimpleCov::Formatter::HTMLFormatter,
15
- Coveralls::SimpleCov::Formatter
16
- ]
12
+ require 'coveralls'
13
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
14
+ SimpleCov::Formatter::HTMLFormatter,
15
+ Coveralls::SimpleCov::Formatter
16
+ ]
17
17
  rescue LoadError
18
18
  end
19
19
 
@@ -24,206 +24,224 @@ require 'zorglub/engines/file'
24
24
  require 'zorglub/engines/haml'
25
25
  require 'zorglub/engines/sass'
26
26
 
27
- HASH_PROC = Proc.new { |path,obj| {:path=>path,:layout=>obj.layout,:view=>obj.view,:args=>obj.args,:map=>obj.map}.to_yaml }
28
- STATIC_PROC = Proc.new { |path,obj| ["VAL #{obj.value}",'text/static'] }
29
- RENDER_PROC = Proc.new { |path,obj|
30
- case obj.state
31
- when :layout
32
- "layout_start #{obj.content} layout_end"
33
- when :view
34
- ["view_content", 'text/view']
35
- when :partial
36
- ['partial_content','text/partial']
37
- else
38
- raise Exception.new
39
- end
27
+ HASH_PROC = proc { |path, obj| { path: path, layout: obj.layout, view: obj.view, args: obj.args, map: obj.map }.to_yaml }
28
+ STATIC_PROC = proc { |_path, obj| ["VAL #{obj.value}", 'text/static'] }
29
+ RENDER_PROC = proc { |_path, obj|
30
+ case obj.state
31
+ when :layout
32
+ "layout_start #{obj.content} layout_end"
33
+ when :view
34
+ ['view_content', 'text/view']
35
+ when :partial
36
+ ['partial_content', 'text/partial']
37
+ else
38
+ raise Exception.new
39
+ end
40
40
  }
41
41
  APP_ROOT = File.join Dir.pwd, 'spec', 'data'
42
42
 
43
43
  class Zorglub::Node
44
- def self.my_call uri
45
- call( {'PATH_INFO'=>uri} )
46
- end
47
- def self.my_call_i uri
48
- call( {'PATH_INFO'=>uri} ).body[0].to_i
49
- end
44
+ def self.my_call(uri)
45
+ call({ 'PATH_INFO' => uri })
46
+ end
47
+
48
+ def self.my_call_i(uri)
49
+ call({ 'PATH_INFO' => uri }).body[0].to_i
50
+ end
50
51
  end
51
52
 
52
53
  class Temp < Zorglub::Node
53
54
  end
54
55
 
55
56
  class Node0 < Zorglub::Node
56
- # default
57
- def index
58
- html
59
- end
60
- def hello
61
- no_layout!
62
- 'world'
63
- end
64
- def with_2args a1, a2
65
- end
66
- def do_render
67
- engine! 'real'
68
- end
69
- def do_content_type
70
- engine! 'real'
71
- response.header['Content-Type'] = 'text/mine'
72
- end
73
- def do_partial a1, a2
74
- engine! 'real'
75
- end
76
- def other_view
77
- engine! 'real'
78
- view! r('do_partial')
79
- end
80
- def do_redirect
81
- redirect r(:do_partial,1,2,3)
82
- end
83
- def xml_file
84
- no_layout!
85
- engine! :file
86
- ext! 'xml'
87
- mime! 'application/xml'
88
- end
89
- def plain_file
90
- no_layout!
91
- engine! :file
92
- ext! 'txt'
93
- mime! 'text/plain'
94
- end
95
- def no_view_no_layout
96
- no_view!
97
- no_layout!
98
- 'hello world'
99
- end
100
- def engines name
101
- no_layout!
102
- case name
103
- when 'haml'
104
- engine! :haml
105
- when 'sass'
106
- engine! :sass
107
- end
108
- end
57
+ # default
58
+ def index
59
+ html
60
+ end
61
+
62
+ def hello
63
+ no_layout!
64
+ 'world'
65
+ end
66
+
67
+ def with_2args(arg1, arg2); end
68
+
69
+ def do_render
70
+ engine! 'real'
71
+ end
72
+
73
+ def do_content_type
74
+ engine! 'real'
75
+ response.headers['Content-Type'] = 'text/mine'
76
+ end
77
+
78
+ def do_partial(_arg1, _arg2)
79
+ engine! 'real'
80
+ end
81
+
82
+ def other_view
83
+ engine! 'real'
84
+ view! r('do_partial')
85
+ end
86
+
87
+ def do_redirect
88
+ redirect r(:do_partial, 1, 2, 3)
89
+ end
90
+
91
+ def xml_file
92
+ no_layout!
93
+ engine! :file
94
+ ext! 'xml'
95
+ mime! 'application/xml'
96
+ end
97
+
98
+ def plain_file
99
+ no_layout!
100
+ engine! :file
101
+ ext! 'txt'
102
+ mime! 'text/plain'
103
+ end
104
+
105
+ def no_view_no_layout
106
+ no_view!
107
+ no_layout!
108
+ 'hello world'
109
+ end
110
+
111
+ def engines(name)
112
+ no_layout!
113
+ case name
114
+ when 'haml'
115
+ @name = '<i>world</i>'
116
+ engine! :haml
117
+ when 'sass'
118
+ engine! :sass
119
+ end
120
+ end
109
121
  end
110
122
 
111
123
  class Node1 < Zorglub::Node
112
- layout! 'layout-1'
113
- engine! 'engine-1'
114
- def index
115
- layout! 'main'
116
- engine! 'engine-2'
117
- end
124
+ layout! 'layout-1'
125
+ engine! 'engine-1'
126
+ def index
127
+ layout! 'main'
128
+ engine! 'engine-2'
129
+ end
118
130
  end
119
131
 
120
132
  class Node2 < Node1
121
- # inherited from Node1
133
+ # inherited from Node1
122
134
  end
123
135
 
124
136
  class Node3 < Zorglub::Node
125
- @before=0
126
- @after=0
127
- class << self
128
- attr_accessor :before, :after
129
- def post obj
130
- @after +=1
131
- end
132
- end
133
- before_all do |node|
134
- Node3.before +=1
135
- end
136
- after_all Node3.method(:post)
137
- layout! 'layout-2'
138
- engine! 'engine-2'
139
- def index
140
- Node3.before-Node3.after
141
- end
142
- def do_partial a1, a2
143
- view! Node0.r('do_partial')
144
- engine! 'real'
145
- end
137
+ @before = 0
138
+ @after = 0
139
+ class << self
140
+ attr_accessor :before, :after
141
+
142
+ def post(_obj)
143
+ @after += 1
144
+ end
145
+ end
146
+ before_all do |_node|
147
+ Node3.before += 1
148
+ end
149
+ after_all Node3.method(:post)
150
+ layout! 'layout-2'
151
+ engine! 'engine-2'
152
+ def index
153
+ Node3.before - Node3.after
154
+ end
155
+
156
+ def do_partial(_arg1, _arg2)
157
+ view! Node0.r('do_partial')
158
+ engine! 'real'
159
+ end
146
160
  end
147
161
 
148
162
  class Node8 < Node3
149
163
  end
150
164
 
151
165
  class Node4 < Zorglub::Node
152
- no_layout!
153
- cli_val :js,'js0'
154
- cli_val :js,'js1'
155
- def index
156
- cli_val(:js).to_yaml
157
- end
158
- def more
159
- cli_val :js,'js2'
160
- cli_val(:js).to_yaml
161
- end
166
+ no_layout!
167
+ cli_val :js, 'js0'
168
+ cli_val :js, 'js1'
169
+
170
+ def index
171
+ cli_val(:js).to_yaml
172
+ end
173
+
174
+ def more
175
+ cli_val :js, 'js2'
176
+ cli_val(:js).to_yaml
177
+ end
162
178
  end
163
179
 
164
180
  class Node5 < Node4
165
- cli_val :js, 'js3'
166
- cli_val :css, 'css0', 'css1'
167
- # no_layout! inherited from Node4
168
- def index
169
- js = cli_val(:js,'jsx')
170
- cli_val(:css, 'css0', 'css1','css2')
171
- css = cli_val :css
172
- js.concat(css).to_yaml
173
- end
181
+ cli_val :js, 'js3'
182
+ cli_val :css, 'css0', 'css1'
183
+ # no_layout! inherited from Node4
184
+ def index
185
+ js = cli_val(:js, 'jsx')
186
+ cli_val(:css, 'css0', 'css1', 'css2')
187
+ css = cli_val :css
188
+ js.concat(css).to_yaml
189
+ end
174
190
  end
175
191
 
176
192
  class Node6 < Zorglub::Node
177
- @static_cpt=0
178
- class << self
179
- attr_accessor :static_cpt
180
- end
181
- attr_reader :value
182
- static! true, 5
183
- def no_static
184
- static! false
185
- engine! 'static'
186
- view! Node0.r('do_render')
187
- Node6.static_cpt+=1
188
- @value = Node6.static_cpt
189
- end
190
- def do_static
191
- engine! 'static'
192
- view! Node0.r('do_render')
193
- Node6.static_cpt+=1
194
- @value = Node6.static_cpt
195
- end
193
+ @static_cpt = 0
194
+ class << self
195
+ attr_accessor :static_cpt
196
+ end
197
+ attr_reader :value
198
+
199
+ static! true, 5
200
+ def no_static
201
+ static! false
202
+ engine! 'static'
203
+ view! Node0.r('do_render')
204
+ Node6.static_cpt += 1
205
+ @value = Node6.static_cpt
206
+ end
207
+
208
+ def do_static
209
+ engine! 'static'
210
+ view! Node0.r('do_render')
211
+ Node6.static_cpt += 1
212
+ @value = Node6.static_cpt
213
+ end
196
214
  end
197
215
 
198
216
  class Node7 < Zorglub::Node
199
- layout_base_path! File.join APP_ROOT, 'alt','layout'
200
- view_base_path! File.join APP_ROOT, 'alt'
201
- def view_path
202
- view! 'do_render'
203
- end
217
+ layout_base_path! File.join APP_ROOT, 'alt', 'layout'
218
+ view_base_path! File.join APP_ROOT, 'alt'
219
+ def view_path
220
+ view! 'do_render'
221
+ end
204
222
  end
205
223
 
206
224
  APP = Zorglub::App.new do
207
- register_engine! :file, nil, Zorglub::Engines::File.method(:proc)
208
- register_engine! :haml, 'haml', Zorglub::Engines::Haml.method(:proc)
209
- register_engine! :sass, 'scss', Zorglub::Engines::Sass.method(:proc)
210
- register_engine! 'default', nil, HASH_PROC
211
- register_engine! 'engine-1', 'spec', HASH_PROC
212
- register_engine! 'engine-2', 'spec', HASH_PROC
213
- register_engine! 'real', nil, RENDER_PROC
214
- register_engine! 'static', nil, STATIC_PROC
215
- opt! :root, APP_ROOT
216
- opt! :engine, 'default'
217
- map '/node0', Node0
218
- map '/node1', Node1
219
- map '/node3', Node3
220
- map '/node4', Node4
221
- map '/node5', Node5
222
- map '/node6', Node6
223
- map '/node7', Node7
224
- map '/node8', Node8
225
+ register_engine! :file, nil, Zorglub::Engines::File.method(:proc)
226
+ register_engine! :haml, 'haml', Zorglub::Engines::Haml.method(:proc)
227
+ register_engine! :sass, 'scss', Zorglub::Engines::Sass.method(:proc)
228
+ register_engine! 'default', nil, HASH_PROC
229
+ register_engine! 'engine-1', 'spec', HASH_PROC
230
+ register_engine! 'engine-2', 'spec', HASH_PROC
231
+ register_engine! 'real', nil, RENDER_PROC
232
+ register_engine! 'static', nil, STATIC_PROC
233
+ opt! :root, APP_ROOT
234
+ opt! :engine, 'default'
235
+ map '/node0', Node0
236
+ map '/node1', Node1
237
+ map '/node3', Node3
238
+ map '/node4', Node4
239
+ map '/node5', Node5
240
+ map '/node6', Node6
241
+ map '/node7', Node7
242
+ map '/node8', Node8
225
243
  end
226
244
 
227
245
  class Node2
228
- map APP, '/node2'
246
+ map APP, '/node2'
229
247
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zorglub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jérémy Zurcher
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-01 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a very stripped down version of innate.
14
14
  email:
@@ -59,7 +59,7 @@ files:
59
59
  homepage: http://github.com/jeremyz/zorglub
60
60
  licenses: []
61
61
  metadata: {}
62
- post_install_message:
62
+ post_install_message:
63
63
  rdoc_options: []
64
64
  require_paths:
65
65
  - lib
@@ -74,9 +74,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubyforge_project:
78
- rubygems_version: 2.7.7
79
- signing_key:
77
+ rubygems_version: 3.4.19
78
+ signing_key:
80
79
  specification_version: 4
81
80
  summary: a nano web application framework based on rack
82
81
  test_files: