sinatra-autosass 0.0.1 → 0.0.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/README.md +18 -6
- data/lib/sinatra/autosass.rb +9 -4
- data/lib/sinatra/sassconvert.rb +21 -8
- metadata +24 -18
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -10,9 +10,14 @@ For classic applications
|
|
10
10
|
```ruby
|
11
11
|
require 'sinatra'
|
12
12
|
require 'sinatra/autosass'
|
13
|
-
set :
|
14
|
-
|
15
|
-
|
13
|
+
set :options,
|
14
|
+
{
|
15
|
+
:css_location => 'public/css',
|
16
|
+
:template_location => 'public/sass',
|
17
|
+
:syntax => :sass,
|
18
|
+
:cache => true,
|
19
|
+
:cache_location => '.tmp/sass-cache'
|
20
|
+
}
|
16
21
|
|
17
22
|
#application code
|
18
23
|
```
|
@@ -24,14 +29,21 @@ require 'sinatra/base'
|
|
24
29
|
require 'sinatra/autosass'
|
25
30
|
class MyApp < Sinatra::Application
|
26
31
|
register Sinatra::AutoSass
|
27
|
-
set :
|
28
|
-
|
29
|
-
|
32
|
+
set :options,
|
33
|
+
{
|
34
|
+
:css_location => 'public/css',
|
35
|
+
:template_location => 'public/sass',
|
36
|
+
:syntax => :sass,
|
37
|
+
:cache => true,
|
38
|
+
:cache_location => '.tmp/sass-cache'
|
39
|
+
}
|
30
40
|
|
31
41
|
#application code
|
32
42
|
|
33
43
|
end
|
34
44
|
```
|
45
|
+
See all available options here:
|
46
|
+
http://sass-lang.com/documentation/file.SASS_REFERENCE.html#options
|
35
47
|
|
36
48
|
|
37
49
|
Licensed under MIT.
|
data/lib/sinatra/autosass.rb
CHANGED
@@ -4,11 +4,16 @@ require_relative 'sassconvert.rb'
|
|
4
4
|
module Sinatra
|
5
5
|
module AutoSass
|
6
6
|
def self.registered(app)
|
7
|
-
app.set :
|
8
|
-
|
9
|
-
|
7
|
+
app.set :options,
|
8
|
+
{
|
9
|
+
:css_location => 'public/css',
|
10
|
+
:template_location => 'public/sass',
|
11
|
+
:syntax => :sass,
|
12
|
+
:cache => true,
|
13
|
+
:cache_location => '.tmp/sass-cache'
|
14
|
+
}
|
10
15
|
app.before do
|
11
|
-
SassConvert.new(settings.
|
16
|
+
SassConvert.new(settings.options)
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
data/lib/sinatra/sassconvert.rb
CHANGED
@@ -1,26 +1,39 @@
|
|
1
|
+
require 'sass'
|
2
|
+
|
1
3
|
class SassConvert
|
2
4
|
|
3
|
-
def initialize(
|
4
|
-
@
|
5
|
-
@
|
6
|
-
@
|
5
|
+
def initialize(options)
|
6
|
+
@options = options
|
7
|
+
@extension = options[:syntax].to_s
|
8
|
+
@sass_dir = options[:template_location].to_s
|
9
|
+
@css_dir = options[:css_location].to_s
|
7
10
|
append_trail
|
8
|
-
|
9
|
-
|
11
|
+
check_dirs
|
12
|
+
Dir.new("#{@sass_dir}/").each do |file|
|
13
|
+
if file.include?(".#{@extension}")
|
10
14
|
convert(file)
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def convert(file)
|
16
|
-
|
17
|
-
|
20
|
+
template = File.read("#{@sass_dir}#{file}")
|
21
|
+
sass_engine = Sass::Engine.new(template, @options)
|
22
|
+
output = sass_engine.render
|
23
|
+
file.gsub!(@extension, 'css')
|
24
|
+
IO.write("#{@css_dir}#{file}", output)
|
18
25
|
end
|
19
26
|
|
20
27
|
def append_trail
|
21
28
|
@sass_dir += '/' if @sass_dir.split(//).last != '/'
|
22
29
|
@css_dir += '/' if @css_dir.split(//).last != '/'
|
23
30
|
end
|
31
|
+
|
32
|
+
def check_dirs
|
33
|
+
Dir.mkdir('public') unless File.exists?('public')
|
34
|
+
Dir.mkdir(@sass_dir) unless File.exists?(@sass_dir)
|
35
|
+
Dir.mkdir(@css_dir) unless File.exists?(@css_dir)
|
36
|
+
end
|
24
37
|
|
25
38
|
end
|
26
39
|
|
metadata
CHANGED
@@ -1,53 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-autosass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Zisis Maras
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: sass
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '3.3'
|
20
|
-
- -
|
22
|
+
- - ! '>='
|
21
23
|
- !ruby/object:Gem::Version
|
22
24
|
version: 3.3.7
|
23
25
|
type: :runtime
|
24
26
|
prerelease: false
|
25
27
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
26
29
|
requirements:
|
27
|
-
- -
|
30
|
+
- - ~>
|
28
31
|
- !ruby/object:Gem::Version
|
29
32
|
version: '3.3'
|
30
|
-
- -
|
33
|
+
- - ! '>='
|
31
34
|
- !ruby/object:Gem::Version
|
32
35
|
version: 3.3.7
|
33
36
|
- !ruby/object:Gem::Dependency
|
34
37
|
name: sinatra
|
35
38
|
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
36
40
|
requirements:
|
37
|
-
- -
|
41
|
+
- - ~>
|
38
42
|
- !ruby/object:Gem::Version
|
39
43
|
version: '1.4'
|
40
|
-
- -
|
44
|
+
- - ! '>='
|
41
45
|
- !ruby/object:Gem::Version
|
42
46
|
version: 1.4.5
|
43
47
|
type: :runtime
|
44
48
|
prerelease: false
|
45
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
46
51
|
requirements:
|
47
|
-
- -
|
52
|
+
- - ~>
|
48
53
|
- !ruby/object:Gem::Version
|
49
54
|
version: '1.4'
|
50
|
-
- -
|
55
|
+
- - ! '>='
|
51
56
|
- !ruby/object:Gem::Version
|
52
57
|
version: 1.4.5
|
53
58
|
description: Sinatra extension to automatically recompile all your sass/scss files
|
@@ -57,33 +62,34 @@ executables: []
|
|
57
62
|
extensions: []
|
58
63
|
extra_rdoc_files: []
|
59
64
|
files:
|
60
|
-
- Gemfile
|
61
|
-
- LICENSE
|
62
|
-
- README.md
|
63
65
|
- lib/sinatra/autosass.rb
|
64
66
|
- lib/sinatra/sassconvert.rb
|
67
|
+
- LICENSE
|
68
|
+
- README.md
|
69
|
+
- Gemfile
|
65
70
|
homepage: https://github.com/zisismaras/sinatra-autosass
|
66
71
|
licenses:
|
67
72
|
- MIT
|
68
|
-
metadata: {}
|
69
73
|
post_install_message:
|
70
74
|
rdoc_options: []
|
71
75
|
require_paths:
|
72
76
|
- lib
|
73
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
74
79
|
requirements:
|
75
|
-
- -
|
80
|
+
- - ! '>='
|
76
81
|
- !ruby/object:Gem::Version
|
77
82
|
version: '0'
|
78
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
79
85
|
requirements:
|
80
|
-
- -
|
86
|
+
- - ! '>='
|
81
87
|
- !ruby/object:Gem::Version
|
82
88
|
version: '0'
|
83
89
|
requirements: []
|
84
90
|
rubyforge_project:
|
85
|
-
rubygems_version:
|
91
|
+
rubygems_version: 1.8.25
|
86
92
|
signing_key:
|
87
|
-
specification_version:
|
93
|
+
specification_version: 3
|
88
94
|
summary: Automatically recompile all your sass/scss files
|
89
95
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 67b655a4e3d28acb9e0fa35cef4cbb119ab1cd3f
|
4
|
-
data.tar.gz: 33ed25c52209ec9607b601d7c84faac363f644a1
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: f48bbf6af43b3147ced0828555555d43aadcc83c54399ce94b31a2763eb8f4b896962fbf8cd18c27b3288551135341f1a2aef14b76a8cda80529be38ec93e2f0
|
7
|
-
data.tar.gz: 3c7e0c92fa5b0fd2100b090008914cc6a0f1b3e5f3b5f4ab275cea92026d4d3edef40d402dba1b147fe21c5cd227182a27a0cfda32cff7430a1a8ba21a1cb380
|