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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0219f50bb07d3009172295d5a5dab9c055cd379475d9a4d292f4938459c4fb8f'
4
- data.tar.gz: 224611e8b174fcf26fbd27e2e72beb80adb8562ce9d945a699bbc76fbd976e73
3
+ metadata.gz: 68a4bd30558640ea906ace0e87f4710be024e9f75dc2013bccba2954a146c994
4
+ data.tar.gz: c48af64abd895f0cb2c3514442c151ec92e7b59b1312fe4cfa9440e7a81bb610
5
5
  SHA512:
6
- metadata.gz: f532761158fdb87b7dbd38eb12882158bbab72a4551861c02a7c88a2776f25ecc455c026ec675198853aee6423bcdfcaeca7f3e17a323fc82deff4a629362251
7
- data.tar.gz: 660122838f1de84f1ab75ae0788ea8160ba47be3fa3d3f8d3bf9d7fce3ae12270cc704a6b2eae3669a154aac9d33809d1e7a466669eac7d6e6256c22b70e3e9b
6
+ metadata.gz: 73a4fbea322ebe7bbccdf7433ceb726fe3e0afd69edf8db947342c0f9905d82c523b96eee283949dfbb7850bc6f76b1973e85f59e149b5c8058aff36411dfcdc
7
+ data.tar.gz: e52eb20c1e9a71c7a4b993c8285f0a3652d7358c0fbe9e541727df6139f9d3279a7338156c6710fc13e17b6686c9ab40026ec768f34fc673c9043b7177ba881a
data/Gemfile CHANGED
@@ -12,7 +12,7 @@ end
12
12
 
13
13
  group :test, :development do
14
14
  gem 'haml'
15
- gem 'sass'
15
+ gem 'sassc'
16
16
  end
17
17
 
18
18
  gem 'coveralls', require: false
data/Gemfile.lock CHANGED
@@ -6,53 +6,52 @@ PATH
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- coveralls (0.8.22)
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 (~> 0.19.4)
14
+ thor (>= 0.19.4, < 2.0)
14
15
  tins (~> 1.6)
15
- diff-lcs (1.3)
16
- docile (1.3.1)
17
- ffi (1.9.25)
18
- haml (5.0.4)
19
- temple (>= 0.8.0)
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.1.0)
22
- rack (2.0.6)
23
- rake (12.3.2)
24
- rb-fsevent (0.10.3)
25
- rb-inotify (0.10.0)
26
- ffi (~> 1.0)
27
- rspec (3.8.0)
28
- rspec-core (~> 3.8.0)
29
- rspec-expectations (~> 3.8.0)
30
- rspec-mocks (~> 3.8.0)
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.8.0)
36
- rspec-mocks (3.8.0)
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.8.0)
39
- rspec-support (3.8.0)
40
- sass (3.7.2)
41
- sass-listen (~> 4.0.0)
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
- temple (0.8.0)
51
- term-ansicolor (1.7.0)
46
+ sync (0.5.0)
47
+ temple (0.10.3)
48
+ term-ansicolor (1.11.2)
52
49
  tins (~> 1.0)
53
- thor (0.19.4)
54
- tilt (2.0.9)
55
- tins (1.20.2)
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
- sass
65
+ sassc
67
66
  zorglub!
68
67
 
69
68
  BUNDLED WITH
70
- 1.17.3
69
+ 2.5.17
data/lib/zorglub/app.rb CHANGED
@@ -1,112 +1,114 @@
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
+ escape_html: false
23
+ },
24
+ sass_options: {
25
+ syntax: :scss,
26
+ cache: false,
27
+ style: :compressed
28
+ },
29
+ session_options: {
30
+ enabled: false,
31
+ key: 'zorglub.sid',
32
+ secret: 'session-secret-secret',
33
+ sid_len: 64
34
+ }
35
+ }
36
+ instance_eval(&block) if block_given?
37
+ remap @map
38
+ end
39
+
40
+ attr_reader :engines_cache
41
+
42
+ def map(location, object)
43
+ return unless location && object
44
+ raise StandardError, "#{@map[location]} already mapped to #{location}" if @map.key? location
45
+
46
+ object.app = self
47
+ @map.merge! location.to_s => object
48
+ remap @map
49
+ end
50
+
51
+ def delete(location)
52
+ @map.delete location
53
+ remap @map
54
+ end
55
+
56
+ def at(location)
57
+ @map[location]
58
+ end
59
+
60
+ def to(object)
61
+ @map.invert[object]
62
+ end
63
+
64
+ def to_hash
65
+ @map.dup
66
+ end
67
+
68
+ # OPTIONS @options
69
+
70
+ def opt(sym)
71
+ @options[sym]
72
+ end
73
+
74
+ def opt!(sym, val)
75
+ @options[sym] = val
76
+ end
77
+
78
+ def register_engine!(name, ext, proc)
79
+ x = if ext.nil? || ext.empty?
80
+ nil
81
+ elsif ext[0] == '.'
82
+ ext.length == 1 ? nil : ext
83
+ else
84
+ ".#{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
+
93
+ [p, ext.nil? || ext.empty? ? x : ext]
94
+ end
95
+
96
+ def view_base_path
97
+ _base_path @options[:view_path], :view_dir
98
+ end
99
+
100
+ def layout_base_path
101
+ _base_path @options[:layout_path], :layout_dir
102
+ end
103
+
104
+ def static_base_path
105
+ _base_path @options[:static_path], :static_dir
106
+ end
107
+
108
+ private
6
109
 
7
- class App < Rack::URLMap
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
110
+ def _base_path(path, sym)
111
+ path.nil? ? File.join(@options[:root], @options[sym]) : path
111
112
  end
113
+ end
112
114
  end
@@ -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
- module Engines
8
- module File
9
- def self.proc path,obj
10
- content = ::File.open(path,'r'){|f| f.read }
11
- ext = path.sub /.*\.(.+)$/,'\1'
12
- return content, "text/#{ext}"
13
- end
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
@@ -1,23 +1,19 @@
1
- # -*- coding: UTF-8 -*-
2
-
3
1
  require 'haml/util'
4
- require 'haml/engine'
2
+ require 'haml/template'
5
3
 
6
4
  module Zorglub
7
- module Engines
8
- module Haml
9
- def self.proc path,obj
10
- if obj.app.opt(:engines_cache_enabled)
11
- key = path.sub obj.app.opt(:root),''
12
- haml = obj.app.engines_cache[key] ||= ::Haml::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:haml_options) )
13
- else
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
+ if obj.app.opt(:engines_cache_enabled)
9
+ key = path.sub obj.app.opt(:root), ''
10
+ haml = obj.app.engines_cache[key] || ::Haml::Template.new(obj.app.opt(:haml_options)) { ::File.read(path) }
11
+ else
12
+ haml = ::Haml::Template.new(obj.app.opt(:haml_options)) { ::File.read(path) }
19
13
  end
14
+ html = haml.render(obj)
15
+ [html, 'text/html']
16
+ end
20
17
  end
18
+ end
21
19
  end
22
-
23
- # EOF
@@ -1,22 +1,18 @@
1
- # -*- coding: UTF-8 -*-
2
-
3
1
  require 'sass'
4
2
 
5
3
  module Zorglub
6
- module Engines
7
- module Sass
8
- def self.proc path,obj
9
- if obj.app.opt(:engines_cache_enabled)
10
- key = path.sub obj.app.opt(:root),''
11
- sass = obj.app.engines_cache[key] ||= ::Sass::Engine.new( ::File.open(path,'r'){|f| f.read }, obj.app.opt(:sass_options) )
12
- else
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
+ if obj.app.opt(:engines_cache_enabled)
8
+ key = path.sub obj.app.opt(:root), ''
9
+ sass = obj.app.engines_cache[key] || ::Sass::Engine.new(::File.read(path), obj.app.opt(:sass_options))
10
+ else
11
+ sass = ::Sass::Engine.new(::File.read(path), obj.app.opt(:sass_options))
18
12
  end
13
+ css = sass.render
14
+ [css, 'text/css']
15
+ end
19
16
  end
17
+ end
20
18
  end
21
-
22
- # EOF