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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +35 -36
- data/lib/zorglub/app.rb +107 -106
- data/lib/zorglub/engines/file.rb +8 -12
- data/lib/zorglub/engines/haml.rb +12 -17
- data/lib/zorglub/engines/sass.rb +11 -16
- data/lib/zorglub/node.rb +273 -273
- data/lib/zorglub/rack_session.rb +4 -6
- data/lib/zorglub/session.rb +142 -146
- data/lib/zorglub.rb +1 -4
- data/spec/app_spec.rb +26 -32
- data/spec/node_spec.rb +298 -304
- data/spec/spec_helper.rb +187 -170
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e7dee8a5205c1f0f2b8be300b2bb68251dbef0f762020332bcf47850bba7323
|
4
|
+
data.tar.gz: 169f7bd5d713d86544d83307fba364876ea6c2326bc2d31c551843854ec340f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09cd0d8cbcdacf01223de522e97d64d3bbb50606f3f50006edcd50150724e0c4cf55d1bc7e65e3fd02ba93d56c4d002470453f64ba39d256081e8936ec59b8b9'
|
7
|
+
data.tar.gz: cfe3dbb427f4a3a488d5c6a0f111bd9723b244fe18925944eced6fa0c9774206e5987f4d19c0ad24db41ee304760aec0e7bf3825642da98c7aa0e38f6e23d76f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,53 +6,52 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
9
|
+
bigdecimal (3.1.8)
|
10
|
+
coveralls (0.8.23)
|
10
11
|
json (>= 1.8, < 3)
|
11
12
|
simplecov (~> 0.16.1)
|
12
13
|
term-ansicolor (~> 1.3)
|
13
|
-
thor (
|
14
|
+
thor (>= 0.19.4, < 2.0)
|
14
15
|
tins (~> 1.6)
|
15
|
-
diff-lcs (1.
|
16
|
-
docile (1.
|
17
|
-
ffi (1.
|
18
|
-
haml (
|
19
|
-
temple (>= 0.8.
|
16
|
+
diff-lcs (1.5.1)
|
17
|
+
docile (1.4.1)
|
18
|
+
ffi (1.17.0)
|
19
|
+
haml (6.3.0)
|
20
|
+
temple (>= 0.8.2)
|
21
|
+
thor
|
20
22
|
tilt
|
21
|
-
json (2.
|
22
|
-
rack (
|
23
|
-
rake (
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rspec-
|
30
|
-
|
31
|
-
rspec-core (3.8.0)
|
32
|
-
rspec-support (~> 3.8.0)
|
33
|
-
rspec-expectations (3.8.2)
|
23
|
+
json (2.7.2)
|
24
|
+
rack (3.1.7)
|
25
|
+
rake (13.2.1)
|
26
|
+
rspec (3.13.0)
|
27
|
+
rspec-core (~> 3.13.0)
|
28
|
+
rspec-expectations (~> 3.13.0)
|
29
|
+
rspec-mocks (~> 3.13.0)
|
30
|
+
rspec-core (3.13.0)
|
31
|
+
rspec-support (~> 3.13.0)
|
32
|
+
rspec-expectations (3.13.1)
|
34
33
|
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.
|
36
|
-
rspec-mocks (3.
|
34
|
+
rspec-support (~> 3.13.0)
|
35
|
+
rspec-mocks (3.13.1)
|
37
36
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.
|
39
|
-
rspec-support (3.
|
40
|
-
|
41
|
-
|
42
|
-
sass-listen (4.0.0)
|
43
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
44
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
37
|
+
rspec-support (~> 3.13.0)
|
38
|
+
rspec-support (3.13.1)
|
39
|
+
sassc (2.4.0)
|
40
|
+
ffi (~> 1.9)
|
45
41
|
simplecov (0.16.1)
|
46
42
|
docile (~> 1.1)
|
47
43
|
json (>= 1.8, < 3)
|
48
44
|
simplecov-html (~> 0.10.0)
|
49
45
|
simplecov-html (0.10.2)
|
50
|
-
|
51
|
-
|
46
|
+
sync (0.5.0)
|
47
|
+
temple (0.10.3)
|
48
|
+
term-ansicolor (1.11.2)
|
52
49
|
tins (~> 1.0)
|
53
|
-
thor (
|
54
|
-
tilt (2.0
|
55
|
-
tins (1.
|
50
|
+
thor (1.3.1)
|
51
|
+
tilt (2.4.0)
|
52
|
+
tins (1.33.0)
|
53
|
+
bigdecimal
|
54
|
+
sync
|
56
55
|
|
57
56
|
PLATFORMS
|
58
57
|
ruby
|
@@ -63,8 +62,8 @@ DEPENDENCIES
|
|
63
62
|
rack
|
64
63
|
rake
|
65
64
|
rspec
|
66
|
-
|
65
|
+
sassc
|
67
66
|
zorglub!
|
68
67
|
|
69
68
|
BUNDLED WITH
|
70
|
-
|
69
|
+
2.5.17
|
data/lib/zorglub/app.rb
CHANGED
@@ -1,112 +1,113 @@
|
|
1
|
-
# -*- coding: UTF-8 -*-
|
2
|
-
|
3
1
|
require 'rack'
|
4
2
|
|
5
3
|
module Zorglub
|
4
|
+
class App < Rack::URLMap
|
5
|
+
def initialize(map = {}, &block)
|
6
|
+
super
|
7
|
+
@map = map
|
8
|
+
@engines_cache = {}
|
9
|
+
@options = {
|
10
|
+
debug: false,
|
11
|
+
root: '.',
|
12
|
+
layout: 'default',
|
13
|
+
view_dir: 'view',
|
14
|
+
layout_dir: 'layout',
|
15
|
+
static_dir: 'static',
|
16
|
+
engine: nil,
|
17
|
+
engines_cache_enabled: true,
|
18
|
+
engines: {},
|
19
|
+
haml_options: {
|
20
|
+
format: :html5,
|
21
|
+
encoding: 'utf-8'
|
22
|
+
},
|
23
|
+
sass_options: {
|
24
|
+
syntax: :scss,
|
25
|
+
cache: false,
|
26
|
+
style: :compressed
|
27
|
+
},
|
28
|
+
session_options: {
|
29
|
+
enabled: false,
|
30
|
+
key: 'zorglub.sid',
|
31
|
+
secret: 'session-secret-secret',
|
32
|
+
sid_len: 64
|
33
|
+
}
|
34
|
+
}
|
35
|
+
instance_eval(&block) if block_given?
|
36
|
+
remap @map
|
37
|
+
end
|
38
|
+
|
39
|
+
attr_reader :engines_cache
|
40
|
+
|
41
|
+
def map(location, object)
|
42
|
+
return unless location && object
|
43
|
+
raise StandardError, "#{@map[location]} already mapped to #{location}" if @map.key? location
|
44
|
+
|
45
|
+
object.app = self
|
46
|
+
@map.merge! location.to_s => object
|
47
|
+
remap @map
|
48
|
+
end
|
49
|
+
|
50
|
+
def delete(location)
|
51
|
+
@map.delete location
|
52
|
+
remap @map
|
53
|
+
end
|
54
|
+
|
55
|
+
def at(location)
|
56
|
+
@map[location]
|
57
|
+
end
|
58
|
+
|
59
|
+
def to(object)
|
60
|
+
@map.invert[object]
|
61
|
+
end
|
62
|
+
|
63
|
+
def to_hash
|
64
|
+
@map.dup
|
65
|
+
end
|
66
|
+
|
67
|
+
# OPTIONS @options
|
68
|
+
|
69
|
+
def opt(sym)
|
70
|
+
@options[sym]
|
71
|
+
end
|
72
|
+
|
73
|
+
def opt!(sym, val)
|
74
|
+
@options[sym] = val
|
75
|
+
end
|
76
|
+
|
77
|
+
def register_engine!(name, ext, proc)
|
78
|
+
x = if ext.nil? || ext.empty?
|
79
|
+
nil
|
80
|
+
elsif ext[0] == '.'
|
81
|
+
ext.length == 1 ? nil : ext
|
82
|
+
else
|
83
|
+
".#{ext}"
|
84
|
+
end
|
85
|
+
@options[:engines][name] = [proc, x]
|
86
|
+
end
|
87
|
+
|
88
|
+
def engine_proc_ext(engine, ext)
|
89
|
+
p, x = @options[:engines][engine]
|
90
|
+
return [nil, ''] if p.nil?
|
91
|
+
|
92
|
+
[p, ext.nil? || ext.empty? ? x : ext]
|
93
|
+
end
|
94
|
+
|
95
|
+
def view_base_path
|
96
|
+
_base_path @options[:view_path], :view_dir
|
97
|
+
end
|
98
|
+
|
99
|
+
def layout_base_path
|
100
|
+
_base_path @options[:layout_path], :layout_dir
|
101
|
+
end
|
102
|
+
|
103
|
+
def static_base_path
|
104
|
+
_base_path @options[:static_path], :static_dir
|
105
|
+
end
|
106
|
+
|
107
|
+
private
|
6
108
|
|
7
|
-
|
8
|
-
|
9
|
-
def initialize map={}, &block
|
10
|
-
super
|
11
|
-
@map = map
|
12
|
-
@engines_cache = { }
|
13
|
-
@options = {
|
14
|
-
:debug => false,
|
15
|
-
:root => '.',
|
16
|
-
:layout => 'default',
|
17
|
-
:view_dir => 'view',
|
18
|
-
:layout_dir => 'layout',
|
19
|
-
:static_dir => 'static',
|
20
|
-
:engine => nil,
|
21
|
-
:engines_cache_enabled => true,
|
22
|
-
:engines => { },
|
23
|
-
:haml_options => {
|
24
|
-
:format => :html5,
|
25
|
-
:encoding => 'utf-8'
|
26
|
-
},
|
27
|
-
:sass_options => {
|
28
|
-
:syntax => :scss,
|
29
|
-
:cache => :false,
|
30
|
-
:style => :compressed
|
31
|
-
},
|
32
|
-
:session_options => {
|
33
|
-
:enabled => false,
|
34
|
-
:key => 'zorglub.sid',
|
35
|
-
:secret => 'session-secret-secret',
|
36
|
-
:sid_len => 64
|
37
|
-
}
|
38
|
-
}
|
39
|
-
instance_eval &block if block_given?
|
40
|
-
remap @map
|
41
|
-
end
|
42
|
-
|
43
|
-
attr_reader :engines_cache
|
44
|
-
|
45
|
-
def map location, object
|
46
|
-
return unless location and object
|
47
|
-
raise Exception.new "#{@map[location]} already mapped to #{location}" if @map.has_key? location
|
48
|
-
object.app = self
|
49
|
-
@map.merge! location.to_s=>object
|
50
|
-
remap @map
|
51
|
-
end
|
52
|
-
|
53
|
-
def delete location
|
54
|
-
@map.delete location
|
55
|
-
remap @map
|
56
|
-
end
|
57
|
-
|
58
|
-
def at location
|
59
|
-
@map[location]
|
60
|
-
end
|
61
|
-
|
62
|
-
def to object
|
63
|
-
@map.invert[object]
|
64
|
-
end
|
65
|
-
|
66
|
-
def to_hash
|
67
|
-
@map.dup
|
68
|
-
end
|
69
|
-
|
70
|
-
# OPTIONS @options
|
71
|
-
|
72
|
-
def opt sym
|
73
|
-
@options[sym]
|
74
|
-
end
|
75
|
-
|
76
|
-
def opt! sym, val
|
77
|
-
@options[sym] = val
|
78
|
-
end
|
79
|
-
|
80
|
-
def register_engine! name, ext, proc
|
81
|
-
if ext.nil? or ext.empty?
|
82
|
-
x = nil
|
83
|
-
else
|
84
|
-
x = (ext[0]=='.' ? (ext.length==1 ? nil : ext) : '.' + ext)
|
85
|
-
end
|
86
|
-
@options[:engines][name]=[ proc, x ]
|
87
|
-
end
|
88
|
-
|
89
|
-
def engine_proc_ext engine, ext
|
90
|
-
p,x = @options[:engines][engine]
|
91
|
-
return [nil, ''] if p.nil?
|
92
|
-
[ p, ((ext.nil? or ext.empty?) ? x : ext ) ]
|
93
|
-
end
|
94
|
-
|
95
|
-
def view_base_path
|
96
|
-
_base_path @options[:view_path], :view_dir
|
97
|
-
end
|
98
|
-
|
99
|
-
def layout_base_path
|
100
|
-
_base_path @options[:layout_path], :layout_dir
|
101
|
-
end
|
102
|
-
|
103
|
-
def static_base_path
|
104
|
-
_base_path @options[:static_path], :static_dir
|
105
|
-
end
|
106
|
-
|
107
|
-
private
|
108
|
-
def _base_path p, sym
|
109
|
-
( p.nil? ? File.join(@options[:root], @options[sym]) : p )
|
110
|
-
end
|
109
|
+
def _base_path(path, sym)
|
110
|
+
path.nil? ? File.join(@options[:root], @options[sym]) : path
|
111
111
|
end
|
112
|
+
end
|
112
113
|
end
|
data/lib/zorglub/engines/file.rb
CHANGED
@@ -1,18 +1,14 @@
|
|
1
|
-
# -*- coding: UTF-8 -*-
|
2
|
-
|
3
1
|
require 'haml/util'
|
4
2
|
require 'haml/engine'
|
5
3
|
|
6
4
|
module Zorglub
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
5
|
+
module Engines
|
6
|
+
module File
|
7
|
+
def self.proc(path, _obj)
|
8
|
+
content = ::File.read(path)
|
9
|
+
ext = path.sub(/.*\.(.+)$/, '\1')
|
10
|
+
[content, "text/#{ext}"]
|
11
|
+
end
|
15
12
|
end
|
13
|
+
end
|
16
14
|
end
|
17
|
-
|
18
|
-
# EOF
|
data/lib/zorglub/engines/haml.rb
CHANGED
@@ -1,23 +1,18 @@
|
|
1
|
-
# -*- coding: UTF-8 -*-
|
2
|
-
|
3
1
|
require 'haml/util'
|
4
|
-
require 'haml/
|
2
|
+
require 'haml/template'
|
5
3
|
|
6
4
|
module Zorglub
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
haml = ::Haml::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:haml_options) )
|
15
|
-
end
|
16
|
-
html = haml.render(obj)
|
17
|
-
return html, 'text/html'
|
18
|
-
end
|
5
|
+
module Engines
|
6
|
+
module Haml
|
7
|
+
def self.proc(path, obj)
|
8
|
+
haml = ::Haml::Template.new(path)
|
9
|
+
if obj.app.opt(:engines_cache_enabled)
|
10
|
+
key = path.sub obj.app.opt(:root), ''
|
11
|
+
obj.app.engines_cache[key] ||= haml
|
19
12
|
end
|
13
|
+
html = haml.render(obj, obj.app.opt(:haml_options))
|
14
|
+
[html, 'text/html']
|
15
|
+
end
|
20
16
|
end
|
17
|
+
end
|
21
18
|
end
|
22
|
-
|
23
|
-
# EOF
|
data/lib/zorglub/engines/sass.rb
CHANGED
@@ -1,22 +1,17 @@
|
|
1
|
-
# -*- coding: UTF-8 -*-
|
2
|
-
|
3
1
|
require 'sass'
|
4
2
|
|
5
3
|
module Zorglub
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
sass = ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) )
|
14
|
-
end
|
15
|
-
css = sass.render
|
16
|
-
return css, 'text/css'
|
17
|
-
end
|
4
|
+
module Engines
|
5
|
+
module Sass
|
6
|
+
def self.proc(path, obj)
|
7
|
+
sass = ::Sass::Engine.new(::File.read(path), obj.app.opt(:sass_options))
|
8
|
+
if obj.app.opt(:engines_cache_enabled)
|
9
|
+
key = path.sub obj.app.opt(:root), ''
|
10
|
+
obj.app.engines_cache[key] ||= sass
|
18
11
|
end
|
12
|
+
css = sass.render
|
13
|
+
[css, 'text/css']
|
14
|
+
end
|
19
15
|
end
|
16
|
+
end
|
20
17
|
end
|
21
|
-
|
22
|
-
# EOF
|