plezi 0.16.0 → 0.16.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09945baaea8ad6231605d6d6b72df2b66d369ca413709de0af5809a21e94d634'
4
- data.tar.gz: a1659a6945166b11210cd14bc5ba3d10e00cbae57fe8c5de20b6af6ab92dd876
3
+ metadata.gz: 45f6afcb048d7e718df8f9eced81ed797c6591656da5bdc961cb83becb1a1fd7
4
+ data.tar.gz: d99fba485b851dbf8c914e50c1e34d389e760981aaaf0d26249e098affb03e3e
5
5
  SHA512:
6
- metadata.gz: 768d697c97ef0eed692f993f1b19bee20021d809d02111aaa310c5b0c6fa67d70f5e64394db7f29889d968e544bae4126994f1b55402ea477815b5440b14219b
7
- data.tar.gz: b90e2722ae0b095b41a42769ed2e0d988d6042c41bafa9545e31740cd4316398d415c8dfb64fd6c0d3501687a9f6d494332d1eda0752ad7d9f42882bef38ac70
6
+ metadata.gz: 5f3daa504ea44e1fdf5f70ea0524fa39f79167fca6a1916232b3b21d7ce015e004e172e56987843150674c239151a2aef483325c675b0c432e9e986ebb675f7d
7
+ data.tar.gz: 2a0018cd9f6bc7717db68aafd7891f728023c8356db82627cafb8fbb04ce32481fe1914ca746cc91e9fa1cb96fdd73b6f72f6e9bfc7436e4adcb93303a83d4d4
@@ -2,6 +2,14 @@
2
2
 
3
3
  ***
4
4
 
5
+ Change log v.0.16.1
6
+
7
+ **Fix**: Fix the application boilerplate code, fixing a typo in the resulting `config.ru` which resulted in boilerplate code failing to execute. Credit to @namiwang (Nami WANG) for PR #28.
8
+
9
+ **Update**: Added support for SassC for assets routing.
10
+
11
+ ***
12
+
5
13
  Change log v.0.16.0
6
14
 
7
15
  **Update**: update gem dependency to utilize `iodine` 0.5.x versions.
data/exe/plezi CHANGED
@@ -75,6 +75,7 @@ module Builder
75
75
  app_tree['controllers'] ||= {}
76
76
  app_tree['controllers']['example.rb'] ||= IO.read(Root.join('resources', 'ctrlr.rb')).gsub('appname', app_name)
77
77
  app_tree['views'] ||= {}
78
+ app_tree['views']['assets'] ||= ''
78
79
  app_tree['views']['welcome.html.erb'] ||= IO.read(Root.join('resources', 'mini_welcome_page.html')).gsub('appname', app_name)
79
80
  app_tree['views']['404.html.erb'] ||= IO.read(Root.join('resources', '404.erb'))
80
81
  app_tree['views']['500.html.erb'] ||= IO.read(Root.join('resources', '500.erb'))
@@ -1,54 +1,54 @@
1
1
  require 'plezi/render/has_cache'
2
- # Redcarpet might not be available, if so, allow the require to throw it's exception.
3
- unless defined?(::Sass)
4
- begin
5
- require('sass')
6
- rescue Exception
2
+ # Support for Sass if SassC wasn't loaded.
3
+ unless defined?(::SassC)
4
+ unless defined?(::Sass)
5
+ begin
6
+ require('sass')
7
+ rescue Exception
7
8
 
9
+ end
8
10
  end
9
- end
10
-
11
- if defined?(::Sass)
12
-
13
- module Plezi
14
- module Base
15
- # This is a baker, not a renderer
16
- module BakeSASS
17
- extend HasCache
18
-
19
- module_function
20
-
21
- SASS_OPTIONS = { cache_store: Sass::CacheStores::Memory.new, style: (ENV['SASS_STYLE'] || ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? :compressed : :nested)) }.dup
22
11
 
23
- # Bakes the SASS for the requested target, if a SASS source file is found.
24
- def call(target)
25
- return self[target] if File.extname(target) == '.map'.freeze
26
- review_cache("#{target}.scss", target) || review_cache("#{target}.sass", target)
12
+ if defined?(::Sass)
13
+ module Plezi
14
+ module Base
15
+ # This is a baker, not a renderer
16
+ module BakeSASS
17
+ extend HasCache
18
+
19
+ module_function
20
+
21
+ SASS_OPTIONS = { cache_store: Sass::CacheStores::Memory.new, style: (ENV['SASS_STYLE'] || ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? :compressed : :nested)) }.dup
22
+
23
+ # Bakes the SASS for the requested target, if a SASS source file is found.
24
+ def call(target)
25
+ return self[target] if File.extname(target) == '.map'.freeze
26
+ review_cache("#{target}.scss", target) || review_cache("#{target}.sass", target)
27
+ end
28
+
29
+ def review_cache(filename, target)
30
+ return nil unless File.exist?(filename)
31
+ eng = self[filename]
32
+ return self[target] unless eng.nil? || refresh_sass?(filename)
33
+ self[filename] = (eng = Sass::Engine.for_file(filename, SASS_OPTIONS)).dependencies
34
+ map_name = "#{target}.map".freeze
35
+ css, map = eng.render_with_sourcemap(File.basename(map_name))
36
+ self[filename.to_sym] = Time.now
37
+ IO.write map_name, map.to_json(css_uri: File.basename(target))
38
+ self[target] = css
39
+ end
40
+
41
+ def refresh_sass?(sass)
42
+ mt = self[sass.to_sym]
43
+ return true if mt < File.mtime(sass)
44
+ self[sass].each { |e| return true if File.exist?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt) }
45
+ false
46
+ end
27
47
  end
28
48
 
29
- def review_cache(filename, target)
30
- return nil unless File.exist?(filename)
31
- eng = self[filename]
32
- return self[target] unless eng.nil? || refresh_sass?(filename)
33
- self[filename] = (eng = Sass::Engine.for_file(filename, SASS_OPTIONS)).dependencies
34
- map_name = "#{target}.map".freeze
35
- css, map = eng.render_with_sourcemap(File.basename(map_name))
36
- self[filename.to_sym] = Time.now
37
- IO.write map_name, map.to_json(css_uri: File.basename(target))
38
- self[target] = css
39
- end
40
-
41
- def refresh_sass?(sass)
42
- mt = self[sass.to_sym]
43
- return true if mt < File.mtime(sass)
44
- self[sass].each { |e| return true if File.exist?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt) }
45
- false
46
- end
49
+ ::Plezi::AssetBaker.register :css, ::Plezi::Base::BakeSASS
50
+ ::Plezi::AssetBaker.register :map, ::Plezi::Base::BakeSASS
47
51
  end
48
-
49
- ::Plezi::AssetBaker.register :css, ::Plezi::Base::BakeSASS
50
- ::Plezi::AssetBaker.register :map, ::Plezi::Base::BakeSASS
51
52
  end
52
53
  end
53
-
54
54
  end
@@ -0,0 +1,61 @@
1
+ require 'plezi/render/has_cache'
2
+ # Redcarpet might not be available, if so, allow the require to throw it's exception.
3
+ unless defined?(::SassC)
4
+ begin
5
+ require('sassc')
6
+ rescue Exception
7
+
8
+ end
9
+ end
10
+
11
+ if defined?(::SassC)
12
+
13
+ module Plezi
14
+ module Base
15
+ # This is a baker, not a renderer
16
+ module BakeSASS
17
+ extend HasCache
18
+
19
+ SCSSC_OPTIONS = { filename: :filename, source_map_file: ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? false : true), source_map_embed: ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? false : true), load_paths: :load_paths, style: (ENV['SASS_STYLE'] || ((ENV['ENV'] || ENV['RACK_ENV']) == 'production' ? :compressed : :nested)) }.dup
20
+
21
+ module_function
22
+
23
+ # Bakes the SASS for the requested target, if a SASS source file is found.
24
+ def call(target)
25
+ return self[target] if File.extname(target) == '.map'.freeze
26
+ load_target("#{target}.scss", target) || load_target("#{target}.sass", target)
27
+ end
28
+
29
+ def load_target(filename, target)
30
+ return nil unless File.exist?(filename)
31
+ eng = self[filename]
32
+ return self[target] unless eng.nil? || refresh_sass?(filename)
33
+ map_name = "#{target}.map".freeze
34
+ opt = SCSSC_OPTIONS.dup
35
+ opt[:source_map_file] = map_name if opt[:source_map_file]
36
+ opt[:filename] = filename
37
+ opt[:load_paths] = [ File.basename(target) ]
38
+ data = IO.binread(filename)
39
+ eng = SassC::Engine.new(data, opt)
40
+ css = eng.render
41
+ map = eng.source_map
42
+ self[filename] = eng.dependencies
43
+ self[filename.to_sym] = Time.now
44
+ IO.write map_name, map.to_json(css_uri: File.basename(target))
45
+ self[target] = css
46
+ end
47
+
48
+ def refresh_sass?(sass)
49
+ mt = self[sass.to_sym]
50
+ return true if mt < File.mtime(sass)
51
+ self[sass].each { |e| return true if File.exist?(e.options[:filename]) && (File.mtime(e.options[:filename]) > mt) }
52
+ false
53
+ end
54
+ end
55
+
56
+ ::Plezi::AssetBaker.register :css, ::Plezi::Base::BakeSASS
57
+ ::Plezi::AssetBaker.register :map, ::Plezi::Base::BakeSASS
58
+ end
59
+ end
60
+
61
+ end
@@ -63,4 +63,6 @@ module Plezi
63
63
  end
64
64
  end
65
65
  end
66
+
67
+ require 'plezi/render/sassc.rb'
66
68
  require 'plezi/render/sass.rb'
@@ -1,3 +1,3 @@
1
1
  module Plezi
2
- VERSION = '0.16.0'.freeze
2
+ VERSION = '0.16.1'.freeze
3
3
  end
@@ -3,6 +3,6 @@
3
3
  # load the application
4
4
  load ::File.expand_path(File.join('..', 'appname.rb'), __FILE__)
5
5
 
6
- Iodine::DEFAULT_HTTP_ARGS[:public] = ||= './public'
6
+ Iodine::DEFAULT_HTTP_ARGS[:public] ||= './public'
7
7
 
8
8
  run Plezi.app
@@ -31,5 +31,8 @@ ENV['PL_REDIS_URL'] ||= ENV['REDIS_URL'] ||
31
31
  # Map the views folder to the template root (for the {#render} function).
32
32
  Plezi.templates = Root.join('views').to_s
33
33
 
34
+ # Map the views/assets folder to the asset root (for the assets route).
35
+ Plezi.assets = Root.join('views/assets').to_s
36
+
34
37
  # load routes.
35
38
  load Root.join('routes.rb').to_s
@@ -17,5 +17,8 @@
17
17
 
18
18
  # Plezi.route "/:format" , /^(html|json|xml)$/
19
19
 
20
+ # An optional assets route:
21
+ # Plezi.route('/assets', :assets)
22
+
20
23
  # # The root Controller
21
24
  Plezi.route '/', ExampleCtrl
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plezi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boaz Segev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-11 00:00:00.000000000 Z
11
+ date: 2018-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iodine
@@ -123,6 +123,7 @@ files:
123
123
  - lib/plezi/render/markdown.rb
124
124
  - lib/plezi/render/render.rb
125
125
  - lib/plezi/render/sass.rb
126
+ - lib/plezi/render/sassc.rb
126
127
  - lib/plezi/render/slim.rb
127
128
  - lib/plezi/router/adclient.rb
128
129
  - lib/plezi/router/assets.rb
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
167
  version: '0'
167
168
  requirements: []
168
169
  rubyforge_project:
169
- rubygems_version: 2.7.3
170
+ rubygems_version: 2.7.6
170
171
  signing_key:
171
172
  specification_version: 4
172
173
  summary: The Plezi.io Ruby Framework for real time web applications.