stylus 0.2.1.beta → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -4
- data/README.md +39 -10
- data/lib/stylus/railtie.rb +1 -0
- data/lib/stylus/version.rb +1 -1
- data/spec/spec_helper.rb +11 -0
- data/spec/sprockets_spec.rb +30 -0
- data/spec/support/generators/test_case.rb +0 -6
- data/spec/support/helpers.rb +11 -0
- data/stylus.gemspec +2 -3
- metadata +24 -33
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
## Changelog
|
2
2
|
|
3
|
-
### 0.2.1
|
4
|
-
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.0...
|
3
|
+
### 0.2.1 (2011-08-30)
|
4
|
+
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.2.0...v0.2.1)
|
5
5
|
|
6
6
|
* Removed a hack for a Sprockets loading order issue;
|
7
|
-
* Testing on 1.9.2, REE and Rubinius thanks to [Travis CI](travis-ci.org/#!/lucasmazza/ruby-stylus)
|
7
|
+
* Testing on 1.9.2, REE and Rubinius thanks to [Travis CI](travis-ci.org/#!/lucasmazza/ruby-stylus);
|
8
|
+
* Enables compression if `Sprockets` is configured to do so;
|
9
|
+
* Added Rails and Sprockets tests.
|
8
10
|
|
9
|
-
### 0.2.0 (
|
11
|
+
### 0.2.0 (2011-07-14)
|
10
12
|
[Compare view](https://github.com/lucasmazza/ruby-stylus/compare/v0.1.2...v0.2.0)
|
11
13
|
|
12
14
|
* Replaced `stylus:install` with proper generators for Rails 3.1 - now all hooks for the `stylesheet_engine` will generate `.styl` files.
|
data/README.md
CHANGED
@@ -2,11 +2,25 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/lucasmazza/ruby-stylus.png)](http://travis-ci.org/lucasmazza/ruby-stylus)
|
4
4
|
|
5
|
-
`stylus` is a bridge between your Ruby code and the [Stylus](https://github.com/LearnBoost/stylus) library that runs on
|
5
|
+
`stylus` is a bridge between your Ruby code and the [Stylus](https://github.com/LearnBoost/stylus) library that runs on [node.js](http://nodejs.org). It has support for the Rails 3.1 asset pipeline (thanks to a [Tilt](https://github.com/rtomayko/tilt) Template) and it's backed by the [ExecJS](https://github.com/sstephenson/execjs) gem.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Be sure to have [node.js](http://nodejs.org) available on your system, and [npm](npmjs.org) to install the [Stylus](https://github.com/LearnBoost/stylus) package (but you can also do a manual installation).
|
10
|
+
|
11
|
+
### With npm
|
12
|
+
|
13
|
+
You can make a local install (inside your application folder, so the package will be at `./node_modules`) or a global one (with the `-g` flag). With a global install you will need to make sure that the global installation folder is present at the `NODE_PATH` env variable. A global install will also enable the [Stylus](https://github.com/LearnBoost/stylus) command line interface.
|
14
|
+
|
15
|
+
### Manual
|
16
|
+
|
17
|
+
You can clone Stylus [git repository](http://github.com/learnboost/stylus) into `node_modules/stylus`. Any `node` commands and/or shells from the current directory will be able to find the cloned package.
|
18
|
+
|
19
|
+
Check your installation with `node -e "require('stylus')"`. It should print something like [this](https://gist.github.com/1182631) and exit successfully.
|
6
20
|
|
7
21
|
## Usage
|
8
22
|
|
9
|
-
|
23
|
+
The interaction is done by the `Stylus` module. You can compile stylus syntax to CSS, convert it back, enable plugins and tweak some other options:
|
10
24
|
|
11
25
|
```ruby
|
12
26
|
require 'stylus'
|
@@ -24,24 +38,39 @@ Stylus.compile(File.read('application.styl'))
|
|
24
38
|
# Converting old and boring CSS to awesome Stylus.
|
25
39
|
Stylus.convert(File.new('file.css'))
|
26
40
|
|
27
|
-
# Importing plugins directly from Node.
|
41
|
+
# Importing plugins directly from Node.js, like nib.
|
28
42
|
Stylus.use :nib
|
29
43
|
```
|
30
44
|
### With the Rails 3.1 Asset Pipeline.
|
31
45
|
|
32
|
-
|
46
|
+
Adding `stylus` to your Gemfile should let you work with `.styl` files with the Rails 3.1 Pipeline. Any asset generated with `rails generate` will be created with a `.css.styl` extension.
|
47
|
+
|
48
|
+
While [Stylus](https://github.com/LearnBoost/stylus) has a `@import` directive, inside a Rails application you should use the `//= require` directive from Sprockets, so the caching mechanism will look after the changes made on the required file. If you're using mixins (for vendor prefixes or any common statements) or plugins inside your `.styl` files, you should use [Stylus](https://github.com/LearnBoost/stylus) `@import` **and** Sprockets `//= depend_on`. The latter is to ensure the proper dependency management on the Sprockets side.
|
33
49
|
|
34
|
-
|
35
|
-
//= depend_on 'mixins/vendor.styl'
|
36
|
-
@import 'mixins/vendor'
|
50
|
+
Any `.styl` file on the Sprockets load path (`app/assets`, `lib/assets`, `vendor/assets` or `assets` folder inside any other gem) will be available via the `@import` directive.
|
37
51
|
|
38
|
-
|
52
|
+
## Plugins
|
53
|
+
|
54
|
+
[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 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`:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
Stylus.use :fingerprint, :literal => 'caa8c262e23268d2a7062c6217202343b84f472b'
|
58
|
+
```
|
59
|
+
|
60
|
+
Will run something like this on javascript:
|
61
|
+
|
62
|
+
```javascript
|
63
|
+
stylus(file).use(fingerprint({literal:'caa8c262e23268d2a7062c6217202343b84f472b'}));
|
39
64
|
```
|
40
65
|
|
41
|
-
|
66
|
+
## Question, Bugs or Support
|
67
|
+
|
68
|
+
You can [submit an issue](https://github.com/lucasmazza/ruby-stylus/issues) or ping me at [GitHub](http://github.com/lucasmazza) or [twitter](http://twitter.com/lucasmazza).
|
69
|
+
|
70
|
+
For more info about the [Stylus](https://github.com/LearnBoost/stylus) syntax and it's features you can check the [project repository](https://github.com/learnboost/stylus) and [GitHub page](learnboost.github.com/stylus).
|
42
71
|
|
43
72
|
## Changelog
|
44
|
-
[here.](https://github.com/lucasmazza/ruby-stylus/blob/master/CHANGELOG.md)
|
73
|
+
[It's available here.](https://github.com/lucasmazza/ruby-stylus/blob/master/CHANGELOG.md)
|
45
74
|
|
46
75
|
## License
|
47
76
|
|
data/lib/stylus/railtie.rb
CHANGED
@@ -15,6 +15,7 @@ module Stylus
|
|
15
15
|
# Includes the `Rails` asset load path into `stylus` so any
|
16
16
|
# `.styl` file inside it can be imported by the `stylus` API.
|
17
17
|
config.after_initialize do |app|
|
18
|
+
Stylus.compress = app.config.assets.compress
|
18
19
|
Stylus.paths.concat app.assets.paths
|
19
20
|
end
|
20
21
|
end
|
data/lib/stylus/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'rails/test_help'
|
3
|
+
require 'rails/generators/test_case'
|
4
|
+
|
5
|
+
require 'active_support/railtie'
|
6
|
+
require 'action_controller/railtie'
|
7
|
+
require 'sprockets/railtie'
|
8
|
+
require 'stylus/railtie'
|
9
|
+
|
10
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
11
|
+
|
1
12
|
require 'support/helpers'
|
2
13
|
require 'support/matchers'
|
3
14
|
require 'support/generators/test_case'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Sprockets and Rails integration' do
|
4
|
+
|
5
|
+
it 'copies the asset paths into the Stylus load path' do
|
6
|
+
app = create_app
|
7
|
+
Stylus.paths.should =~ app.assets.paths
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'process .styl files with the asset pipeline' do
|
11
|
+
result = fixture(:simple).last
|
12
|
+
|
13
|
+
app = create_app
|
14
|
+
app.assets['simple'].to_s.should == result
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'enables @import definitions' do
|
18
|
+
result = fixture(:import).last
|
19
|
+
|
20
|
+
app = create_app
|
21
|
+
app.assets['import'].to_s.should == result
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'compress the output if Rails is configured to compress them too' do
|
25
|
+
result = fixture(:compressed).last
|
26
|
+
|
27
|
+
app = create_app(:compress => true)
|
28
|
+
app.assets['compressed'].to_s.should == result
|
29
|
+
end
|
30
|
+
end
|
@@ -2,12 +2,6 @@
|
|
2
2
|
# But `RSpec::Rails::RailsExampleGroup` loads a truckload of things from rails and rspec-rails
|
3
3
|
# That we don't need.
|
4
4
|
|
5
|
-
ENV["RAILS_ENV"] = 'test'
|
6
|
-
require 'rails'
|
7
|
-
require 'rails/test_help'
|
8
|
-
require 'rails/generators/test_case'
|
9
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
10
|
-
|
11
5
|
module Generators
|
12
6
|
module TestCase
|
13
7
|
extend ActiveSupport::Concern
|
data/spec/support/helpers.rb
CHANGED
@@ -6,6 +6,17 @@ module Helpers
|
|
6
6
|
FileUtils.touch File.join(destination, 'routes.rb')
|
7
7
|
end
|
8
8
|
|
9
|
+
def create_app(options = {})
|
10
|
+
Rails.application = nil
|
11
|
+
Class.new(Rails::Application).tap do |app|
|
12
|
+
app.config.assets.enabled = true
|
13
|
+
app.config.assets.compress = true if options[:compress]
|
14
|
+
app.config.assets.paths << fixture_root
|
15
|
+
app.config.active_support.deprecation = :log
|
16
|
+
app.initialize!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
9
20
|
def fixture_root
|
10
21
|
File.expand_path('../../fixtures', __FILE__)
|
11
22
|
end
|
data/stylus.gemspec
CHANGED
@@ -14,9 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
s.add_dependency 'execjs'
|
16
16
|
s.add_development_dependency 'rspec', '~> 2.0'
|
17
|
-
s.add_development_dependency 'railties', '~> 3.1.0
|
18
|
-
s.add_development_dependency '
|
19
|
-
s.add_development_dependency 'sprockets', '~> 2.0.0.beta.10'
|
17
|
+
s.add_development_dependency 'railties', '~> 3.1.0'
|
18
|
+
s.add_development_dependency 'tzinfo'
|
20
19
|
s.add_development_dependency 'yajl-ruby'
|
21
20
|
s.add_development_dependency 'rocco'
|
22
21
|
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stylus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.1
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Lucas Mazza
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
16
|
-
requirement: &
|
16
|
+
requirement: &2157713640 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2157713640
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &2157713100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,43 +32,32 @@ dependencies:
|
|
32
32
|
version: '2.0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2157713100
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: railties
|
38
|
-
requirement: &
|
38
|
+
requirement: &2157712580 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 3.1.0
|
43
|
+
version: 3.1.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2157712580
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
49
|
-
requirement: &
|
48
|
+
name: tzinfo
|
49
|
+
requirement: &2157712200 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 3.1.0.rc1
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *2156713220
|
58
|
-
- !ruby/object:Gem::Dependency
|
59
|
-
name: sprockets
|
60
|
-
requirement: &2156712640 !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
63
|
-
- - ~>
|
52
|
+
- - ! '>='
|
64
53
|
- !ruby/object:Gem::Version
|
65
|
-
version:
|
54
|
+
version: '0'
|
66
55
|
type: :development
|
67
56
|
prerelease: false
|
68
|
-
version_requirements: *
|
57
|
+
version_requirements: *2157712200
|
69
58
|
- !ruby/object:Gem::Dependency
|
70
59
|
name: yajl-ruby
|
71
|
-
requirement: &
|
60
|
+
requirement: &2157711740 !ruby/object:Gem::Requirement
|
72
61
|
none: false
|
73
62
|
requirements:
|
74
63
|
- - ! '>='
|
@@ -76,10 +65,10 @@ dependencies:
|
|
76
65
|
version: '0'
|
77
66
|
type: :development
|
78
67
|
prerelease: false
|
79
|
-
version_requirements: *
|
68
|
+
version_requirements: *2157711740
|
80
69
|
- !ruby/object:Gem::Dependency
|
81
70
|
name: rocco
|
82
|
-
requirement: &
|
71
|
+
requirement: &2157699620 !ruby/object:Gem::Requirement
|
83
72
|
none: false
|
84
73
|
requirements:
|
85
74
|
- - ! '>='
|
@@ -87,7 +76,7 @@ dependencies:
|
|
87
76
|
version: '0'
|
88
77
|
type: :development
|
89
78
|
prerelease: false
|
90
|
-
version_requirements: *
|
79
|
+
version_requirements: *2157699620
|
91
80
|
description: Bridge library to compile .styl stylesheets from ruby code.
|
92
81
|
email:
|
93
82
|
- luc4smazza@gmail.com
|
@@ -125,6 +114,7 @@ files:
|
|
125
114
|
- spec/generators/controller_generator_spec.rb
|
126
115
|
- spec/generators/scaffold_generator_spec.rb
|
127
116
|
- spec/spec_helper.rb
|
117
|
+
- spec/sprockets_spec.rb
|
128
118
|
- spec/stylus_spec.rb
|
129
119
|
- spec/support/generators/test_case.rb
|
130
120
|
- spec/support/helpers.rb
|
@@ -146,12 +136,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
137
|
none: false
|
148
138
|
requirements:
|
149
|
-
- - ! '
|
139
|
+
- - ! '>='
|
150
140
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
141
|
+
version: '0'
|
152
142
|
requirements: []
|
153
143
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.8.
|
144
|
+
rubygems_version: 1.8.10
|
155
145
|
signing_key:
|
156
146
|
specification_version: 3
|
157
147
|
summary: Ruby Stylus Compiler
|
@@ -171,6 +161,7 @@ test_files:
|
|
171
161
|
- spec/generators/controller_generator_spec.rb
|
172
162
|
- spec/generators/scaffold_generator_spec.rb
|
173
163
|
- spec/spec_helper.rb
|
164
|
+
- spec/sprockets_spec.rb
|
174
165
|
- spec/stylus_spec.rb
|
175
166
|
- spec/support/generators/test_case.rb
|
176
167
|
- spec/support/helpers.rb
|