more 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.markdown +140 -0
- data/Rakefile +23 -0
- data/init.rb +1 -0
- data/lib/more.rb +168 -0
- data/rails/init.rb +13 -0
- data/tasks/more_tasks.rake +19 -0
- data/test/less_cache_controller_test.rb +31 -0
- data/test/more_test.rb +82 -0
- data/test/test_helper.rb +42 -0
- metadata +73 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Logan Raarup, August Lilleaas
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
More
|
2
|
+
====
|
3
|
+
|
4
|
+
*LESS on Rails.*
|
5
|
+
|
6
|
+
More is a plugin for Ruby on Rails applications. It automatically parses your applications `.less` files through LESS and outputs CSS files.
|
7
|
+
|
8
|
+
In details, More does the following:
|
9
|
+
|
10
|
+
* Recursively looks for LESS (`.less`) files in `app/stylesheets`
|
11
|
+
* Ignores partials (prefixed with underscore: `_partial.less`) - these can be included with `@import` in your LESS files
|
12
|
+
* Saves the resulting CSS files to `public/stylesheets` using the same directory structure as `app/stylesheets`
|
13
|
+
|
14
|
+
LESS
|
15
|
+
----
|
16
|
+
|
17
|
+
LESS extends CSS with: variables, mixins, operations and nested rules. For more information, see [http://lesscss.org](http://lesscss.org).
|
18
|
+
|
19
|
+
Upgrading from less-for-rails
|
20
|
+
=======================================
|
21
|
+
|
22
|
+
The old `less-for-rails` plugin looked for `.less` files in `public/stylesheets`. This plugin looks in `app/stylesheets`.
|
23
|
+
|
24
|
+
To migrate, you can either set `Less::More.source_path = Rails.root + "/public/stylesheets"`, or move your `.less` files to `app/stylesheets`.
|
25
|
+
|
26
|
+
|
27
|
+
Installation
|
28
|
+
============
|
29
|
+
|
30
|
+
More depends on the LESS gem. Please install LESS first:
|
31
|
+
|
32
|
+
$ gem install less
|
33
|
+
|
34
|
+
Rails Plugin
|
35
|
+
------------
|
36
|
+
|
37
|
+
Use this to install as a plugin in a Ruby on Rails app:
|
38
|
+
|
39
|
+
$ script/plugin install git://github.com/cloudhead/more.git
|
40
|
+
|
41
|
+
Rails Plugin (using git submodules)
|
42
|
+
-----------------------------------
|
43
|
+
|
44
|
+
Use this if you prefer to use git submodules for plugins:
|
45
|
+
|
46
|
+
$ git submodule add git://github.com/cloudhead/more.git vendor/plugins/more
|
47
|
+
$ script/runner vendor/plugins/more/install.rb
|
48
|
+
|
49
|
+
|
50
|
+
Usage
|
51
|
+
=====
|
52
|
+
|
53
|
+
Upon installation, a new directory will be created in `app/stylesheets`. Any LESS file placed in this directory, including subdirectories, will
|
54
|
+
automatically be parsed through LESS and saved as a corresponding CSS file in `public/stylesheets`. Example:
|
55
|
+
|
56
|
+
app/stylesheets/clients/screen.less => public/stylesheets/clients/screen.css
|
57
|
+
|
58
|
+
If you prefix a file with an underscore, it is considered to be a partial, and will not be parsed unless included in another file. Example:
|
59
|
+
|
60
|
+
<file: app/stylesheets/clients/partials/_form.less>
|
61
|
+
@text_dark: #222;
|
62
|
+
|
63
|
+
<file: app/stylesheets/clients/screen.less>
|
64
|
+
@import "partials/_form";
|
65
|
+
|
66
|
+
input { color: @text_dark; }
|
67
|
+
|
68
|
+
The example above will result in a single CSS file in `public/stylesheets/clients/screen.css`.
|
69
|
+
|
70
|
+
|
71
|
+
Configuration
|
72
|
+
=============
|
73
|
+
|
74
|
+
To set the source path (the location of your LESS files):
|
75
|
+
|
76
|
+
Less::More.source_path = "/path/to/less/files"
|
77
|
+
|
78
|
+
You can also set the destination path. Be careful with the formatting here, since this is in fact a route, and not a regular path.
|
79
|
+
|
80
|
+
Less::More.destination_path = "css"
|
81
|
+
|
82
|
+
More can compress your files by removing extra line breaks. This is enabled by default in the `production` environment. To change this setting, set:
|
83
|
+
|
84
|
+
Less::More.compression = true
|
85
|
+
|
86
|
+
If you're on a read-only file system, you can turn page caching off and use Cache-Control headers. This option is on by default on Heroku (see separate section).
|
87
|
+
|
88
|
+
Less::More.page_cache = false
|
89
|
+
|
90
|
+
More inserts headers in the generated CSS files, letting people know that the file is in fact generated and shouldn't be edited directly. This is by default only enabled in development mode. You can disable this behavior if you want to.
|
91
|
+
|
92
|
+
Less::More.header = false
|
93
|
+
|
94
|
+
To configure More for a specific environment, add configuration options into the environment file, such as `config/environments/development.rb`.
|
95
|
+
|
96
|
+
If you wish to apply the configuration to all environments, place them in `config/environment.rb`.
|
97
|
+
|
98
|
+
Heroku
|
99
|
+
======
|
100
|
+
|
101
|
+
The plugin works out-of-the-box on Heroku.
|
102
|
+
|
103
|
+
Heroku has a read-only file system, which means caching the generated CSS with page caching is not an option. Heroku supports caching with Varnish, though, which the plugin will leverage by setting Cache-Control headers so that generated CSS is cached for one month.
|
104
|
+
|
105
|
+
Tasks
|
106
|
+
=====
|
107
|
+
|
108
|
+
More provides a set of Rake tasks to help manage your CSS files.
|
109
|
+
|
110
|
+
To parse all LESS files and save the resulting CSS files to the destination path, run:
|
111
|
+
|
112
|
+
$ rake more:parse
|
113
|
+
|
114
|
+
To delete all generated CSS files, run:
|
115
|
+
|
116
|
+
$ rake more:clean
|
117
|
+
|
118
|
+
This task will not delete any CSS files from the destination path, that does not have a corresponding LESS file in the source path.
|
119
|
+
|
120
|
+
|
121
|
+
Git
|
122
|
+
===
|
123
|
+
|
124
|
+
If you are using git to version control your code and LESS for all your stylesheets, you can add this entry to your `.gitignore` file:
|
125
|
+
|
126
|
+
public/stylesheets
|
127
|
+
|
128
|
+
|
129
|
+
Documentation
|
130
|
+
=============
|
131
|
+
|
132
|
+
To view the full RDoc documentation, go to [http://rdoc.info/projects/cloudhead/more](http://rdoc.info/projects/cloudhead/more)
|
133
|
+
|
134
|
+
|
135
|
+
Contributors
|
136
|
+
============
|
137
|
+
* August Lilleaas ([http://github.com/augustl](http://github.com/augustl))
|
138
|
+
* Logan Raarup ([http://github.com/logandk](http://github.com/logandk))
|
139
|
+
|
140
|
+
LESS is maintained by Alexis Sellier [http://github.com/cloudhead](http://github.com/cloudhead)
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the more plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the more plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'More'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.markdown')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'rails', 'init')
|
data/lib/more.rb
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
# Less::More provides methods for parsing LESS files in a rails application to CSS target files.
|
2
|
+
#
|
3
|
+
# When Less::More.parse is called, all files in Less::More.source_path will be parsed using LESS
|
4
|
+
# and saved as CSS files in Less::More.destination_path. If Less::More.compression is set to true,
|
5
|
+
# extra line breaks will be removed to compress the CSS files.
|
6
|
+
#
|
7
|
+
# By default, Less::More.parse will be called for each request in `development` environment and on
|
8
|
+
# application initialization in `production` environment.
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'less'
|
12
|
+
rescue LoadError => e
|
13
|
+
e.message << " (You may need to install the less gem)"
|
14
|
+
raise e
|
15
|
+
end
|
16
|
+
|
17
|
+
class Less::More
|
18
|
+
DEFAULTS = {
|
19
|
+
"production" => {
|
20
|
+
:compression => true,
|
21
|
+
:header => false,
|
22
|
+
:page_cache => true,
|
23
|
+
:destination_path => "stylesheets"
|
24
|
+
},
|
25
|
+
"development" => {
|
26
|
+
:compression => false,
|
27
|
+
:header => true,
|
28
|
+
:page_cache => false,
|
29
|
+
:destination_path => "stylesheets"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
HEADER = %{/*\n\n\n\n\n\tThis file was auto generated by Less (http://lesscss.org). To change the contents of this file, edit %s instead.\n\n\n\n\n*/}
|
34
|
+
|
35
|
+
class << self
|
36
|
+
attr_writer :compression, :header, :page_cache, :destination_path
|
37
|
+
|
38
|
+
# Returns true if compression is enabled. By default, compression is enabled in the production environment
|
39
|
+
# and disabled in the development and test environments. This value can be changed using:
|
40
|
+
#
|
41
|
+
# Less::More.compression = true
|
42
|
+
#
|
43
|
+
# You can put this line into config/environments/development.rb to enable compression for the development environments
|
44
|
+
def compression?
|
45
|
+
get_cvar(:compression)
|
46
|
+
end
|
47
|
+
|
48
|
+
# TODO: Use controllers and page cache to generate the files.
|
49
|
+
def page_cache?
|
50
|
+
(not heroku?) && get_cvar(:page_cache)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Tells the plugin to prepend HEADER to all generated CSS, informing users
|
54
|
+
# opening raw .css files that the file is auto-generated and that the
|
55
|
+
# .less file should be edited instead.
|
56
|
+
#
|
57
|
+
# Less::More.header = false
|
58
|
+
def header
|
59
|
+
result = get_cvar(:header)
|
60
|
+
get_cvar(:header) ? DEFAULT_HEADER : ""
|
61
|
+
end
|
62
|
+
|
63
|
+
# The path, or route, where you want your .css files to live.
|
64
|
+
def destination_path
|
65
|
+
get_cvar(:destination_path)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Gets user set values or DEFAULTS. User set values gets precedence.
|
69
|
+
def get_cvar(cvar)
|
70
|
+
instance_variable_get("@#{cvar}") || (DEFAULTS[Rails.env] || DEFAULTS["production"])[cvar]
|
71
|
+
end
|
72
|
+
|
73
|
+
# Returns true if the app is running on Heroku. When +heroku?+ is true,
|
74
|
+
# +page_cache?+ will always be false.
|
75
|
+
def heroku?
|
76
|
+
!!ENV["HEROKU_ENV"]
|
77
|
+
end
|
78
|
+
|
79
|
+
# Returns the LESS source path, see `source_path=`
|
80
|
+
def source_path
|
81
|
+
@source_path || Rails.root.join("app", "stylesheets")
|
82
|
+
end
|
83
|
+
|
84
|
+
# Sets the source path for LESS files. This directory will be scanned recursively for all *.less files. Files prefixed
|
85
|
+
# with an underscore is considered to be partials and are not parsed directly. These files can be included using `@import`
|
86
|
+
# statements. *Example partial filename: _form.less*
|
87
|
+
#
|
88
|
+
# Default value is app/stylesheets
|
89
|
+
#
|
90
|
+
# Examples:
|
91
|
+
# Less::More.source_path = "/path/to/less/files"
|
92
|
+
# Less::More.source_path = Pathname.new("/other/path")
|
93
|
+
def source_path=(path)
|
94
|
+
@source_path = Pathname.new(path.to_s)
|
95
|
+
end
|
96
|
+
|
97
|
+
# Checks if a .less or .lss file exists in Less::More.source_path matching
|
98
|
+
# the given parameters.
|
99
|
+
#
|
100
|
+
# Less::More.exists?(["screen"])
|
101
|
+
# Less::More.exists?(["subdirectories", "here", "homepage"])
|
102
|
+
def exists?(path_as_array)
|
103
|
+
return false if path_as_array[-1].starts_with?("_")
|
104
|
+
|
105
|
+
pathname = pathname_from_array(path_as_array)
|
106
|
+
pathname && pathname.exist?
|
107
|
+
end
|
108
|
+
|
109
|
+
# Generates the .css from a .less or .lss file in Less::More.source_path matching
|
110
|
+
# the given parameters.
|
111
|
+
#
|
112
|
+
# Less::More.generate(["screen"])
|
113
|
+
# Less::More.generate(["subdirectories", "here", "homepage"])
|
114
|
+
#
|
115
|
+
# Returns the CSS as a string.
|
116
|
+
def generate(path_as_array)
|
117
|
+
source = pathname_from_array(path_as_array)
|
118
|
+
engine = File.open(source) {|f| Less::Engine.new(f) }
|
119
|
+
css = engine.to_css
|
120
|
+
css.delete!("\n") if self.compression?
|
121
|
+
css
|
122
|
+
end
|
123
|
+
|
124
|
+
# Generates all the .css files.
|
125
|
+
def parse
|
126
|
+
Less::More.all_less_files.each do |path|
|
127
|
+
# Get path
|
128
|
+
relative_path = path.relative_path_from(Less::More.source_path)
|
129
|
+
path_as_array = relative_path.to_s.split(File::SEPARATOR)
|
130
|
+
path_as_array[-1] = File.basename(path_as_array[-1], File.extname(path_as_array[-1]))
|
131
|
+
|
132
|
+
# Generate CSS
|
133
|
+
css = Less::More.generate(path_as_array)
|
134
|
+
|
135
|
+
# Store CSS
|
136
|
+
path_as_array[-1] = path_as_array[-1] + ".css"
|
137
|
+
destination = Pathname.new(File.join(Rails.root, "public", Less::More.destination_path)).join(*path_as_array)
|
138
|
+
destination.dirname.mkpath
|
139
|
+
|
140
|
+
File.open(destination, "w") {|f|
|
141
|
+
f.puts css
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Removes all generated css files.
|
147
|
+
def clean
|
148
|
+
all_less_files.each do |path|
|
149
|
+
relative_path = path.relative_path_from(Less::More.source_path)
|
150
|
+
css_path = relative_path.to_s.sub(/le?ss$/, "css")
|
151
|
+
css_file = File.join(Rails.root, "public", Less::More.destination_path, css_path)
|
152
|
+
File.delete(css_file) if File.file?(css_file)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Array of Pathname instances for all the less source files.
|
157
|
+
def all_less_files
|
158
|
+
Dir[Less::More.source_path.join("**", "*.{less,lss}")].map! {|f| Pathname.new(f) }
|
159
|
+
end
|
160
|
+
|
161
|
+
# Converts ["foo", "bar"] into a `Pathname` based on Less::More.source_path.
|
162
|
+
def pathname_from_array(array)
|
163
|
+
path_spec = array.dup
|
164
|
+
path_spec[-1] = path_spec[-1] + ".{less,lss}"
|
165
|
+
Pathname.glob(self.source_path.join(*path_spec))[0]
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
data/rails/init.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'less'
|
3
|
+
rescue LoadError => e
|
4
|
+
e.message << " (You may need to install the less gem)"
|
5
|
+
raise e
|
6
|
+
end
|
7
|
+
|
8
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'more')
|
9
|
+
|
10
|
+
config.after_initialize {
|
11
|
+
Less::More.clean
|
12
|
+
Less::More.parse if Less::More.page_cache?
|
13
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'less'
|
2
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'more')
|
3
|
+
|
4
|
+
namespace :more do
|
5
|
+
desc "Generate CSS files from LESS files"
|
6
|
+
task :parse => :environment do
|
7
|
+
puts "Parsing files from #{Less::More.source_path}."
|
8
|
+
Less::More.parse
|
9
|
+
puts "Done."
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Remove generated CSS files"
|
14
|
+
task :clean => :environment do
|
15
|
+
puts "Deleting files.."
|
16
|
+
Less::More.clean
|
17
|
+
puts "Done."
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class LessCacheControllerTest < ActionController::IntegrationTest
|
4
|
+
def setup
|
5
|
+
Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
|
6
|
+
end
|
7
|
+
|
8
|
+
test "regular stylesheet" do
|
9
|
+
get "stylesheets/test.css"
|
10
|
+
assert_response :success
|
11
|
+
assert @response.body.include?("body { color: #222222; }")
|
12
|
+
end
|
13
|
+
|
14
|
+
test "sub-folder" do
|
15
|
+
get "stylesheets/sub/test2.css"
|
16
|
+
assert_response :success
|
17
|
+
assert @response.body.include?("div { display: none; }")
|
18
|
+
end
|
19
|
+
|
20
|
+
test "404" do
|
21
|
+
Less::More.expects(:generate).never
|
22
|
+
get "stylesheets/does_not_exist.css"
|
23
|
+
assert_response 404
|
24
|
+
end
|
25
|
+
|
26
|
+
test "setting headers with page cache" do
|
27
|
+
Less::More.expects(:page_cache?).returns(false)
|
28
|
+
get "stylesheets/test.css"
|
29
|
+
assert @response.headers["Cache-Control"]
|
30
|
+
end
|
31
|
+
end
|
data/test/more_test.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MoreTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
class << Less::More
|
6
|
+
[:@compression, :@header, :@page_cache].each {|v| remove_instance_variable(v) if instance_variable_defined?(v) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
def test_getting_config_from_current_environment_or_defaults_to_production
|
12
|
+
Less::More::DEFAULTS["development"]["foo"] = 5
|
13
|
+
Less::More::DEFAULTS["production"]["foo"] = 10
|
14
|
+
|
15
|
+
Rails.expects(:env).returns("development")
|
16
|
+
assert_equal 5, Less::More.get_cvar("foo")
|
17
|
+
|
18
|
+
Rails.expects(:env).returns("production")
|
19
|
+
assert_equal 10, Less::More.get_cvar("foo")
|
20
|
+
|
21
|
+
Rails.expects(:env).returns("staging")
|
22
|
+
assert_equal 10, Less::More.get_cvar("foo")
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_cvar_gets_predesence_for_user_values
|
26
|
+
Less::More::DEFAULTS["development"][:page_cache] = false
|
27
|
+
assert_equal false, Less::More.page_cache?
|
28
|
+
|
29
|
+
Less::More.page_cache = true
|
30
|
+
assert_equal true, Less::More.page_cache?
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_page_cache_off_on_heroku
|
34
|
+
Less::More.page_cache = true
|
35
|
+
Less::More::DEFAULTS["development"][:page_cache] = true
|
36
|
+
|
37
|
+
# The party pooper
|
38
|
+
Less::More.expects(:heroku?).returns(true)
|
39
|
+
|
40
|
+
assert_equal false, Less::More.page_cache?
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_compression
|
44
|
+
Less::More.compression = true
|
45
|
+
assert_equal Less::More.compression?, true
|
46
|
+
|
47
|
+
Less::More.compression = false
|
48
|
+
assert_equal Less::More.compression?, false
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_source_path
|
52
|
+
Less::More.source_path = "/path/to/flaf"
|
53
|
+
assert_equal Pathname.new("/path/to/flaf"), Less::More.source_path
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_exists
|
57
|
+
Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
|
58
|
+
|
59
|
+
assert Less::More.exists?(["test"])
|
60
|
+
assert Less::More.exists?(["short"])
|
61
|
+
assert Less::More.exists?(["sub", "test2"])
|
62
|
+
|
63
|
+
# Partials does not exist
|
64
|
+
assert !Less::More.exists?(["_global"])
|
65
|
+
assert !Less::More.exists?(["shared", "_form"])
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_generate
|
69
|
+
Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
|
70
|
+
Less::More.compression = true
|
71
|
+
|
72
|
+
assert_equal ".allforms { font-size: 110%; }body { color: #222222; }form { font-size: 110%; color: #ffffff;}", Less::More.generate(["test"])
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_pathname_from_array
|
76
|
+
Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
|
77
|
+
|
78
|
+
assert Less::More.pathname_from_array(["test"]).exist?
|
79
|
+
assert Less::More.pathname_from_array(["short"]).exist?
|
80
|
+
assert Less::More.pathname_from_array(["sub", "test2"]).exist?
|
81
|
+
end
|
82
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mocha'
|
5
|
+
require 'active_support'
|
6
|
+
require 'action_controller'
|
7
|
+
|
8
|
+
ActionController::Base.session_store = nil
|
9
|
+
|
10
|
+
module Rails
|
11
|
+
extend self
|
12
|
+
|
13
|
+
def env
|
14
|
+
"development"
|
15
|
+
end
|
16
|
+
|
17
|
+
def root
|
18
|
+
Pathname.new("/tmp")
|
19
|
+
end
|
20
|
+
|
21
|
+
def backtrace_cleaner
|
22
|
+
ActiveSupport::BacktraceCleaner.new
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class ApplicationController < ActionController::Base
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'less'
|
31
|
+
rescue LoadError => e
|
32
|
+
e.message << " (You may need to install the less gem)"
|
33
|
+
raise e
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'more'
|
37
|
+
|
38
|
+
# Ugh.. shouldn't these be required for us?
|
39
|
+
Dir.chdir("#{File.dirname(__FILE__)}/../") {
|
40
|
+
require "config/routes"
|
41
|
+
require 'app/controllers/less_cache_controller'
|
42
|
+
}
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: more
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexis Sellier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-08 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: less
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: " More is a plugin for Ruby on Rails applications. It automatically\n parses your applications .less files through LESS and outputs CSS files.\n"
|
26
|
+
email:
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- README.markdown
|
35
|
+
- MIT-LICENSE
|
36
|
+
- Rakefile
|
37
|
+
- init.rb
|
38
|
+
- lib/more.rb
|
39
|
+
- rails/init.rb
|
40
|
+
- tasks/more_tasks.rake
|
41
|
+
- test/test_helper.rb
|
42
|
+
- test/less_cache_controller_test.rb
|
43
|
+
- test/more_test.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage: http://github.com/cloudhead/more
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 1.3.5
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: LESS on Rails
|
72
|
+
test_files: []
|
73
|
+
|