less-rails 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -1
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/less-rails.gemspec +1 -1
- data/lib/less/rails.rb +1 -1
- data/lib/less/rails/import_processor.rb +23 -0
- data/lib/less/rails/railtie.rb +2 -3
- data/lib/less/rails/version.rb +1 -1
- data/test/cases/basics_spec.rb +26 -5
- data/test/cases/railtie_spec.rb +4 -0
- data/test/dummy_app/app/assets/stylesheets/basics.css.less +3 -0
- data/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less +4 -0
- data/test/dummy_app/init.rb +1 -1
- data/test/dummy_app/tmp/.gitkeep +0 -0
- data/test/dummy_app/tmp/cache/.gitkeep +0 -0
- data/test/spec_helper.rb +24 -13
- metadata +13 -9
- data/lib/less/rails/css_compressor.rb +0 -11
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
2.1.0 - 11/18/2011
|
5
|
+
------------------
|
6
|
+
* Remove our basic CssCompressor since it can not handle real world general purpose JS
|
7
|
+
compression. Instead set parse compression and recommend final YUI Compressor. Fixes #7.
|
8
|
+
* Import preprocessor so @import'ed less files are automatic asset dependencies. Fixes #3.
|
9
|
+
|
10
|
+
|
4
11
|
2.0.3 - 11/13/2011
|
5
12
|
------------------
|
6
13
|
* Add generator support. Fixes #8.
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ end
|
|
25
25
|
|
26
26
|
#### About Compression
|
27
27
|
|
28
|
-
If `config.assets.compress` is set to true, we will set the `config.
|
28
|
+
If `config.assets.compress` is set to true, we will set the `config.less.compress` to true as well. Less has real basic compression and it is recommended that you set the rails `config.assets.css_compressor` to something more stronger like `:yui` in your `config/environments/production.rb` file. Note, this requires the [yui-compressor](https://rubygems.org/gems/yui-compressor) gem but does an excellent job of compressing assets.
|
29
29
|
|
30
30
|
|
31
31
|
|
@@ -82,7 +82,7 @@ We also have a generator for rails scaffold CSS. Just like the Sass gem, we simp
|
|
82
82
|
|
83
83
|
## Testing
|
84
84
|
|
85
|
-
|
85
|
+
Simple! Just clone the repo, then run `bundle install` and `bundle exec rake`. The tests will begin to run. We also use Travis CI to run our tests too. Current build status is:
|
86
86
|
|
87
87
|
[](http://travis-ci.org/metaskills/less-rails)
|
88
88
|
|
data/less-rails.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["ken@metaskills.net"]
|
10
10
|
s.homepage = "http://github.com/metaskills/less-rails"
|
11
11
|
s.summary = %q{The dynamic stylesheet language for the Rails asset pipeline.}
|
12
|
-
s.description = %q{The dynamic stylesheet language for the Rails asset pipeline.}
|
12
|
+
s.description = %q{The dynamic stylesheet language for the Rails asset pipeline. Allows other gems to extend Less load path.}
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
15
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
data/lib/less/rails.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Less
|
2
|
+
module Rails
|
3
|
+
class ImportProcessor < Tilt::Template
|
4
|
+
|
5
|
+
IMPORT_SCANNER = /@import\s*['"]([^'"]+)['"]\s*;/.freeze
|
6
|
+
|
7
|
+
def prepare
|
8
|
+
end
|
9
|
+
|
10
|
+
def evaluate(context, locals, &block)
|
11
|
+
import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq
|
12
|
+
import_paths.each do |path|
|
13
|
+
asset = context.environment[path]
|
14
|
+
if asset && asset.pathname.to_s.ends_with?('.less')
|
15
|
+
context.depend_on_asset(asset.pathname)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
data
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/less/rails/railtie.rb
CHANGED
@@ -20,6 +20,7 @@ module Less
|
|
20
20
|
|
21
21
|
initializer 'less-rails.before.load_config_initializers', :before => 'load_config_initializers', :group => :all do |app|
|
22
22
|
raise 'The less-rails plugin requires the asset pipeline to be enabled.' unless app.config.assets.enabled
|
23
|
+
app.assets.register_preprocessor 'text/css', ImportProcessor
|
23
24
|
end
|
24
25
|
|
25
26
|
initializer 'less-rails.after.load_config_initializers', :after => 'load_config_initializers', :group => :all do |app|
|
@@ -28,9 +29,7 @@ module Less
|
|
28
29
|
end
|
29
30
|
|
30
31
|
initializer 'less-rails.setup_compression', :group => :all do |app|
|
31
|
-
|
32
|
-
app.config.assets.css_compressor = CssCompressor.new
|
33
|
-
end
|
32
|
+
config.less.compress = app.config.assets.compress
|
34
33
|
end
|
35
34
|
|
36
35
|
end
|
data/lib/less/rails/version.rb
CHANGED
data/test/cases/basics_spec.rb
CHANGED
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
class BasicsSpec < Less::Rails::Spec
|
4
4
|
|
5
|
-
let(:basics) { dummy_asset('basics') }
|
6
|
-
|
7
5
|
it 'must render variables' do
|
8
6
|
basics.must_match %r{#test-variable\{color:#4d926f;\}}
|
9
7
|
end
|
@@ -11,9 +9,32 @@ class BasicsSpec < Less::Rails::Spec
|
|
11
9
|
it 'must render mixins' do
|
12
10
|
basics.must_match %r{#test-mixin span\{border:1px solid black;\}}
|
13
11
|
end
|
14
|
-
|
15
|
-
it 'must
|
16
|
-
|
12
|
+
|
13
|
+
it 'must hook into less import so that imported paths are declared as sprocket dependencies of the source file' do
|
14
|
+
basics.must_match %r{#test-radiused\{border-radius:5px;\}}, 'default is 5px'
|
15
|
+
safely_edit_mixins do |d|
|
16
|
+
d.gsub! '5px', '10px'
|
17
|
+
File.open(mixins_asset.pathname,'w') { |f| f.write(d) }
|
18
|
+
basics.must_match %r{#test-radiused\{border-radius:10px;\}}, 'mixins.less should be a sprockets context dependency'
|
19
|
+
end
|
17
20
|
end
|
18
21
|
|
22
|
+
protected
|
23
|
+
|
24
|
+
def basics
|
25
|
+
dummy_asset 'basics'
|
26
|
+
end
|
27
|
+
|
28
|
+
def mixins_asset
|
29
|
+
dummy_assets['frameworks/bootstrap/mixins.less']
|
30
|
+
end
|
31
|
+
|
32
|
+
def safely_edit_mixins
|
33
|
+
data = File.read(mixins_asset.pathname)
|
34
|
+
begin
|
35
|
+
yield data.dup
|
36
|
+
ensure
|
37
|
+
File.open(mixins_asset.pathname,'w') { |f| f.write(data) }
|
38
|
+
end
|
39
|
+
end
|
19
40
|
end
|
data/test/cases/railtie_spec.rb
CHANGED
@@ -34,6 +34,10 @@ class RailtieSpec < Less::Rails::Spec
|
|
34
34
|
dummy_assets.context_class.less_config.must_equal dummy_config.less
|
35
35
|
end
|
36
36
|
|
37
|
+
it 'must register our import pre processor' do
|
38
|
+
dummy_assets.preprocessors['text/css'].must_include Less::Rails::ImportProcessor
|
39
|
+
end
|
40
|
+
|
37
41
|
end
|
38
42
|
|
39
43
|
|
data/test/dummy_app/init.rb
CHANGED
File without changes
|
File without changes
|
data/test/spec_helper.rb
CHANGED
@@ -12,18 +12,31 @@ module Less
|
|
12
12
|
module Rails
|
13
13
|
|
14
14
|
class Spec < MiniTest::Spec
|
15
|
-
|
15
|
+
|
16
|
+
include FileUtils
|
17
|
+
|
18
|
+
class << self
|
19
|
+
|
20
|
+
def dummy_app
|
21
|
+
Dummy::Application
|
22
|
+
end
|
23
|
+
|
24
|
+
def dummy_tmp
|
25
|
+
"#{dummy_app.root}/tmp"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
16
30
|
before do
|
31
|
+
prepare_cache_dir
|
17
32
|
reset_config_options
|
18
33
|
reset_caches
|
19
34
|
end
|
20
35
|
|
21
36
|
protected
|
22
37
|
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
|
38
|
+
delegate :dummy_app, :dummy_tmp, :to => :'self.class'
|
39
|
+
|
27
40
|
def dummy_config
|
28
41
|
dummy_app.config
|
29
42
|
end
|
@@ -46,21 +59,23 @@ module Less
|
|
46
59
|
dummy_assets.cache.clear
|
47
60
|
end
|
48
61
|
|
62
|
+
def prepare_cache_dir
|
63
|
+
mkdir_p "#{dummy_tmp}/cache/assets"
|
64
|
+
end
|
65
|
+
|
49
66
|
end
|
50
67
|
|
51
68
|
# Heavily inspired by Rails::Generators::TestCase.
|
52
69
|
class GeneratorSpec < Spec
|
53
70
|
|
54
|
-
include FileUtils
|
55
|
-
|
56
71
|
class_attribute :destination_root, :current_path, :generator_class, :default_arguments
|
57
72
|
delegate :destination_root, :current_path, :generator_class, :default_arguments, :to => :'self.class'
|
58
73
|
|
59
74
|
self.current_path = File.expand_path(Dir.pwd)
|
60
75
|
self.default_arguments = []
|
61
|
-
self.destination_root = "#{
|
76
|
+
self.destination_root = "#{dummy_tmp}/destination_root"
|
62
77
|
|
63
|
-
before {
|
78
|
+
before { ensure_current_path ; prepare_destination ; no_color! ; setup_generator_class }
|
64
79
|
after { remove_destination ; ensure_current_path }
|
65
80
|
|
66
81
|
protected
|
@@ -69,10 +84,6 @@ module Less
|
|
69
84
|
Thor::Base.shell = Thor::Shell::Basic
|
70
85
|
end
|
71
86
|
|
72
|
-
def destination_root_is_set?
|
73
|
-
raise "You need to configure your Less::Rails::GeneratorSpec destination root." unless destination_root
|
74
|
-
end
|
75
|
-
|
76
87
|
def ensure_current_path
|
77
88
|
cd current_path
|
78
89
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: less-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 2.0.3
|
10
|
+
version: 2.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Collins
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-11-18 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: less
|
@@ -94,7 +93,7 @@ dependencies:
|
|
94
93
|
version: 3.1.1
|
95
94
|
type: :development
|
96
95
|
version_requirements: *id005
|
97
|
-
description: The dynamic stylesheet language for the Rails asset pipeline.
|
96
|
+
description: The dynamic stylesheet language for the Rails asset pipeline. Allows other gems to extend Less load path.
|
98
97
|
email:
|
99
98
|
- ken@metaskills.net
|
100
99
|
executables: []
|
@@ -115,8 +114,8 @@ files:
|
|
115
114
|
- less-rails.gemspec
|
116
115
|
- lib/less-rails.rb
|
117
116
|
- lib/less/rails.rb
|
118
|
-
- lib/less/rails/css_compressor.rb
|
119
117
|
- lib/less/rails/helpers.rb
|
118
|
+
- lib/less/rails/import_processor.rb
|
120
119
|
- lib/less/rails/railtie.rb
|
121
120
|
- lib/less/rails/template_handlers.rb
|
122
121
|
- lib/less/rails/version.rb
|
@@ -130,10 +129,12 @@ files:
|
|
130
129
|
- test/dummy_app/app/assets/images/1x1.png
|
131
130
|
- test/dummy_app/app/assets/images/rails.png
|
132
131
|
- test/dummy_app/app/assets/stylesheets/basics.css.less
|
132
|
+
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less
|
133
133
|
- test/dummy_app/app/assets/stylesheets/helpers.css.less
|
134
134
|
- test/dummy_app/init.rb
|
135
|
+
- test/dummy_app/tmp/.gitkeep
|
136
|
+
- test/dummy_app/tmp/cache/.gitkeep
|
135
137
|
- test/spec_helper.rb
|
136
|
-
has_rdoc: true
|
137
138
|
homepage: http://github.com/metaskills/less-rails
|
138
139
|
licenses: []
|
139
140
|
|
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
164
|
requirements: []
|
164
165
|
|
165
166
|
rubyforge_project:
|
166
|
-
rubygems_version: 1.
|
167
|
+
rubygems_version: 1.8.11
|
167
168
|
signing_key:
|
168
169
|
specification_version: 3
|
169
170
|
summary: The dynamic stylesheet language for the Rails asset pipeline.
|
@@ -175,6 +176,9 @@ test_files:
|
|
175
176
|
- test/dummy_app/app/assets/images/1x1.png
|
176
177
|
- test/dummy_app/app/assets/images/rails.png
|
177
178
|
- test/dummy_app/app/assets/stylesheets/basics.css.less
|
179
|
+
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less
|
178
180
|
- test/dummy_app/app/assets/stylesheets/helpers.css.less
|
179
181
|
- test/dummy_app/init.rb
|
182
|
+
- test/dummy_app/tmp/.gitkeep
|
183
|
+
- test/dummy_app/tmp/cache/.gitkeep
|
180
184
|
- test/spec_helper.rb
|