stylus 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -6
- data/README.md +20 -0
- data/lib/stylus.rb +7 -25
- data/lib/stylus/import_processor.rb +12 -0
- data/lib/stylus/railtie.rb +27 -23
- data/lib/stylus/runtime.rb +55 -0
- data/lib/stylus/{compiler.js → runtime/compiler.js} +1 -1
- data/lib/stylus/{runner.js → runtime/runner.js} +0 -0
- data/lib/stylus/sprockets.rb +46 -0
- data/lib/stylus/tilt.rb +28 -4
- data/lib/stylus/version.rb +1 -1
- data/spec/rails_spec.rb +49 -0
- data/spec/runtime_spec.rb +11 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/sprockets_spec.rb +19 -43
- metadata +10 -4
data/CHANGELOG.md
CHANGED
@@ -1,33 +1,39 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
+
### 0.6.0 (2012-05-20)
|
4
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.5.1...v.0.6.0)
|
5
|
+
|
6
|
+
* Sprockets configuration extracted to `Stylus.setup` - you can use this on a Sinatra or Rack app;
|
7
|
+
* When `node` isn't available, Stylus will raise a exception of it's own instead of blowing up inside ExecJS.
|
8
|
+
|
3
9
|
### 0.5.1 (2012-05-07)
|
4
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.5.0...
|
10
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.5.0...v0.5.1)
|
5
11
|
|
6
12
|
* Fixes the `ImportProcessor` so it doesn't evaluates the stylesheets.
|
7
13
|
|
8
14
|
### 0.5.0 (2012-03-26)
|
9
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.2...
|
15
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.2...v0.5.0)
|
10
16
|
|
11
17
|
* Rewrite of the Railtie initializers to match 3.2 loading order;
|
12
18
|
* Only folders ending with `stylesheets` will be copied over to `Stylus.paths`.
|
13
19
|
|
14
20
|
### 0.4.2 (2012-03-24)
|
15
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.1...
|
21
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.1...v0.4.2)
|
16
22
|
|
17
23
|
* Tells Rails to always run the Railtie initializer.
|
18
24
|
|
19
25
|
### 0.4.1 (2012-01-06)
|
20
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.0...
|
26
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.4.0...v0.4.1)
|
21
27
|
|
22
28
|
* Skips Sprockets configuration if `config.assets.enabled` isn't true.
|
23
29
|
|
24
30
|
### 0.4.0 (2011-11-23)
|
25
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.3.0...
|
31
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.3.0...v0.4.0)
|
26
32
|
|
27
33
|
* `@import` directives will be added as dependencies to Sprockets (based on the work by @metaskills on the less-rails).
|
28
34
|
|
29
35
|
### 0.3.0 (2011-10-17)
|
30
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.2...
|
36
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.2...v0.3.0)
|
31
37
|
|
32
38
|
* This gem now uses the [stylus-source](https://github.com/railsjedi/ruby-stylus-source) gem to bundle the latest [NPM](http://search.npmjs.org/#/stylus) package of Stylus, so there's no setup required to install stylus via `npm install` or cloning it into the `node_modules` folder - Thanks @railsjedi.
|
33
39
|
* Added a `debug` configuration option, that enables the `linenos` and `firebug` flags on Stylus. Inside Rails, this configuration option will be copied from the `config.assets.debug`;
|
data/README.md
CHANGED
@@ -62,6 +62,26 @@ If you use Stylus `@import` to expose variables, mixins or just to concatenate c
|
|
62
62
|
@import 'mixins'
|
63
63
|
```
|
64
64
|
|
65
|
+
### Standalone Sprockets usage
|
66
|
+
|
67
|
+
If you're using Sprockets outside Rails, on Sinatra or on a plain Rack app, you can wire up Stylus inside a instance of `Sprockets::Environment` with the `Stylus.setup` method.
|
68
|
+
|
69
|
+
An example of serving stylesheets from `./stylesheets` using just Sprockets and Rack.
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
require 'sprockets'
|
73
|
+
require 'stylus'
|
74
|
+
|
75
|
+
# Serve your stylesheets living on ./stylesheets
|
76
|
+
assets = Sprockets::Environment.new
|
77
|
+
assets.append_path('stylesheets')
|
78
|
+
|
79
|
+
Stylus.setup(assets)
|
80
|
+
|
81
|
+
# Run the Sprockets with Rack
|
82
|
+
map('/assets') { run assets.index }
|
83
|
+
```
|
84
|
+
|
65
85
|
## Plugins
|
66
86
|
|
67
87
|
[Stylus](https://github.com/LearnBoost/stylus) exposes a nice API to create plugins written on [node.js](http://nodejs.org), like [nib](https://github.com/visionmedia/nib). The installation process should be the same as described above for [Stylus](https://github.com/LearnBoost/stylus) (since they're all npm packages after all). You can hook them up on your Ruby code with `Stylus.use`:
|
data/lib/stylus.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'stylus/runtime'
|
2
|
+
require 'stylus/source'
|
3
|
+
require 'stylus/sprockets'
|
2
4
|
require 'stylus/version'
|
3
5
|
require 'stylus/tilt' if defined?(::Tilt)
|
4
6
|
require 'stylus/railtie' if defined?(::Rails)
|
5
|
-
require 'stylus/source'
|
6
7
|
## Stylus
|
7
8
|
#
|
8
9
|
# `stylus` is a bridge between your Ruby code and the [Stylus](https://github.com/LearnBoost/stylus)
|
@@ -22,6 +23,7 @@ require 'stylus/source'
|
|
22
23
|
# `Stylus.compile(File.read('application.styl'), :compress => true)`
|
23
24
|
#
|
24
25
|
module Stylus
|
26
|
+
extend Runtime, Sprockets
|
25
27
|
class << self
|
26
28
|
@@compress = false
|
27
29
|
@@debug = false
|
@@ -103,14 +105,14 @@ module Stylus
|
|
103
105
|
end
|
104
106
|
source = source.read if source.respond_to?(:read)
|
105
107
|
options = merge_options(options)
|
106
|
-
|
108
|
+
exec('compile', source, options, plugins, imports)
|
107
109
|
end
|
108
110
|
|
109
111
|
# Converts back an input of plain CSS to the `Stylus` syntax. The source object can be
|
110
112
|
# a `File`, `StringIO`, `String` or anything that responds to `read`.
|
111
113
|
def convert(source)
|
112
114
|
source = source.read if source.respond_to?(:read)
|
113
|
-
|
115
|
+
exec('convert', source)
|
114
116
|
end
|
115
117
|
|
116
118
|
# Returns a `Hash` of the given `options` merged with the default configuration.
|
@@ -141,30 +143,10 @@ module Stylus
|
|
141
143
|
|
142
144
|
# Return the gem version alongside with the current `Stylus` version of your system.
|
143
145
|
def version
|
144
|
-
"Stylus - gem #{VERSION} library #{
|
146
|
+
"Stylus - gem #{VERSION} library #{exec('version')}"
|
145
147
|
end
|
146
148
|
|
147
149
|
protected
|
148
|
-
# Returns the `ExecJS` execution context.
|
149
|
-
def context
|
150
|
-
@@_context ||= backend.compile(script)
|
151
|
-
end
|
152
|
-
|
153
|
-
# Reads the default compiler script that `ExecJS` will execute.
|
154
|
-
def script
|
155
|
-
File.read(File.expand_path('../stylus/compiler.js',__FILE__))
|
156
|
-
end
|
157
|
-
|
158
|
-
# `ExecJS` 1.2.5+ doesn't support `require` statements on node anymore,
|
159
|
-
# so we use a new instance of the `ExternalRuntime` with the old runner script.
|
160
|
-
def backend
|
161
|
-
@@_backend ||= ExecJS::ExternalRuntime.new(
|
162
|
-
:name => 'Node.js (V8)',
|
163
|
-
:command => ["nodejs", "node"],
|
164
|
-
:runner_path => File.expand_path("../stylus/runner.js", __FILE__)
|
165
|
-
)
|
166
|
-
end
|
167
|
-
|
168
150
|
def bundled_path
|
169
151
|
File.dirname(Stylus::Source.bundled_path)
|
170
152
|
end
|
@@ -1,12 +1,24 @@
|
|
1
1
|
# Based on the ImportProcessor from the less-rails gem, by @metaskills
|
2
2
|
module Stylus
|
3
|
+
# Internal: A Tilt template that tracks down '@import' declarations
|
4
|
+
# and marks them as a dependency on the current asset.
|
5
|
+
#
|
6
|
+
# Example
|
7
|
+
#
|
8
|
+
# @import 'dashboard'
|
9
|
+
# # => A '//= depend_on dashboard' directive can be ommited from the stylesheet.
|
3
10
|
class ImportProcessor < Tilt::Template
|
4
11
|
|
5
12
|
IMPORT_SCANNER = /@import\s*['"]([^'"]+)['"]\s*/.freeze
|
6
13
|
|
14
|
+
# Internal: Tilt default interface requirement.
|
15
|
+
#
|
16
|
+
# Returns nothing.
|
7
17
|
def prepare
|
8
18
|
end
|
9
19
|
|
20
|
+
# Internal: Scan the stylesheet body, looking for '@import' calls to
|
21
|
+
# declare them as dependency on the context using 'depend_on' method.
|
10
22
|
def evaluate(context, locals, &block)
|
11
23
|
dependencies = data.scan(IMPORT_SCANNER).flatten.compact.uniq
|
12
24
|
|
data/lib/stylus/railtie.rb
CHANGED
@@ -1,32 +1,36 @@
|
|
1
|
-
require 'stylus
|
2
|
-
require 'stylus/import_processor'
|
3
|
-
|
1
|
+
require 'stylus'
|
4
2
|
module Stylus
|
5
|
-
|
3
|
+
# Internal: The Railtie responsible for integrate the Stylus library with
|
4
|
+
# a Rails 3.2 (or 3.1) application.
|
5
|
+
#
|
6
|
+
# Some of the customizations of using Stylus alongside Rails:
|
6
7
|
#
|
7
|
-
#
|
8
|
+
# * The application will use the Stylus stylesheet engine;
|
9
|
+
# * The Sprockets instance (present at Rails.application.assets) will be configured
|
10
|
+
# with the Stylus templates and the configurations defined at 'config.assets' will
|
11
|
+
# affect how Stylus compile your stylesheets;
|
12
|
+
# * The assets load path - the folders living on app/assets/stylesheets,
|
13
|
+
# lib/assets/stylesheets and vendor/assets/stylesheets on your app - will be
|
14
|
+
# added to the Stylus path registry.
|
8
15
|
class Railtie < ::Rails::Railtie
|
9
16
|
|
17
|
+
# Internal: Set the Stylesheet engine to 'stylus', so the generator constants
|
18
|
+
# will be loaded from the `Stylus::Generators` namespace.
|
10
19
|
config.app_generators.stylesheet_engine :stylus
|
11
20
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
#
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
paths = sprockets.paths.select { |dir| dir.to_s.ends_with?('stylesheets') }
|
26
|
-
if sprockets.enabled
|
27
|
-
Stylus.compress = sprockets.compress
|
28
|
-
Stylus.debug = sprockets.debug
|
29
|
-
Stylus.paths.concat paths
|
21
|
+
# Internal: Initializer block that uses the Stylus.setup utility to configure
|
22
|
+
# both Stylus and the Sprockets instance that lives on 'app.assets'. The entire
|
23
|
+
# configuration object will be passed along.
|
24
|
+
#
|
25
|
+
# If you don't have the Asset Pipeline enabled on your application - done by
|
26
|
+
# setting the 'config.assets.enabled' flag to false, this setup process will be
|
27
|
+
# skipped.
|
28
|
+
#
|
29
|
+
# Returns nothing.
|
30
|
+
initializer 'stylus.setup', :after => :append_assets_path, :group => :all do |app|
|
31
|
+
config = app.config.assets
|
32
|
+
if config.enabled
|
33
|
+
Stylus.setup(app.assets, config)
|
30
34
|
end
|
31
35
|
end
|
32
36
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'execjs'
|
2
|
+
|
3
|
+
module Stylus
|
4
|
+
# Internal: Module responsible for the ExecJS interaction. Besides handling
|
5
|
+
# the compilation execution, this module provide a runtime validation to ensure
|
6
|
+
# that the Node.JS binary is available to use.
|
7
|
+
module Runtime
|
8
|
+
# Internal: Calls a specific function on the Node.JS context.
|
9
|
+
#
|
10
|
+
# Example
|
11
|
+
# exec('version', 2)
|
12
|
+
# # => "2"
|
13
|
+
#
|
14
|
+
# Returns The function returned value.
|
15
|
+
def exec(*arguments)
|
16
|
+
check_availability!
|
17
|
+
context.call(*arguments)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
# Internal: Queries the runtime for it's availability and raises a 'RuntimeError'
|
22
|
+
# if the runtime isn't available. Otherwise, this is a noop.
|
23
|
+
def check_availability!
|
24
|
+
unless runtime.available?
|
25
|
+
message = "The Node.JS runtime isn't available to Stylus."
|
26
|
+
message << "Ensure that the 'node' (or 'nodejs') executable is present in your $PATH."
|
27
|
+
raise RuntimeError, message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Internal: Compile the Stylus compilation script into a execution context
|
32
|
+
# to execute functions into.
|
33
|
+
#
|
34
|
+
# Returns the compiled context.
|
35
|
+
def context
|
36
|
+
@context ||= runtime.compile(script)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Internal: The custom compilation script body.
|
40
|
+
def script
|
41
|
+
File.read(File.expand_path('../runtime/compiler.js',__FILE__))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Internal: Create the ExecJS external runtime with a old runner script that
|
45
|
+
# maintains the state of 'require', so we can use it to load modules like on
|
46
|
+
# any Node.JS program.
|
47
|
+
def runtime
|
48
|
+
@runtime ||= ExecJS::ExternalRuntime.new(
|
49
|
+
:name => 'Node.js (V8)',
|
50
|
+
:command => ["nodejs", "node"],
|
51
|
+
:runner_path => File.expand_path("../runtime/runner.js", __FILE__)
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
File without changes
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'stylus/tilt'
|
2
|
+
require 'stylus/import_processor'
|
3
|
+
|
4
|
+
# Public: The setup logic to configure both Stylus and Sprockets on any
|
5
|
+
# kind of application - Rails, Sinatra or Rack.
|
6
|
+
#
|
7
|
+
# Example
|
8
|
+
#
|
9
|
+
# # mounting Sprockets as a Rack application with Stylus
|
10
|
+
# assets = Sprockets::Environment.new
|
11
|
+
# assets.append_path 'stylesheets'
|
12
|
+
# Stylus.setup(assets)
|
13
|
+
# run assets.index
|
14
|
+
module Stylus
|
15
|
+
module Sprockets
|
16
|
+
# Public: Configure a Sprockets environment with Stylus Tilt engine
|
17
|
+
# and the ImportProcessor. It also accept a configuration Hash to
|
18
|
+
# setup the load path and flags of the Stylus module.
|
19
|
+
#
|
20
|
+
# environment - A instance of Sprockets::Environment.
|
21
|
+
# options - The configuration Hash (default: {})
|
22
|
+
# :paths - An Array of paths to use the '@import' directive, defaults
|
23
|
+
# to the `paths` attribute on the environment object.
|
24
|
+
# :debug - The Boolean value for the debug flag.
|
25
|
+
# :compress - The Boolean value for the debug compress.
|
26
|
+
#
|
27
|
+
# Example
|
28
|
+
#
|
29
|
+
# assets = Sprockets::Environment.new
|
30
|
+
# Stylus.setup(assets, :compress => settings.production?)
|
31
|
+
#
|
32
|
+
# Returns nothing.
|
33
|
+
def setup(environment, options = {})
|
34
|
+
paths = options[:paths] || environment.paths
|
35
|
+
directories = paths.select { |dir| dir.to_s =~ /stylesheets$/ }
|
36
|
+
|
37
|
+
Stylus.paths.concat(directories)
|
38
|
+
|
39
|
+
Stylus.debug = options.fetch(:debug, Stylus.debug)
|
40
|
+
Stylus.compress = options.fetch(:compress, Stylus.compress)
|
41
|
+
|
42
|
+
environment.register_engine('.styl', Tilt::StylusTemplate)
|
43
|
+
environment.register_preprocessor('text/css', Stylus::ImportProcessor)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/stylus/tilt.rb
CHANGED
@@ -1,26 +1,50 @@
|
|
1
1
|
require 'tilt'
|
2
|
-
|
2
|
+
# Public: A Tilt template to compile Stylus stylesheets.
|
3
|
+
#
|
4
|
+
# Examples
|
5
|
+
#
|
6
|
+
# template = Tilt::StylusTemplate.new { |t| File.read('app.styl') }
|
7
|
+
# template.render
|
8
|
+
# # => the compiled CSS from the app.styl file.
|
9
|
+
#
|
10
|
+
# Options should assigned on the template constructor.
|
11
|
+
# template = Tilt::StylusTemplate.new(:compress => true) { |t| File.read('app.styl') }
|
12
|
+
# template.render
|
13
|
+
# # => the compiled CSS with compression enabled.
|
3
14
|
module Tilt
|
4
|
-
### stylus template implementation for `Tilt`.
|
5
|
-
#
|
6
|
-
# It can be used by the `Rails` 3.1 or `Sinatra` applications.
|
7
15
|
class StylusTemplate < Template
|
16
|
+
|
17
|
+
# Public: The default mime type for stylesheets.
|
8
18
|
self.default_mime_type = 'text/css'
|
9
19
|
|
20
|
+
# Internal: Checks if the Stylus module has been properly defined.
|
21
|
+
#
|
22
|
+
# Returns true if the 'Stylus' module is present.
|
10
23
|
def self.engine_initialized?
|
11
24
|
defined? ::Stylus
|
12
25
|
end
|
13
26
|
|
27
|
+
# Internal: Require the 'stylus' file to load the Stylus module.
|
28
|
+
#
|
29
|
+
# Returns nothing.
|
14
30
|
def initialize_engine
|
15
31
|
require_template_library 'stylus'
|
16
32
|
end
|
17
33
|
|
34
|
+
# Internal: Caches the filename as an option entry if it's present.
|
35
|
+
#
|
36
|
+
# Returns nothing.
|
18
37
|
def prepare
|
19
38
|
if self.file
|
20
39
|
options[:filename] ||= self.file
|
21
40
|
end
|
22
41
|
end
|
23
42
|
|
43
|
+
# Internal: Compile the template Stylus using this instance options.
|
44
|
+
# The current 'scope' and given 'locals' are ignored and the output
|
45
|
+
# is cached.
|
46
|
+
#
|
47
|
+
# Returns the compiled stylesheet with CSS syntax.
|
24
48
|
def evaluate(scope, locals, &block)
|
25
49
|
@output ||= Stylus.compile(data, options)
|
26
50
|
end
|
data/lib/stylus/version.rb
CHANGED
data/spec/rails_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Rails integration' do
|
4
|
+
|
5
|
+
it "copies the folders ending with 'stylesheets' from the Sprockets load path" do
|
6
|
+
app = create_app
|
7
|
+
Stylus.paths.should == [fixture_root]
|
8
|
+
Stylus.paths.should_not == app.assets.paths
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'process .styl files with the asset pipeline' do
|
12
|
+
result = fixture(:simple).last
|
13
|
+
|
14
|
+
app = create_app
|
15
|
+
app.assets['simple'].to_s.should == result
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'enables @import definitions' do
|
19
|
+
result = fixture(:import).last
|
20
|
+
|
21
|
+
app = create_app
|
22
|
+
app.assets['import'].to_s.should == result
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'skips debug info by default' do
|
26
|
+
app = create_app
|
27
|
+
asset = app.assets['simple']
|
28
|
+
asset.to_s.should_not match(/line 1 : #{asset.pathname}/)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'provides debug info if required' do
|
32
|
+
app = create_app(:debug => true)
|
33
|
+
asset = app.assets['simple']
|
34
|
+
asset.to_s.should match(/line 1 : #{asset.pathname}/)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'compress the output if Rails is configured to compress them too' do
|
38
|
+
result = fixture(:compressed).last
|
39
|
+
|
40
|
+
app = create_app(:compress => true)
|
41
|
+
app.assets['compressed'].to_s.should == result
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'loads the app normally even when the asset pipeline is disabled' do
|
45
|
+
expect {
|
46
|
+
create_app(:enabled => false)
|
47
|
+
}.to_not raise_error
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stylus::Runtime do
|
4
|
+
it "raises an error if the runtime isn't available" do
|
5
|
+
Stylus.stub(:runtime) { mock("An unavailable Runtime", :available? => false) }
|
6
|
+
|
7
|
+
expect {
|
8
|
+
Stylus.version
|
9
|
+
}.to raise_error RuntimeError, %r[The Node.JS runtime isn't available to Stylus.]
|
10
|
+
end
|
11
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,8 +4,8 @@ require 'rails/generators/test_case'
|
|
4
4
|
|
5
5
|
require 'active_support/railtie'
|
6
6
|
require 'action_controller/railtie'
|
7
|
+
require 'sprockets'
|
7
8
|
require 'sprockets/railtie'
|
8
|
-
require 'stylus/railtie'
|
9
9
|
require 'stylus'
|
10
10
|
|
11
11
|
require 'active_support/core_ext/class/attribute_accessors'
|
data/spec/sprockets_spec.rb
CHANGED
@@ -1,55 +1,31 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'process .styl files with the asset pipeline' do
|
12
|
-
result = fixture(:simple).last
|
13
|
-
|
14
|
-
app = create_app
|
15
|
-
app.assets['simple'].to_s.should == result
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'enables @import definitions' do
|
19
|
-
result = fixture(:import).last
|
20
|
-
|
21
|
-
app = create_app
|
22
|
-
app.assets['import'].to_s.should == result
|
3
|
+
describe "Sprockets setup" do
|
4
|
+
let(:env) do
|
5
|
+
Sprockets::Environment.new do |assets|
|
6
|
+
assets.append_path fixture_root
|
7
|
+
assets.append_path 'javascripts'
|
8
|
+
end
|
23
9
|
end
|
24
10
|
|
25
|
-
it
|
26
|
-
|
27
|
-
|
28
|
-
asset.to_s.should_not match(/line 1 : #{asset.pathname}/)
|
11
|
+
it "register the Tilt engine" do
|
12
|
+
env.should_receive(:register_engine).with('.styl', Tilt::StylusTemplate)
|
13
|
+
Stylus.setup(env)
|
29
14
|
end
|
30
15
|
|
31
|
-
it
|
32
|
-
|
33
|
-
|
34
|
-
asset.to_s.should match(/line 1 : #{asset.pathname}/)
|
16
|
+
it "register the import processor" do
|
17
|
+
env.should_receive(:register_preprocessor).with('text/css', Stylus::ImportProcessor)
|
18
|
+
Stylus.setup(env)
|
35
19
|
end
|
36
20
|
|
37
|
-
it
|
38
|
-
|
39
|
-
|
40
|
-
app = create_app(:compress => true)
|
41
|
-
app.assets['compressed'].to_s.should == result
|
21
|
+
it "copies the 'stylesheets' paths" do
|
22
|
+
Stylus.setup(env)
|
23
|
+
Stylus.paths.should == [fixture_root]
|
42
24
|
end
|
43
25
|
|
44
|
-
it "
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
app.assets['variables'].to_s.should == result
|
49
|
-
end
|
50
|
-
it 'loads the app normally even when the asset pipeline is disabled' do
|
51
|
-
expect {
|
52
|
-
create_app(:enabled => false)
|
53
|
-
}.to_not raise_error
|
26
|
+
it "configure the debug and compress flags" do
|
27
|
+
Stylus.setup(env, :debug => true, :compress => true)
|
28
|
+
Stylus.debug.should == true
|
29
|
+
Stylus.compress.should == true
|
54
30
|
end
|
55
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stylus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
@@ -126,10 +126,12 @@ files:
|
|
126
126
|
- lib/rails/generators/stylus/assets/templates/stylesheet.css.styl
|
127
127
|
- lib/rails/generators/stylus/scaffold/scaffold_generator.rb
|
128
128
|
- lib/stylus.rb
|
129
|
-
- lib/stylus/compiler.js
|
130
129
|
- lib/stylus/import_processor.rb
|
131
130
|
- lib/stylus/railtie.rb
|
132
|
-
- lib/stylus/
|
131
|
+
- lib/stylus/runtime.rb
|
132
|
+
- lib/stylus/runtime/compiler.js
|
133
|
+
- lib/stylus/runtime/runner.js
|
134
|
+
- lib/stylus/sprockets.rb
|
133
135
|
- lib/stylus/tilt.rb
|
134
136
|
- lib/stylus/version.rb
|
135
137
|
- spec/cases/compressed.css
|
@@ -144,6 +146,8 @@ files:
|
|
144
146
|
- spec/generators/controller_generator_spec.rb
|
145
147
|
- spec/generators/scaffold_generator_spec.rb
|
146
148
|
- spec/import_processor_spec.rb
|
149
|
+
- spec/rails_spec.rb
|
150
|
+
- spec/runtime_spec.rb
|
147
151
|
- spec/spec_helper.rb
|
148
152
|
- spec/sprockets_spec.rb
|
149
153
|
- spec/stylesheets/compressed.styl
|
@@ -201,6 +205,8 @@ test_files:
|
|
201
205
|
- spec/generators/controller_generator_spec.rb
|
202
206
|
- spec/generators/scaffold_generator_spec.rb
|
203
207
|
- spec/import_processor_spec.rb
|
208
|
+
- spec/rails_spec.rb
|
209
|
+
- spec/runtime_spec.rb
|
204
210
|
- spec/spec_helper.rb
|
205
211
|
- spec/sprockets_spec.rb
|
206
212
|
- spec/stylesheets/compressed.styl
|