sasscrack 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.rubocop.yml +16 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +16 -0
- data/Rakefile +8 -0
- data/lib/sassc_rack.rb +65 -0
- data/sasscrack.gemspec +24 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e578ced061896b80ff090f469c5554e6cc6bb657
|
4
|
+
data.tar.gz: 6605a6c90dc8610605d7ee459129ceef80683ac4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f5eb8e4912d9adce4848b4cabea5d620397bd4c71023a853f5d03eedcc9abf3020872f05ca8a524e0130a7a91b7de0e26e1d1bf8ff2c15cf6358173ae7e1f5d
|
7
|
+
data.tar.gz: 2207fd13293569fa51a6bd39a020255cf9f0012d7061aafe1d796d4d15941bb569feee23cb17f0e674fd0bd22500c0e4d229a706b688cbd3877d0d6088c2dbea
|
data/.gitignore
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Documentation cache and generated files:
|
13
|
+
/.yardoc/
|
14
|
+
/_yardoc/
|
15
|
+
/doc/
|
16
|
+
/rdoc/
|
17
|
+
|
18
|
+
## Environment normalisation:
|
19
|
+
/.bundle/
|
20
|
+
/lib/bundler/man/
|
21
|
+
|
22
|
+
# for a library or gem, you might want to ignore these files since the code is
|
23
|
+
# intended to run in multiple environments; otherwise, check them in:
|
24
|
+
Gemfile.lock
|
25
|
+
.ruby-version
|
26
|
+
|
27
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
28
|
+
.rvmrc
|
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Hans Krutzer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
SasscRack
|
2
|
+
=========
|
3
|
+
[![Build Status](https://travis-ci.org/hkrutzer/sasscrack.svg)](https://travis-ci.org/hkrutzer/sasscrack)
|
4
|
+
|
5
|
+
Hacky Rack plugin that runs sassc on scss files before their corresponding css
|
6
|
+
file is loaded. Libsass and sassc are required.
|
7
|
+
|
8
|
+
# Example usage
|
9
|
+
```
|
10
|
+
require "sassc_rack"
|
11
|
+
|
12
|
+
use SasscRack,
|
13
|
+
:write_file => false,
|
14
|
+
:static_path => "html",
|
15
|
+
:loadpaths => ["html/stylesheets"]
|
16
|
+
```
|
data/Rakefile
ADDED
data/lib/sassc_rack.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Rack plugin that intercepts requests to css files and calls sassc on the
|
2
|
+
# corresponding scss file if there is one.
|
3
|
+
class SasscRack
|
4
|
+
# @param [Hash] options Configuration options
|
5
|
+
# @option options [String] :static_path Path from where static files
|
6
|
+
# are served
|
7
|
+
# @option options [Array[String]] :loadpaths Additional paths for sassc to
|
8
|
+
# look in
|
9
|
+
# @option options [Boolean] :write_file Compile and write file to disk
|
10
|
+
# instead of capturing sassc output and serving this directly
|
11
|
+
def initialize(app, options = {})
|
12
|
+
detect_sassc
|
13
|
+
|
14
|
+
@app = app
|
15
|
+
|
16
|
+
@options = {
|
17
|
+
static_path: "public",
|
18
|
+
loadpaths: [],
|
19
|
+
write_file: true,
|
20
|
+
}.update(options)
|
21
|
+
|
22
|
+
sass_loadpaths = (Sass.load_paths | @options[:loadpaths]).join(":")
|
23
|
+
@sass_command = 'sassc -I "' + sass_loadpaths + '" '
|
24
|
+
end
|
25
|
+
|
26
|
+
def detect_sassc
|
27
|
+
detect = system("sassc -v")
|
28
|
+
fail "SasscRack could not find sassc." unless detect
|
29
|
+
end
|
30
|
+
|
31
|
+
def call(env)
|
32
|
+
if env["PATH_INFO"].end_with? ".css"
|
33
|
+
writepath = @options[:static_path] + env["PATH_INFO"]
|
34
|
+
scssfile = writepath[0..-4] + "scss"
|
35
|
+
|
36
|
+
if File.exist? scssfile
|
37
|
+
if @options[:write_file]
|
38
|
+
compile_write(env, scssfile, writepath)
|
39
|
+
else
|
40
|
+
compile_serve(env, scssfile)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
@app.call(env)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
@app.call(env)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def compile_serve(env, filepath)
|
51
|
+
_, headers, _ = @app.call(env)
|
52
|
+
|
53
|
+
exec = @sass_command + filepath
|
54
|
+
response_body = `#{exec}`
|
55
|
+
|
56
|
+
headers["Content-Length"] = response_body.length.to_s
|
57
|
+
|
58
|
+
[200, headers, [response_body]]
|
59
|
+
end
|
60
|
+
|
61
|
+
def compile_write(env, filepath, writepath)
|
62
|
+
system(@sass_command + filepath + " " + writepath)
|
63
|
+
@app.call(env)
|
64
|
+
end
|
65
|
+
end
|
data/sasscrack.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.authors = ['Hans Krutzer']
|
5
|
+
s.email = ['git@pixelspaceships.com']
|
6
|
+
s.name = 'sasscrack'
|
7
|
+
s.version = '0.0.2'
|
8
|
+
s.homepage = 'https://github.com/hkrutzer/sasscrack'
|
9
|
+
|
10
|
+
s.summary = 'Rack plugin for libsass'
|
11
|
+
s.description = <<-EOF
|
12
|
+
Rack plugin that executes sassc on scss files, and
|
13
|
+
serves or writes the file.
|
14
|
+
EOF
|
15
|
+
s.licenses = ['MIT']
|
16
|
+
|
17
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.require_paths = ['lib']
|
21
|
+
|
22
|
+
s.add_development_dependency 'rake', ['>= 0']
|
23
|
+
s.add_development_dependency 'rubocop', ['>= 0']
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sasscrack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Hans Krutzer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: |2
|
42
|
+
Rack plugin that executes sassc on scss files, and
|
43
|
+
serves or writes the file.
|
44
|
+
email:
|
45
|
+
- git@pixelspaceships.com
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rubocop.yml"
|
52
|
+
- ".travis.yml"
|
53
|
+
- Gemfile
|
54
|
+
- LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/sassc_rack.rb
|
58
|
+
- sasscrack.gemspec
|
59
|
+
homepage: https://github.com/hkrutzer/sasscrack
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.4.5
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Rack plugin for libsass
|
83
|
+
test_files: []
|