stylus_rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ ## Changelog
2
+
3
+ ### 0.0.2 (2011-02-02)
4
+ [Compare view](http://github.com/lucasmazza/stylus_rails/compare/v0.0.1...v0.0.2)
5
+
6
+ * Support to the `-C` flag. Turned on by default;
7
+ * Grouping paths by their output dir, so all the files inside the same folder will be compiled using one single command;
8
+ * The output dir will be created if it doesn't exists.
9
+
10
+ ### 0.0.1 (2011-02-01)
11
+
12
+ * Initial Release.
data/README.md CHANGED
@@ -15,6 +15,9 @@ Just add `gem 'stylus_rails'` To your `Gemfile`.
15
15
 
16
16
  By default, `stylus_rails` will compile all files existing at `public/stylesheets/stylus` to the `public/stylesheets` folder. For instance, `public/stylesheets/stylus/application.styl` would generate `public/stylesheets/application.css`.
17
17
 
18
+ ## Changelog
19
+ [here.](https://github.com/lucasmazza/stylus_rails/blob/master/CHANGELOG.md)
20
+
18
21
  ## License
19
22
 
20
23
  (The MIT License)
@@ -7,8 +7,11 @@ module Stylus
7
7
  end
8
8
 
9
9
  def call
10
- paths.each do |file|
11
- system("stylus #{file} -o #{css_folder(file)}")
10
+ directories = group_paths
11
+
12
+ directories.each_pair do |directory, files|
13
+ FileUtils.mkdir_p(directory) unless File.directory?(directory)
14
+ system("stylus #{files.join(" ")} -o #{directory}#{' -C' if Stylus.compress?}")
12
15
  end
13
16
  end
14
17
 
@@ -17,6 +20,14 @@ module Stylus
17
20
  File.dirname(File.dirname(path))
18
21
  end
19
22
 
23
+ def group_paths
24
+ directories = Hash.new { |h, k| h[k] = [] }
25
+ paths.each do |path|
26
+ directories[css_folder(path)] << path
27
+ end
28
+ directories
29
+ end
30
+
20
31
  def should_parse?(path)
21
32
  File.extname(path) == ".#{Stylus.extension}" && File.file?(path) && File.basename(path) !~ /^_/
22
33
  end
@@ -13,23 +13,29 @@ module Stylus
13
13
  mattr_accessor :extension
14
14
  @@extension = "styl"
15
15
 
16
- def self.compile
17
- paths = Dir[File.join(folder, "**", "*.#{extension}")]
18
- Stylus::Runner.new(paths).call
16
+ mattr_accessor :compress
17
+ @@compress = true
18
+
19
+ class << self
20
+ alias_method :compress?, :compress
21
+
22
+ def compile
23
+ paths = Dir[File.join(folder, "**", "*.#{extension}")]
24
+ Stylus::Runner.new(paths).call
25
+ end
26
+ def message
27
+ <<-warn
28
+
29
+ Warning: 'stylus' executable was not found on your system.
30
+ Check stylus docs about installation at https://github.com/LearnBoost/stylus
31
+ and be sure to have node.js and npm properly installed.
32
+
33
+ warn
34
+ end
35
+
36
+ protected
37
+ def folder
38
+ File.join(root, directory)
39
+ end
19
40
  end
20
- def self.message
21
- <<-warn
22
-
23
- Warning: 'stylus' executable was not found on your system.
24
- Check stylus docs about installation at https://github.com/LearnBoost/stylus
25
- and be sure to have node.js and npm properly installed.
26
-
27
- warn
28
- end
29
-
30
- protected
31
- def self.folder
32
- File.join(root, directory)
33
- end
34
-
35
41
  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,4 @@
1
+ body {
2
+ background-color: #000;
3
+ color: #fff;
4
+ }
@@ -0,0 +1,3 @@
1
+ body
2
+ background-color black
3
+ color white
data/spec/runner_spec.rb CHANGED
@@ -21,13 +21,29 @@ describe Stylus::Runner do
21
21
 
22
22
  describe "#call" do
23
23
  subject { Stylus::Runner.new(fixture("stylus/simple.styl")) }
24
+ let(:stylus_file) { fixture("stylus/simple.styl").first }
25
+ let(:target_folder) { File.dirname(fixture("simple.css").first) }
26
+
27
+ before do
28
+ Stylus.compress = false
29
+ end
24
30
 
25
31
  it "calls the stylus cli" do
26
- stylus_file = fixture("stylus/simple.styl").first
27
- target_folder = File.dirname(fixture("simple.css").first)
28
32
  subject.should_receive(:system).with("stylus #{stylus_file} -o #{target_folder}")
29
33
  subject.call
30
34
  end
31
35
 
36
+ it "runs files on the same folder on a single command" do
37
+ paths = fixtures("stylus/simple.styl", "stylus/foo.styl")
38
+ subject = Stylus::Runner.new(paths)
39
+ subject.should_receive(:system).with("stylus #{paths.join(" ")} -o #{target_folder}")
40
+ subject.call
41
+ end
42
+
43
+ it "uses the compress flag when configured to" do
44
+ Stylus.compress = true
45
+ subject.should_receive(:system).with("stylus #{stylus_file} -o #{target_folder} -C")
46
+ subject.call
47
+ end
32
48
  end
33
49
  end
data/stylus_rails.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["luc4smazza@gmail.com"]
11
11
  s.homepage = "http://rubygems.org/gems/stylus_rails"
12
12
  s.summary = %q{Stylus stylesheets for Rails apps}
13
- s.description = %q{Rails engine to compile .styl files between requests}
13
+ s.description = %q{Rails plugin to compile .styl files between requests}
14
14
 
15
15
  s.add_dependency "activesupport", "~> 3.0"
16
16
  s.add_development_dependency "rspec", "~> 2.4"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stylus_rails
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-02-01 00:00:00 -02:00
18
+ date: 2011-02-02 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  version: "2.4"
49
49
  type: :development
50
50
  version_requirements: *id002
51
- description: Rails engine to compile .styl files between requests
51
+ description: Rails plugin to compile .styl files between requests
52
52
  email:
53
53
  - luc4smazza@gmail.com
54
54
  executables: []
@@ -59,6 +59,7 @@ extra_rdoc_files: []
59
59
 
60
60
  files:
61
61
  - .gitignore
62
+ - CHANGELOG.md
62
63
  - Gemfile
63
64
  - LICENSE
64
65
  - README.md
@@ -69,9 +70,11 @@ files:
69
70
  - lib/stylus_rails/stylus.rb
70
71
  - lib/stylus_rails/tasks/tasks.rake
71
72
  - lib/stylus_rails/version.rb
73
+ - spec/fixtures/foo.css
72
74
  - spec/fixtures/simple.css
73
75
  - spec/fixtures/style.css
74
76
  - spec/fixtures/stylus/_border_radius.styl
77
+ - spec/fixtures/stylus/foo.styl
75
78
  - spec/fixtures/stylus/simple.styl
76
79
  - spec/runner_spec.rb
77
80
  - spec/spec_helper.rb
@@ -111,9 +114,11 @@ signing_key:
111
114
  specification_version: 3
112
115
  summary: Stylus stylesheets for Rails apps
113
116
  test_files:
117
+ - spec/fixtures/foo.css
114
118
  - spec/fixtures/simple.css
115
119
  - spec/fixtures/style.css
116
120
  - spec/fixtures/stylus/_border_radius.styl
121
+ - spec/fixtures/stylus/foo.styl
117
122
  - spec/fixtures/stylus/simple.styl
118
123
  - spec/runner_spec.rb
119
124
  - spec/spec_helper.rb