precssious 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/LICENSE +20 -0
- data/README.rdoc +66 -0
- data/Rakefile +48 -0
- data/VERSION +1 -0
- data/bin/precssious +6 -0
- data/lib/precssious.rb +69 -0
- data/lib/precssious/preprocessor.rb +95 -0
- data/lib/precssious/rails/controller.rb +9 -0
- data/lib/precssious/rails/routes.rb +4 -0
- data/lib/precssious/rule.rb +51 -0
- data/lib/precssious/token.rb +12 -0
- data/lib/precssious/value.rb +12 -0
- data/lib/tasks/precssious.rb +13 -0
- data/precssious.gemspec +64 -0
- data/spec/precssious_spec.rb +117 -0
- data/spec/spec_helper.rb +10 -0
- metadata +84 -0
data/.document
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Erik Hansson
|
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.rdoc
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
= precssious
|
2
|
+
|
3
|
+
This is just a hack to allow me to write nested CSS. I had trouble finding
|
4
|
+
a CSS preprocessor that actually allowed nested styles without breaking my
|
5
|
+
stylesheets.
|
6
|
+
|
7
|
+
Although I am under no illusions of the general applicability of this code
|
8
|
+
(the current implementation is very naïve), it appears to do OK with how I
|
9
|
+
write CSS.
|
10
|
+
|
11
|
+
See spec/snippets.rb for a quick list of the features it supports.
|
12
|
+
|
13
|
+
|
14
|
+
== On performance / configuration
|
15
|
+
|
16
|
+
It's probably not a good idea to serve stylesheets using precssious under
|
17
|
+
normal conditions. However, caching them in development can be a real drag.
|
18
|
+
I've used the following approach.
|
19
|
+
|
20
|
+
(1) I add a precssious dependency, and make sure it isn't loaded by default.
|
21
|
+
|
22
|
+
/config/environment.rb
|
23
|
+
|
24
|
+
config.gem 'precssious', :lib => false
|
25
|
+
|
26
|
+
(2) I add an initializer with the following code, to load precssious in
|
27
|
+
development:
|
28
|
+
|
29
|
+
/config/initializers/precssious.rb
|
30
|
+
|
31
|
+
if RAILS_ENV == 'development'
|
32
|
+
require 'precssious'
|
33
|
+
Precssious.start_rails_controller
|
34
|
+
end
|
35
|
+
|
36
|
+
This catches requests to "/stylesheets/xxx/xxx.css", and serves the content
|
37
|
+
of all stylesheets in that directory, merged into a single file. The web path
|
38
|
+
("stylesheets") and the source directory ("public/stylesheets") can both be
|
39
|
+
configured.
|
40
|
+
|
41
|
+
(3) For production, I don't want Precssious loaded at all -- instead, I
|
42
|
+
generate the stylesheets on deploy. Require 'tasks/precssious' from within
|
43
|
+
your Rakefile to make the task available, and then add something like the
|
44
|
+
following to /config/deploy.rb
|
45
|
+
|
46
|
+
/config/deploy.rb
|
47
|
+
|
48
|
+
after "deploy:update_code" do
|
49
|
+
run "cd #{current_path} && rake precssious:generate"
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
== Note on Patches/Pull Requests
|
54
|
+
|
55
|
+
* Fork the project.
|
56
|
+
* Make your feature addition or bug fix.
|
57
|
+
* Add tests for it. This is important so I don't break it in a
|
58
|
+
future version unintentionally.
|
59
|
+
* Commit, do not mess with rakefile, version, or history.
|
60
|
+
(if you want to have your own version, that is fine but
|
61
|
+
bump version in a commit by itself I can ignore when I pull)
|
62
|
+
* Send me a pull request. Bonus points for topic branches.
|
63
|
+
|
64
|
+
== Copyright
|
65
|
+
|
66
|
+
Copyright (c) 2009 Erik Hansson. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "precssious"
|
8
|
+
gem.summary = %Q{Merges CSS files and allows nested declarations}
|
9
|
+
gem.description = %Q{}
|
10
|
+
gem.email = "erik@bits2life.com"
|
11
|
+
gem.homepage = "http://github.com/erikhansson/precssious"
|
12
|
+
gem.authors = ["Erik Hansson"]
|
13
|
+
gem.add_development_dependency "rspec"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'spec/rake/spectask'
|
21
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
22
|
+
spec.libs << 'lib' << 'spec'
|
23
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
24
|
+
end
|
25
|
+
|
26
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
27
|
+
spec.libs << 'lib' << 'spec'
|
28
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
29
|
+
spec.rcov = true
|
30
|
+
end
|
31
|
+
|
32
|
+
task :spec => :check_dependencies
|
33
|
+
|
34
|
+
task :default => :spec
|
35
|
+
|
36
|
+
require 'rake/rdoctask'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
if File.exist?('VERSION')
|
39
|
+
version = File.read('VERSION')
|
40
|
+
else
|
41
|
+
version = ""
|
42
|
+
end
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "precssious #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/bin/precssious
ADDED
data/lib/precssious.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + "/precssious/rule"
|
3
|
+
require File.dirname(__FILE__) + "/precssious/value"
|
4
|
+
require File.dirname(__FILE__) + "/precssious/token"
|
5
|
+
require File.dirname(__FILE__) + "/precssious/preprocessor"
|
6
|
+
|
7
|
+
|
8
|
+
module Precssious
|
9
|
+
|
10
|
+
def self.directory=(value); @directory = value; end
|
11
|
+
def self.directory; @directory; end
|
12
|
+
def self.web_path=(value); @web_path = value; end
|
13
|
+
def self.web_path; @web_path; end
|
14
|
+
|
15
|
+
|
16
|
+
##
|
17
|
+
# Loads the Precssious controller and adds routes to it. This route matches
|
18
|
+
# [directory]/:id/:filename.css, which by default is stylesheets/:id/:filename.css.
|
19
|
+
#
|
20
|
+
def self.start_rails_controller
|
21
|
+
yield self if block_given?
|
22
|
+
|
23
|
+
@directory ||= Rails.root.join('public', 'stylesheets')
|
24
|
+
@web_path ||= 'stylesheets'
|
25
|
+
|
26
|
+
require "precssious/rails/controller"
|
27
|
+
ActionController::Routing::Routes.add_configuration_file(File.join(File.dirname(__FILE__), 'precssious', 'rails', 'routes.rb'))
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Generates CSS with names matching the directory names from all the CSS files
|
32
|
+
# included in that directory. By default searches public/stylesheets for directories
|
33
|
+
# to process (set Precssious.directory to change this).
|
34
|
+
#
|
35
|
+
def self.perform_preprocessing
|
36
|
+
yield self if block_given?
|
37
|
+
@directory ||= Rails.root.join('public', 'stylesheets') if defined?(Rails)
|
38
|
+
|
39
|
+
Dir["#{@directory}/*"].each do |dir|
|
40
|
+
if File.directory?(dir)
|
41
|
+
css = process_files(Dir["#{dir}/*.css"].sort, true)
|
42
|
+
File.open "#{dir}/#{File.basename(dir)}.css", 'w' do |file|
|
43
|
+
file.write css
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def self.process(input)
|
51
|
+
Preprocessor.new(input).rules.map { |x| x.to_s }.join "\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.process_files(files, zero = false)
|
55
|
+
result = zero ? [zero_css] : []
|
56
|
+
files.each do |filename|
|
57
|
+
File.open filename, 'r' do |file|
|
58
|
+
result << '' << "/* #{File.basename(filename)} */"
|
59
|
+
result << process(file.read)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
result.join "\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.zero_css
|
66
|
+
"html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym {border:0;font-variant:normal;}sup {vertical-align:text-top;}sub {vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
|
2
|
+
module Precssious
|
3
|
+
|
4
|
+
class Preprocessor
|
5
|
+
|
6
|
+
def initialize(input)
|
7
|
+
@tokens = []
|
8
|
+
|
9
|
+
Preprocessor.tokenize(Preprocessor.strip_comments(input)) do |t|
|
10
|
+
@tokens << t
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def pull(type = nil)
|
16
|
+
result = @tokens.shift
|
17
|
+
if type && result.type != type
|
18
|
+
raise 'Unexpected token (#{result}, #{@tokens[0]}, #{@tokens[1]}, #{@tokens[2]}, #{@tokens[3]})'
|
19
|
+
end
|
20
|
+
result
|
21
|
+
end
|
22
|
+
def peek; @tokens[0]; end
|
23
|
+
def peek2; @tokens[1] if @tokens.length > 1; end
|
24
|
+
def consume(type)
|
25
|
+
t = pull
|
26
|
+
if t.type != type
|
27
|
+
raise "Unexpected token (#{t.data}, #{@tokens[0]}, #{@tokens[1]}, #{@tokens[2]}, #{@tokens[3]}) #{t.type}, expected #{type}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def rules
|
33
|
+
result = []
|
34
|
+
while peek
|
35
|
+
result << rule
|
36
|
+
end
|
37
|
+
result
|
38
|
+
end
|
39
|
+
|
40
|
+
def rule
|
41
|
+
Rule.new pull(:text).data, rule_value
|
42
|
+
end
|
43
|
+
|
44
|
+
def rule_value
|
45
|
+
consume :lbrace
|
46
|
+
result = any
|
47
|
+
consume :rbrace
|
48
|
+
result
|
49
|
+
end
|
50
|
+
|
51
|
+
def any
|
52
|
+
result = []
|
53
|
+
while (peek.type != :rbrace)
|
54
|
+
if peek2 && peek2.type == :lbrace
|
55
|
+
result << rule
|
56
|
+
else
|
57
|
+
if peek2 && peek2.type == :semicolon
|
58
|
+
result << value
|
59
|
+
else
|
60
|
+
raise 'Unexpected CSS syntax (missing ;?)'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def value
|
68
|
+
l = pull(:text)
|
69
|
+
consume(:semicolon)
|
70
|
+
Value.new l.data
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.tokenize(input)
|
74
|
+
current = []
|
75
|
+
input.each_char do |c|
|
76
|
+
if %W({ } ;).include? c.to_s
|
77
|
+
prev = current.join('').strip
|
78
|
+
current.clear
|
79
|
+
|
80
|
+
yield Token.new(:text, prev) if prev.length > 0
|
81
|
+
yield Token.new(:lbrace, nil) if c.to_s == '{'
|
82
|
+
yield Token.new(:rbrace, nil) if c.to_s == '}'
|
83
|
+
yield Token.new(:semicolon, nil) if c.to_s == ';'
|
84
|
+
else
|
85
|
+
current << c
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.strip_comments(input)
|
91
|
+
input.gsub /\/\*.*?\*\//, ''
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
module Precssious
|
3
|
+
|
4
|
+
Rule = Struct.new :selector, :values
|
5
|
+
|
6
|
+
class Rule
|
7
|
+
def to_s(context = nil)
|
8
|
+
@context = context
|
9
|
+
r, v = values.partition { |x| Rule === x }
|
10
|
+
|
11
|
+
result = []
|
12
|
+
result << "#{selector_string} { #{v.map { |x| x.to_s }.join ' '} }" if v.length > 0
|
13
|
+
|
14
|
+
r.each do |nested|
|
15
|
+
result << nested.to_s(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
result.join "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_hack?
|
22
|
+
raw_selector_string =~ /\[[a-z0-9]*\]/
|
23
|
+
end
|
24
|
+
|
25
|
+
def selector_string
|
26
|
+
raw_selector_string.gsub /\[[a-z0-9]*\] /, ''
|
27
|
+
end
|
28
|
+
|
29
|
+
def raw_selector_string
|
30
|
+
selectors.join(', ').gsub(/\s+-/, '')
|
31
|
+
end
|
32
|
+
|
33
|
+
def selectors
|
34
|
+
reverse, current = selector.split(',').map { |x| x.strip }.partition { |s| s =~ /<>/ }
|
35
|
+
|
36
|
+
return current unless @context
|
37
|
+
|
38
|
+
result = []
|
39
|
+
|
40
|
+
@context.selectors.map do |cs|
|
41
|
+
current.map { |s| result << "#{cs} #{s}" }
|
42
|
+
end
|
43
|
+
reverse.map do |rs|
|
44
|
+
@context.selectors.map { |cs| result << "#{rs.gsub('<>', '').strip} #{cs}" }
|
45
|
+
end
|
46
|
+
|
47
|
+
result
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :precssious do
|
2
|
+
|
3
|
+
desc 'Generates the stylesheets as static resources'
|
4
|
+
task :generate => :environment do
|
5
|
+
require 'precssious'
|
6
|
+
|
7
|
+
if defined?(Rails)
|
8
|
+
Precssious.directory = Rails.root.join('public', 'stylesheets')
|
9
|
+
Precssious.perform_preprocessing
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/precssious.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{precssious}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Erik Hansson"]
|
12
|
+
s.date = %q{2009-09-09}
|
13
|
+
s.default_executable = %q{precssious}
|
14
|
+
s.description = %q{}
|
15
|
+
s.email = %q{erik@bits2life.com}
|
16
|
+
s.executables = ["precssious"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/precssious",
|
29
|
+
"lib/precssious.rb",
|
30
|
+
"lib/precssious/preprocessor.rb",
|
31
|
+
"lib/precssious/rails/controller.rb",
|
32
|
+
"lib/precssious/rails/routes.rb",
|
33
|
+
"lib/precssious/rule.rb",
|
34
|
+
"lib/precssious/token.rb",
|
35
|
+
"lib/precssious/value.rb",
|
36
|
+
"lib/tasks/precssious.rb",
|
37
|
+
"precssious.gemspec",
|
38
|
+
"spec/precssious_spec.rb",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
s.has_rdoc = true
|
42
|
+
s.homepage = %q{http://github.com/erikhansson/precssious}
|
43
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = %q{1.3.1}
|
46
|
+
s.summary = %q{Merges CSS files and allows nested declarations}
|
47
|
+
s.test_files = [
|
48
|
+
"spec/precssious_spec.rb",
|
49
|
+
"spec/spec_helper.rb"
|
50
|
+
]
|
51
|
+
|
52
|
+
if s.respond_to? :specification_version then
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
54
|
+
s.specification_version = 2
|
55
|
+
|
56
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
60
|
+
end
|
61
|
+
else
|
62
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Precssious do
|
4
|
+
describe :process do
|
5
|
+
it "should handle regular styles" do
|
6
|
+
Precssious.process(%Q(
|
7
|
+
a {
|
8
|
+
color: black;
|
9
|
+
text-decoration: none;
|
10
|
+
}
|
11
|
+
)).should == "a { color: black; text-decoration: none; }"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should handle nested styles" do
|
15
|
+
Precssious.process(%Q(
|
16
|
+
a {
|
17
|
+
b {
|
18
|
+
color: blue;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
)).should == "a b { color: blue; }"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should handle mixed nested and regular styles" do
|
25
|
+
Precssious.process(%Q(
|
26
|
+
a {
|
27
|
+
color: black;
|
28
|
+
|
29
|
+
b { color: blue; }
|
30
|
+
}
|
31
|
+
)).should == "a { color: black; }\na b { color: blue; }"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should handle listed (comma delimited) styles" do
|
35
|
+
Precssious.process(%Q(
|
36
|
+
a, b {
|
37
|
+
c {
|
38
|
+
font-weight: bold;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
)).should == "a c, b c { font-weight: bold; }"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should handle nested listed styles" do
|
45
|
+
Precssious.process(%Q(
|
46
|
+
a, b {
|
47
|
+
c, d {
|
48
|
+
font-weight: bold;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
)).should == "a c, a d, b c, b d { font-weight: bold; }"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should provide a reverse-order nesting using <>" do
|
55
|
+
Precssious.process(%Q(
|
56
|
+
a {
|
57
|
+
.outer <> { color: red; }
|
58
|
+
}
|
59
|
+
)).should == ".outer a { color: red; }"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should handle pseudoclasses" do
|
63
|
+
Precssious.process(%Q(
|
64
|
+
a { .to_movie1:hover { background-position: 0 -96px; } }
|
65
|
+
)).should == "a .to_movie1:hover { background-position: 0 -96px; }"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should handle regular listed classes" do
|
69
|
+
Precssious.process(%Q(
|
70
|
+
html, body { height: 100%; background: #c0c0c0; text-aling: center; }
|
71
|
+
)).should == "html, body { height: 100%; background: #c0c0c0; text-aling: center; }"
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should allow for nested pseudoclass selectors" do
|
75
|
+
Precssious.process(%Q(
|
76
|
+
a { -:hover { text-decoration: underline; } }
|
77
|
+
)).should == "a:hover { text-decoration: underline; }"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should allow nesting on arbitrary 'same-selector' basis" do
|
81
|
+
Precssious.process(%Q(
|
82
|
+
img {
|
83
|
+
-.mood1 { background-position: 0 0; }
|
84
|
+
-.mood2 { background-position: -70px 0; }
|
85
|
+
}
|
86
|
+
)).should == "img.mood1 { background-position: 0 0; }\nimg.mood2 { background-position: -70px 0; }"
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should allow nesting on arbitrary 'same-selector' basis, with nesting" do
|
90
|
+
Precssious.process(%Q(
|
91
|
+
img, p {
|
92
|
+
-.mood1 { background-position: 0 0; }
|
93
|
+
-.mood2 { background-position: -70px 0; }
|
94
|
+
}
|
95
|
+
)).should == "img.mood1, p.mood1 { background-position: 0 0; }\nimg.mood2, p.mood2 { background-position: -70px 0; }"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should ignore CSS comments" do
|
99
|
+
Precssious.process(%Q(
|
100
|
+
/* Prestyle comment. */
|
101
|
+
a {
|
102
|
+
color: black; /* One in here, too */
|
103
|
+
text-decoration: none;
|
104
|
+
}
|
105
|
+
)).should == "a { color: black; text-decoration: none; }"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should allow a special [ie6] selector" do
|
109
|
+
Precssious.process(%Q(
|
110
|
+
[ie6] a {
|
111
|
+
color: black;
|
112
|
+
text-decoration: none;
|
113
|
+
}
|
114
|
+
)).should == "a { color: black; text-decoration: none; }"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: precssious
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Erik Hansson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-02 00:00:00 +02:00
|
14
|
+
default_executable: precssious
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rspec
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "0"
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
description: ""
|
28
|
+
email: erik@bits2life.com
|
29
|
+
executables:
|
30
|
+
- precssious
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- LICENSE
|
35
|
+
- README.rdoc
|
36
|
+
files:
|
37
|
+
- .document
|
38
|
+
- LICENSE
|
39
|
+
- README.rdoc
|
40
|
+
- Rakefile
|
41
|
+
- VERSION
|
42
|
+
- bin/precssious
|
43
|
+
- lib/precssious.rb
|
44
|
+
- lib/precssious/preprocessor.rb
|
45
|
+
- lib/precssious/rails/controller.rb
|
46
|
+
- lib/precssious/rails/routes.rb
|
47
|
+
- lib/precssious/rule.rb
|
48
|
+
- lib/precssious/token.rb
|
49
|
+
- lib/precssious/value.rb
|
50
|
+
- lib/tasks/precssious.rb
|
51
|
+
- precssious.gemspec
|
52
|
+
- spec/precssious_spec.rb
|
53
|
+
- spec/spec_helper.rb
|
54
|
+
has_rdoc: true
|
55
|
+
homepage: http://github.com/erikhansson/precssious
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
requirements: []
|
76
|
+
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.6.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Merges CSS files and allows nested declarations
|
82
|
+
test_files:
|
83
|
+
- spec/precssious_spec.rb
|
84
|
+
- spec/spec_helper.rb
|