stylus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -18,9 +18,23 @@ First, be sure to have stylus installed in your system. If needed, check the pro
18
18
  Stylus.compress = true
19
19
  Stylus.compile(File.read('application.styl'))
20
20
 
21
+ # Converting old and boring CSS to awesome Stylus.
22
+ Stylus.convert(File.new('file.css'))
23
+
21
24
  ### With the Rails 3.1 Asset Pipeline.
22
25
 
23
- Just add the `stylus` gem to your Gemfile and the gem will hook itself into Sprockets and enable the `.styl` templates for your stylesheets.
26
+ Just add the `stylus` gem to your Gemfile and the gem will hook itself into Sprockets and enable the `.styl` templates for your stylesheets. If you're including partial files inside your stylesheets, remember to use the `depend_on` directive on the top of your file so Sprockets can recompile it when the partial changes, as below.
27
+
28
+ //= depend_on 'mixins/vendor.styl'
29
+ @import 'mixins/vendor'
30
+
31
+ // Code goes here...
32
+
33
+ If you just want to merge the generated css in another file, you can use only the `require` directive from Sprockets.
34
+
35
+ ### Rails Generators
36
+
37
+ `stylus` ships with a `stylus:install` generator that copy 2 `.styl` files to your `lib/` folder, so when you run rails generators like `rails g assets products` or `rails g scaffold post` it will create `.styl` files instead of plain `.css` ones.
24
38
 
25
39
  ## Changelog
26
40
  [here.](https://github.com/lucasmazza/ruby-stylus/blob/master/CHANGELOG.md)
@@ -0,0 +1,3 @@
1
+ Copy the Stylus templates to your Rails app to replace the .css files generated by Rails, just do:
2
+
3
+ rails generate stylus:install
@@ -0,0 +1,16 @@
1
+ module Stylus
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ desc 'copy Stylus assets templates'
5
+ source_root File.expand_path('../templates', __FILE__)
6
+
7
+ def copy_asset_template
8
+ copy_file 'stylesheet.css.styl', 'lib/templates/rails/assets/stylesheet.css.styl'
9
+ end
10
+
11
+ def copy_scaffold_template
12
+ copy_file 'scaffold.css.styl', 'lib/templates/rails/resource/scaffold.css.styl'
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,58 @@
1
+ body
2
+ background-color #fff
3
+ color #333
4
+
5
+ body, p, ol, ul, td
6
+ font-family verdana, arial, helvetica, sans-serif
7
+ font-size 13px
8
+ line-height 18px
9
+
10
+ pre
11
+ background-color #eee
12
+ padding 10px
13
+ font-size 11px
14
+
15
+ a
16
+ color #000
17
+
18
+ &:visited
19
+ color #666
20
+
21
+ &:hover
22
+ color #fff
23
+ background-color #000
24
+
25
+ div.field, div.actions
26
+ margin-bottom 10px
27
+
28
+ #notice
29
+ color green
30
+
31
+ .field_with_errors
32
+ padding 2px
33
+ background-color red
34
+ display table
35
+
36
+ #error_explanation
37
+ width 450px
38
+ border 2px solid red
39
+ padding 7px
40
+ padding-bottom 0
41
+ margin-bottom 20px
42
+ background-color #f0f0f0
43
+
44
+ h2
45
+ text-align left
46
+ font-weight bold
47
+ padding 5px 5px 5px 15px
48
+ font-size 12px
49
+ margin -7px
50
+ margin-bottom 0px
51
+ background-color #c00
52
+ color #fff
53
+ ul
54
+ li
55
+ font-size 12px
56
+ list-style square
57
+
58
+
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the matching controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass here: http://learnboost.github.com/stylus
data/lib/stylus.rb CHANGED
@@ -30,6 +30,11 @@ module Stylus
30
30
  context.call('compiler', source, options)
31
31
  end
32
32
 
33
+ def convert(source)
34
+ source = source.read if source.respond_to?(:read)
35
+ context.call('convert', source)
36
+ end
37
+
33
38
  def merge_options(options)
34
39
  _paths = options.delete(:paths)
35
40
  options = defaults.merge(options)
@@ -51,8 +56,7 @@ module Stylus
51
56
  end
52
57
 
53
58
  def script
54
- path = File.expand_path(File.dirname(__FILE__))
55
- File.read(File.join(path, 'stylus', 'compiler.js'))
59
+ File.read(File.expand_path('../stylus/compiler.js',__FILE__))
56
60
  end
57
61
 
58
62
  def backend
@@ -10,6 +10,10 @@ function compiler(str, options) {
10
10
  return output;
11
11
  }
12
12
 
13
+ function convert(str) {
14
+ return stylus.convertCSS(str);
15
+ }
16
+
13
17
  function version() {
14
18
  return stylus.version;
15
19
  }
@@ -3,11 +3,13 @@ require 'stylus/tilt'
3
3
  module Stylus
4
4
  class Railtie < ::Rails::Railtie
5
5
 
6
- config.after_initialize do |app|
7
- if app.assets
8
- Stylus.paths.concat app.assets.paths
9
- app.assets.register_engine '.styl', Tilt::StylusTemplate
10
- end
6
+ initializer :setup_stylus do |app|
7
+ config.app_generators.stylesheet_engine :styl
8
+ end
9
+
10
+ config.after_initialize do |app|
11
+ Stylus.paths.concat app.assets.paths
12
+ app.assets.register_engine '.styl', Tilt::StylusTemplate
11
13
  end
12
14
 
13
15
  end
@@ -1,3 +1,3 @@
1
1
  module Stylus
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,3 @@
1
+ body {
2
+ padding: 5px;
3
+ }
@@ -0,0 +1,3 @@
1
+ body
2
+ padding: 5px
3
+
data/spec/spec_helper.rb CHANGED
@@ -9,7 +9,7 @@ RSpec.configure do |config|
9
9
  end
10
10
 
11
11
  def fixture_root
12
- File.join(File.dirname(File.expand_path(__FILE__)), 'fixtures')
12
+ File.expand_path('../fixtures', __FILE__)
13
13
  end
14
14
 
15
15
  def fixture(name)
data/spec/stylus_spec.rb CHANGED
@@ -38,4 +38,9 @@ describe Stylus do
38
38
  it "outputs both gem and library version" do
39
39
  Stylus.version.should =~ /Stylus - gem .+ library .+/
40
40
  end
41
+
42
+ it "converts CSS to Stylus" do
43
+ stylus, css = fixture :stylesheet
44
+ Stylus.convert(css).should == stylus
45
+ end
41
46
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lucas Mazza
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-19 00:00:00 Z
18
+ date: 2011-06-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: execjs
@@ -90,6 +90,10 @@ files:
90
90
  - LICENSE
91
91
  - README.md
92
92
  - Rakefile
93
+ - lib/generators/stylus/USAGE
94
+ - lib/generators/stylus/install_generator.rb
95
+ - lib/generators/stylus/templates/scaffold.css.styl
96
+ - lib/generators/stylus/templates/stylesheet.css.styl
93
97
  - lib/stylus.rb
94
98
  - lib/stylus/compiler.js
95
99
  - lib/stylus/railtie.rb
@@ -102,6 +106,8 @@ files:
102
106
  - spec/fixtures/mixins/vendor.styl
103
107
  - spec/fixtures/simple.css
104
108
  - spec/fixtures/simple.styl
109
+ - spec/fixtures/stylesheet.css
110
+ - spec/fixtures/stylesheet.styl
105
111
  - spec/spec_helper.rb
106
112
  - spec/stylus_spec.rb
107
113
  - spec/tilt_spec.rb
@@ -135,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
141
  requirements: []
136
142
 
137
143
  rubyforge_project:
138
- rubygems_version: 1.8.2
144
+ rubygems_version: 1.8.3
139
145
  signing_key:
140
146
  specification_version: 3
141
147
  summary: Ruby Stylus Compiler
@@ -147,6 +153,8 @@ test_files:
147
153
  - spec/fixtures/mixins/vendor.styl
148
154
  - spec/fixtures/simple.css
149
155
  - spec/fixtures/simple.styl
156
+ - spec/fixtures/stylesheet.css
157
+ - spec/fixtures/stylesheet.styl
150
158
  - spec/spec_helper.rb
151
159
  - spec/stylus_spec.rb
152
160
  - spec/tilt_spec.rb