zorglub 0.1.0 → 0.1.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.
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,223 @@ 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
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
+ engine! :haml
116
+ when 'sass'
117
+ engine! :sass
108
118
  end
119
+ end
109
120
  end
110
121
 
111
122
  class Node1 < Zorglub::Node
112
- layout! 'layout-1'
113
- engine! 'engine-1'
114
- def index
115
- layout! 'main'
116
- engine! 'engine-2'
117
- end
123
+ layout! 'layout-1'
124
+ engine! 'engine-1'
125
+ def index
126
+ layout! 'main'
127
+ engine! 'engine-2'
128
+ end
118
129
  end
119
130
 
120
131
  class Node2 < Node1
121
- # inherited from Node1
132
+ # inherited from Node1
122
133
  end
123
134
 
124
135
  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
136
+ @before = 0
137
+ @after = 0
138
+ class << self
139
+ attr_accessor :before, :after
140
+
141
+ def post(_obj)
142
+ @after += 1
143
+ end
144
+ end
145
+ before_all do |_node|
146
+ Node3.before += 1
147
+ end
148
+ after_all Node3.method(:post)
149
+ layout! 'layout-2'
150
+ engine! 'engine-2'
151
+ def index
152
+ Node3.before - Node3.after
153
+ end
154
+
155
+ def do_partial(_arg1, _arg2)
156
+ view! Node0.r('do_partial')
157
+ engine! 'real'
158
+ end
146
159
  end
147
160
 
148
161
  class Node8 < Node3
149
162
  end
150
163
 
151
164
  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
165
+ no_layout!
166
+ cli_val :js, 'js0'
167
+ cli_val :js, 'js1'
168
+
169
+ def index
170
+ cli_val(:js).to_yaml
171
+ end
172
+
173
+ def more
174
+ cli_val :js, 'js2'
175
+ cli_val(:js).to_yaml
176
+ end
162
177
  end
163
178
 
164
179
  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
180
+ cli_val :js, 'js3'
181
+ cli_val :css, 'css0', 'css1'
182
+ # no_layout! inherited from Node4
183
+ def index
184
+ js = cli_val(:js, 'jsx')
185
+ cli_val(:css, 'css0', 'css1', 'css2')
186
+ css = cli_val :css
187
+ js.concat(css).to_yaml
188
+ end
174
189
  end
175
190
 
176
191
  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
192
+ @static_cpt = 0
193
+ class << self
194
+ attr_accessor :static_cpt
195
+ end
196
+ attr_reader :value
197
+
198
+ static! true, 5
199
+ def no_static
200
+ static! false
201
+ engine! 'static'
202
+ view! Node0.r('do_render')
203
+ Node6.static_cpt += 1
204
+ @value = Node6.static_cpt
205
+ end
206
+
207
+ def do_static
208
+ engine! 'static'
209
+ view! Node0.r('do_render')
210
+ Node6.static_cpt += 1
211
+ @value = Node6.static_cpt
212
+ end
196
213
  end
197
214
 
198
215
  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
216
+ layout_base_path! File.join APP_ROOT, 'alt', 'layout'
217
+ view_base_path! File.join APP_ROOT, 'alt'
218
+ def view_path
219
+ view! 'do_render'
220
+ end
204
221
  end
205
222
 
206
223
  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
224
+ register_engine! :file, nil, Zorglub::Engines::File.method(:proc)
225
+ register_engine! :haml, 'haml', Zorglub::Engines::Haml.method(:proc)
226
+ register_engine! :sass, 'scss', Zorglub::Engines::Sass.method(:proc)
227
+ register_engine! 'default', nil, HASH_PROC
228
+ register_engine! 'engine-1', 'spec', HASH_PROC
229
+ register_engine! 'engine-2', 'spec', HASH_PROC
230
+ register_engine! 'real', nil, RENDER_PROC
231
+ register_engine! 'static', nil, STATIC_PROC
232
+ opt! :root, APP_ROOT
233
+ opt! :engine, 'default'
234
+ map '/node0', Node0
235
+ map '/node1', Node1
236
+ map '/node3', Node3
237
+ map '/node4', Node4
238
+ map '/node5', Node5
239
+ map '/node6', Node6
240
+ map '/node7', Node7
241
+ map '/node8', Node8
225
242
  end
226
243
 
227
244
  class Node2
228
- map APP, '/node2'
245
+ map APP, '/node2'
229
246
  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.1
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: