Skip to content
Browse files

removing old version of more plugin

  • Loading branch information...
1 parent 8a1f068 commit 3c32f399e6756b1148cd4cb00d6899c7cfeb3dfe @rick committed Jul 23, 2010
View
20 vendor/plugins/more/MIT-LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2009 Logan Raarup, August Lilleaas
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
138 vendor/plugins/more/README.markdown
@@ -1,138 +0,0 @@
-More
-====
-
-*LESS on Rails.*
-
-More is a plugin for Ruby on Rails applications. It automatically parses your applications `.less` files through LESS and outputs CSS files.
-
-In details, More does the following:
-
-* Recursively looks for LESS (`.less`) files in `app/stylesheets`
-* Ignores partials (prefixed with underscore: `_partial.less`) - these can be included with `@import` in your LESS files
-* Saves the resulting CSS files to `public/stylesheets` using the same directory structure as `app/stylesheets`
-
-LESS
-----
-
-LESS extends CSS with: variables, mixins, operations and nested rules. For more information, see [http://lesscss.org](http://lesscss.org).
-
-Upgrading from less-for-rails
-=======================================
-
-The old `less-for-rails` plugin looked for `.less` files in `public/stylesheets`. This plugin looks in `app/stylesheets`.
-
-To migrate, you can either set `Less::More.source_path = Rails.root + "/public/stylesheets"`, or move your `.less` files to `app/stylesheets`.
-
-
-Installation
-============
-
-More depends on the LESS gem. Please install LESS first:
-
- $ gem install less
-
-Rails Plugin
-------------
-
-Use this to install as a plugin in a Ruby on Rails app:
-
- $ script/plugin install git://github.com/cloudhead/more.git
-
-Rails Plugin (using git submodules)
------------------------------------
-
-Use this if you prefer to use git submodules for plugins:
-
- $ git submodule add git://github.com/cloudhead/more.git vendor/plugins/more
- $ script/runner vendor/plugins/more/install.rb
-
-
-Usage
-=====
-
-Upon installation, a new directory will be created in `app/stylesheets`. Any LESS file placed in this directory, including subdirectories, will
-automatically be parsed through LESS and saved as a corresponding CSS file in `public/stylesheets`. Example:
-
- app/stylesheets/clients/screen.less => public/stylesheets/clients/screen.css
-
-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:
-
- <file: app/stylesheets/clients/partials/_form.less>
- @text_dark: #222;
-
- <file: app/stylesheets/clients/screen.less>
- @import "partials/_form";
-
- input { color: @text_dark; }
-
-The example above will result in a single CSS file in `public/stylesheets/clients/screen.css`.
-
-Any `.css` file placed in `app/stylesheets` will be copied into `public/stylesheets` without being parsed through LESS.
-
-
-Configuration
-=============
-
-To set the source path (the location of your LESS files):
-
- Less::More.source_path = "/path/to/less/files"
-
-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.
-
- Less::More.destination_path = "css"
-
-More can compress your files by removing extra line breaks. This is enabled by default in the `production` environment. To change this setting, set:
-
- Less::More.compression = true
-
-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.
-
- Less::More.header = false
-
-To configure More for a specific environment, add configuration options into the environment file, such as `config/environments/development.rb`.
-
-If you wish to apply the configuration to all environments, place them in `config/environment.rb`.
-
-Heroku
-======
-
-The plugin works out-of-the-box on Heroku.
-
-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.
-
-Tasks
-=====
-
-More provides a set of Rake tasks to help manage your CSS files.
-
-To parse all LESS files and save the resulting CSS files to the destination path, run:
-
- $ rake more:parse
-
-To delete all generated CSS files, run:
-
- $ rake more:clean
-
-This task will not delete any CSS files from the destination path, that does not have a corresponding LESS file in the source path.
-
-
-Git
-===
-
-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:
-
- public/stylesheets
-
-
-Documentation
-=============
-
-To view the full RDoc documentation, go to [http://rdoc.info/projects/cloudhead/more](http://rdoc.info/projects/cloudhead/more)
-
-
-Contributors
-============
-* August Lilleaas ([http://github.com/augustl](http://github.com/augustl))
-* Logan Raarup ([http://github.com/logandk](http://github.com/logandk))
-
-LESS is maintained by Alexis Sellier [http://github.com/cloudhead](http://github.com/cloudhead)
View
23 vendor/plugins/more/Rakefile
@@ -1,23 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the more plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the more plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'More'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README.markdown')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
View
22 vendor/plugins/more/app/controllers/less_cache_controller.rb
@@ -1,22 +0,0 @@
-class LessCacheController < ApplicationController
- caches_page :show, :if => proc { Less::More.page_cache? }
- write_inheritable_attribute('filter_chain', FilterChain.new)
-
- def show
- path_spec = params[:id]
-
- if Less::More.exists?(params[:id])
- headers['Cache-Control'] = 'public; max-age=2592000' unless Less::More.page_cache? # Cache for a month.
- render :text => Less::More.generate(params[:id]), :content_type => "text/css"
- else
- render :nothing => true, :status => 404
- end
- end
-
- private
-
- # Don't log.
- def logger
- nil
- end
-end
View
3 vendor/plugins/more/config/routes.rb
@@ -1,3 +0,0 @@
-ActionController::Routing::Routes.draw do |map|
- map.connect "#{Less::More.destination_path}/*id.css", :controller => 'less_cache', :action => "show"
-end
View
1 vendor/plugins/more/init.rb
@@ -1 +0,0 @@
-require File.join(File.dirname(__FILE__), 'rails', 'init')
View
4 vendor/plugins/more/install.rb
@@ -1,4 +0,0 @@
-require "fileutils"
-include FileUtils::Verbose
-
-mkdir_p File.join(Rails.root, "app", "stylesheets")
View
177 vendor/plugins/more/lib/more.rb
@@ -1,177 +0,0 @@
-# Less::More provides methods for parsing LESS files in a rails application to CSS target files.
-#
-# When Less::More.parse is called, all files in Less::More.source_path will be parsed using LESS
-# and saved as CSS files in Less::More.destination_path. If Less::More.compression is set to true,
-# extra line breaks will be removed to compress the CSS files.
-#
-# By default, Less::More.parse will be called for each request in `development` environment and on
-# application initialization in `production` environment.
-
-begin
- require 'less'
-rescue LoadError => e
- e.message << " (You may need to install the less gem)"
- raise e
-end
-
-class Less::More
- DEFAULTS = {
- "production" => {
- :compression => true,
- :header => false,
- :destination_path => "stylesheets"
- },
- "development" => {
- :compression => false,
- :header => true,
- :destination_path => "stylesheets"
- }
- }
-
- 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*/}
-
- class << self
- attr_writer :compression, :header, :page_cache, :destination_path
-
- # Returns true if compression is enabled. By default, compression is enabled in the production environment
- # and disabled in the development and test environments. This value can be changed using:
- #
- # Less::More.compression = true
- #
- # You can put this line into config/environments/development.rb to enable compression for the development environments
- def compression?
- get_cvar(:compression)
- end
-
- # Check wether or not we should page cache the generated CSS
- def page_cache?
- (not heroku?) && page_cache_enabled_in_environment_configuration?
- end
-
- # For easy mocking.
- def page_cache_enabled_in_environment_configuration?
- Rails.configuration.action_controller.perform_caching
- end
-
- # Tells the plugin to prepend HEADER to all generated CSS, informing users
- # opening raw .css files that the file is auto-generated and that the
- # .less file should be edited instead.
- #
- # Less::More.header = false
- def header?
- get_cvar(:header)
- end
-
- # The path, or route, where you want your .css files to live.
- def destination_path
- get_cvar(:destination_path)
- end
-
- # Gets user set values or DEFAULTS. User set values gets precedence.
- def get_cvar(cvar)
- instance_variable_get("@#{cvar}") || (DEFAULTS[Rails.env] || DEFAULTS["production"])[cvar]
- end
-
- # Returns true if the app is running on Heroku. When +heroku?+ is true,
- # +page_cache?+ will always be false.
- def heroku?
- !!ENV["HEROKU_ENV"]
- end
-
- # Returns the LESS source path, see `source_path=`
- def source_path
- @source_path || Rails.root.join("app", "stylesheets")
- end
-
- # Sets the source path for LESS files. This directory will be scanned recursively for all *.less files. Files prefixed
- # with an underscore is considered to be partials and are not parsed directly. These files can be included using `@import`
- # statements. *Example partial filename: _form.less*
- #
- # Default value is app/stylesheets
- #
- # Examples:
- # Less::More.source_path = "/path/to/less/files"
- # Less::More.source_path = Pathname.new("/other/path")
- def source_path=(path)
- @source_path = Pathname.new(path.to_s)
- end
-
- # Checks if a .less or .lss file exists in Less::More.source_path matching
- # the given parameters.
- #
- # Less::More.exists?(["screen"])
- # Less::More.exists?(["subdirectories", "here", "homepage"])
- def exists?(path_as_array)
- return false if path_as_array[-1].starts_with?("_")
-
- pathname = pathname_from_array(path_as_array)
- pathname && pathname.exist?
- end
-
- # Generates the .css from a .less or .lss file in Less::More.source_path matching
- # the given parameters.
- #
- # Less::More.generate(["screen"])
- # Less::More.generate(["subdirectories", "here", "homepage"])
- #
- # Returns the CSS as a string.
- def generate(path_as_array)
- source = pathname_from_array(path_as_array)
-
- if source.extname == ".css"
- css = File.read(source)
- else
- engine = File.open(source) {|f| Less::Engine.new(f) }
- css = engine.to_css
- css.delete!("\n") if self.compression?
- css = (HEADER % [source.to_s]) << css if self.header?
- end
-
- css
- end
-
- # Generates all the .css files.
- def parse
- Less::More.all_less_files.each do |path|
- # Get path
- relative_path = path.relative_path_from(Less::More.source_path)
- path_as_array = relative_path.to_s.split(File::SEPARATOR)
- path_as_array[-1] = File.basename(path_as_array[-1], File.extname(path_as_array[-1]))
-
- # Generate CSS
- css = Less::More.generate(path_as_array)
-
- # Store CSS
- path_as_array[-1] = path_as_array[-1] + ".css"
- destination = Pathname.new(File.join(Rails.root, "public", Less::More.destination_path)).join(*path_as_array)
- destination.dirname.mkpath
-
- File.open(destination, "w") {|f|
- f.puts css
- }
- end
- end
-
- # Removes all generated css files.
- def clean
- all_less_files.each do |path|
- relative_path = path.relative_path_from(Less::More.source_path)
- css_path = relative_path.to_s.sub(/(le?|c)ss$/, "css")
- css_file = File.join(Rails.root, "public", Less::More.destination_path, css_path)
- File.delete(css_file) if File.file?(css_file)
- end
- end
-
- # Array of Pathname instances for all the less source files.
- def all_less_files
- Dir[Less::More.source_path.join("**", "*.{css,less,lss}")].map! {|f| Pathname.new(f) }
- end
-
- # Converts ["foo", "bar"] into a `Pathname` based on Less::More.source_path.
- def pathname_from_array(array)
- path_spec = array.dup
- path_spec[-1] = path_spec[-1] + ".{css,less,lss}"
- Pathname.glob(File.join(self.source_path.to_s, *path_spec))[0]
- end
- end
-end
View
17 vendor/plugins/more/more.gemspec
@@ -1,17 +0,0 @@
-
-require 'rake'
-
-SPEC = Gem::Specification.new do |s|
- s.name = "more"
- s.summary = "LESS on Rails"
- s.homepage = "http://github.com/cloudhead/more"
- s.description = <<-EOS
- More is a plugin for Ruby on Rails applications. It automatically
- parses your applications .less files through LESS and outputs CSS files.
- EOS
- s.authors = ["August Lilleaas", "Logan Raarup"]
- s.version = "0.0.4"
- s.files = FileList["README.markdown", "MIT-LICENSE", "Rakefile", "init.rb", "lib/*.rb", "rails/init.rb", "tasks/*", "test/*"]
- s.has_rdoc = true
- s.add_dependency "less"
-end
View
6 vendor/plugins/more/rails/init.rb
@@ -1,6 +0,0 @@
-require File.join(File.dirname(__FILE__), '..', 'lib', 'more')
-
-config.after_initialize {
- Less::More.clean
- Less::More.parse if Less::More.page_cache?
-}
View
19 vendor/plugins/more/tasks/more_tasks.rake
@@ -1,19 +0,0 @@
-require 'less'
-require File.join(File.dirname(__FILE__), '..', 'lib', 'more')
-
-namespace :more do
- desc "Generate CSS files from LESS files"
- task :parse => :environment do
- puts "Parsing files from #{Less::More.source_path}."
- Less::More.parse
- puts "Done."
-
- end
-
- desc "Remove generated CSS files"
- task :clean => :environment do
- puts "Deleting files.."
- Less::More.clean
- puts "Done."
- end
-end
View
41 vendor/plugins/more/test/less_cache_controller_test.rb
@@ -1,41 +0,0 @@
-require 'test_helper'
-
-class LessCacheControllerTest < ActionController::IntegrationTest
- def setup
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
- end
-
- test "regular stylesheet" do
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(true).at_least_once
- get "stylesheets/test.css"
- assert_response :success
- assert @response.body.include?("body { color: #222222; }")
- end
-
- test "sub-folder" do
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(true).at_least_once
- get "stylesheets/sub/test2.css"
- assert_response :success
- assert @response.body.include?("div { display: none; }")
- end
-
- test "plain css stylesheet" do
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(true).at_least_once
- get "stylesheets/plain.css"
- assert_response :success
- assert @response.body.include?("div { width: 1 + 1 }")
- end
-
- test "404" do
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(true)
- Less::More.expects(:generate).never
- get "stylesheets/does_not_exist.css"
- assert_response 404
- end
-
- test "setting headers with page cache" do
- Less::More.expects(:page_cache?).returns(false)
- get "stylesheets/test.css"
- assert @response.headers["Cache-Control"]
- end
-end
View
2 vendor/plugins/more/test/less_files/_global.less
@@ -1,2 +0,0 @@
-@text_light: #ffffff;
-@text_dark: #222222;
View
2 vendor/plugins/more/test/less_files/plain.css
@@ -1,2 +0,0 @@
-/* This file should not be parsed through LESS */
-div { width: 1 + 1 }
View
3 vendor/plugins/more/test/less_files/shared/_form.less
@@ -1,3 +0,0 @@
-.allforms {
- font-size: 110%;
-}
View
1 vendor/plugins/more/test/less_files/short.lss
@@ -1 +0,0 @@
-p { color:red; }
View
1 vendor/plugins/more/test/less_files/sub/test2.less
@@ -1 +0,0 @@
-div { display:none; }
View
11 vendor/plugins/more/test/less_files/test.less
@@ -1,11 +0,0 @@
-@import "_global";
-@import "shared/_form";
-
-body {
- color: @text_dark;
-}
-
-form {
- .allforms;
- color: @text_light;
-}
View
107 vendor/plugins/more/test/more_test.rb
@@ -1,107 +0,0 @@
-require 'test_helper'
-
-class MoreTest < Test::Unit::TestCase
- def setup
- Less::More.class_eval do
- ["@compression", "@header"].each {|v|
- remove_instance_variable(v) if instance_variable_defined?(v)
- }
- end
- end
-
-
- def test_getting_config_from_current_environment_or_defaults_to_production
- Less::More::DEFAULTS["development"]["foo"] = 5
- Less::More::DEFAULTS["production"]["foo"] = 10
-
- Rails.expects(:env).returns("development")
- assert_equal 5, Less::More.get_cvar("foo")
-
- Rails.expects(:env).returns("production")
- assert_equal 10, Less::More.get_cvar("foo")
-
- Rails.expects(:env).returns("staging")
- assert_equal 10, Less::More.get_cvar("foo")
- end
-
- def test_user_settings_wins_over_defaults
- Less::More::DEFAULTS["development"][:compression] = true
- assert_equal true, Less::More.compression?
-
- Less::More::DEFAULTS["development"][:compression] = false
- assert_equal false, Less::More.compression?
-
- Less::More.compression = true
- assert_equal true, Less::More.compression?
- end
-
- def test_page_cache_is_read_from_environment_configs
- Less::More.expects(:heroku?).returns(false).times(2)
-
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(true)
- assert_equal true, Less::More.page_cache?
-
- Less::More.expects(:page_cache_enabled_in_environment_configuration?).returns(false)
- assert_equal false, Less::More.page_cache?
- end
-
- def test_page_cache_off_on_heroku
- Less::More.page_cache = true
- Less::More::DEFAULTS["development"][:page_cache] = true
-
- # The party pooper
- Less::More.expects(:heroku?).returns(true)
-
- assert_equal false, Less::More.page_cache?
- end
-
- def test_compression
- Less::More.compression = true
- assert_equal Less::More.compression?, true
-
- Less::More.compression = false
- assert_equal Less::More.compression?, false
- end
-
- def test_source_path
- Less::More.source_path = "/path/to/flaf"
- assert_equal Pathname.new("/path/to/flaf"), Less::More.source_path
- end
-
- def test_exists
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
-
- assert Less::More.exists?(["test"])
- assert Less::More.exists?(["short"])
- assert Less::More.exists?(["sub", "test2"])
-
- # Partials does not exist
- assert !Less::More.exists?(["_global"])
- assert !Less::More.exists?(["shared", "_form"])
- end
-
- def test_generate
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
- Less::More.compression = true
-
- assert Less::More.generate(["test"]).include?(".allforms { font-size: 110%; }body { color: #222222; }form { font-size: 110%; color: #ffffff;}")
- end
-
- def test_header
- Less::More.expects(:header?).returns(false)
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
- assert !Less::More.generate(["test"]).starts_with?("/*")
-
- Less::More.expects(:header?).returns(true)
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
- assert Less::More.generate(["test"]).starts_with?("/*")
- end
-
- def test_pathname_from_array
- Less::More.source_path = File.join(File.dirname(__FILE__), 'less_files')
-
- assert Less::More.pathname_from_array(["test"]).exist?
- assert Less::More.pathname_from_array(["short"]).exist?
- assert Less::More.pathname_from_array(["sub", "test2"]).exist?
- end
-end
View
42 vendor/plugins/more/test/test_helper.rb
@@ -1,42 +0,0 @@
-require 'test/unit'
-
-require 'rubygems'
-require 'mocha'
-require 'active_support'
-require 'action_controller'
-
-ActionController::Base.session_store = nil
-
-module Rails
- extend self
-
- def env
- "development"
- end
-
- def root
- Pathname.new("/tmp")
- end
-
- def backtrace_cleaner
- ActiveSupport::BacktraceCleaner.new
- end
-end
-
-class ApplicationController < ActionController::Base
-end
-
-begin
- require 'less'
-rescue LoadError => e
- e.message << " (You may need to install the less gem)"
- raise e
-end
-
-require 'more'
-
-# Ugh.. shouldn't these be required for us?
-Dir.chdir("#{File.dirname(__FILE__)}/../") {
- require "config/routes"
- require 'app/controllers/less_cache_controller'
-}

0 comments on commit 3c32f39

Please sign in to comment.
Something went wrong with that request. Please try again.