visionmedia-ass 0.0.2
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/History.rdoc +4 -0
- data/Manifest +18 -0
- data/README.rdoc +102 -0
- data/Rakefile +15 -0
- data/Todo.rdoc +27 -0
- data/ass.gemspec +39 -0
- data/bin/ass +25 -0
- data/examples/benchmarks.rb +75 -0
- data/lib/ass/parser.rb +117 -0
- data/lib/ass/version.rb +7 -0
- data/lib/ass.rb +27 -0
- data/spec/fixtures/test.ass +4 -0
- data/spec/functional/parser_spec.rb +159 -0
- data/spec/spec_helper.rb +8 -0
- data/tasks/benchmark.rake +5 -0
- data/tasks/docs.rake +13 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- metadata +100 -0
data/History.rdoc
ADDED
data/Manifest
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ass.gemspec
|
2
|
+
bin/ass
|
3
|
+
examples/benchmarks.rb
|
4
|
+
History.rdoc
|
5
|
+
lib/ass/parser.rb
|
6
|
+
lib/ass/version.rb
|
7
|
+
lib/ass.rb
|
8
|
+
Manifest
|
9
|
+
Rakefile
|
10
|
+
README.rdoc
|
11
|
+
spec/fixtures/test.ass
|
12
|
+
spec/functional/parser_spec.rb
|
13
|
+
spec/spec_helper.rb
|
14
|
+
tasks/benchmark.rake
|
15
|
+
tasks/docs.rake
|
16
|
+
tasks/gemspec.rake
|
17
|
+
tasks/spec.rake
|
18
|
+
Todo.rdoc
|
data/README.rdoc
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
|
2
|
+
= Amazing Style Sheets
|
3
|
+
|
4
|
+
Like Sass, but without the s-uck. Just kidding, Sass is great, however I am not fond of
|
5
|
+
some of the grammar choices, and for how simple the library COULD be, it is rather large.
|
6
|
+
That being said this is simply my 'flavour' of a CSS DSL.
|
7
|
+
|
8
|
+
== Features:
|
9
|
+
|
10
|
+
* Sexy, intuative grammar
|
11
|
+
* DRY with selector nesting
|
12
|
+
* Mixins
|
13
|
+
* Nesting of mixins
|
14
|
+
* Constants
|
15
|
+
* Both literal and Ass specific comments
|
16
|
+
* Commandline executable for compilation etc
|
17
|
+
* Compilation / aggregation of several files into a single file, or batches
|
18
|
+
* Has a funny name
|
19
|
+
|
20
|
+
== Installation:
|
21
|
+
|
22
|
+
$ sudo gem install visionmedia-ass
|
23
|
+
$ sudo gem install visionmedia-commander (used for executable)
|
24
|
+
|
25
|
+
== Sub-commands:
|
26
|
+
|
27
|
+
$ ass help, for more examples
|
28
|
+
$ ass compile directory_of_ass --to-dir ./directory_of_css
|
29
|
+
|
30
|
+
== Looks like:
|
31
|
+
|
32
|
+
// Constants
|
33
|
+
|
34
|
+
:primary_color = blue
|
35
|
+
|
36
|
+
// Mixins
|
37
|
+
|
38
|
+
+hidden
|
39
|
+
visibility hidden
|
40
|
+
height 0
|
41
|
+
|
42
|
+
+clearfix
|
43
|
+
display block
|
44
|
+
content '.'
|
45
|
+
clear both
|
46
|
+
+hidden
|
47
|
+
|
48
|
+
// Stylesheet
|
49
|
+
|
50
|
+
body
|
51
|
+
margin 20px 0
|
52
|
+
color :primary_color
|
53
|
+
|
54
|
+
.clear
|
55
|
+
+clearfix
|
56
|
+
|
57
|
+
h1, h2, h3
|
58
|
+
font 12px
|
59
|
+
color :primary_color
|
60
|
+
|
61
|
+
== Compiles to:
|
62
|
+
|
63
|
+
body {
|
64
|
+
margin: 20px 0;
|
65
|
+
color: blue;
|
66
|
+
}
|
67
|
+
body .clear {
|
68
|
+
visibility: hidden;
|
69
|
+
height: 0;
|
70
|
+
display: block;
|
71
|
+
content: '.';
|
72
|
+
clear: both;
|
73
|
+
}
|
74
|
+
h1, h2, h3 {
|
75
|
+
font: 12px;
|
76
|
+
color: blue;
|
77
|
+
}
|
78
|
+
|
79
|
+
== License:
|
80
|
+
|
81
|
+
(The MIT License)
|
82
|
+
|
83
|
+
Copyright (c) 2008 TJ Holowaychuk <tj@vision-media.ca>
|
84
|
+
|
85
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
86
|
+
a copy of this software and associated documentation files (the
|
87
|
+
'Software'), to deal in the Software without restriction, including
|
88
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
89
|
+
distribute, sublicense, an d/or sell copies of the Software, and to
|
90
|
+
permit persons to whom the Software is furnished to do so, subject to
|
91
|
+
the following conditions:
|
92
|
+
|
93
|
+
The above copyright notice and this permission notice shall be
|
94
|
+
included in all copies or substantial portions of the Software.
|
95
|
+
|
96
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
97
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
98
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
99
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
100
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
101
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
102
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'echoe'
|
5
|
+
require './lib/ass.rb'
|
6
|
+
|
7
|
+
Echoe.new("ass", Ass::VERSION::STRING) do |p|
|
8
|
+
p.author = "TJ Holowaychuk"
|
9
|
+
p.email = "tj@vision-media.ca"
|
10
|
+
p.summary = "'Amazing Style Sheets'"
|
11
|
+
p.url = "http://github.com/visionmedia/ass"
|
12
|
+
p.runtime_dependencies = ['visionmedia-commander']
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir['tasks/**/*.rake'].sort.each { |lib| load lib }
|
data/Todo.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
== Major:
|
3
|
+
|
4
|
+
* Real parser (remove lame/quick scripting prototype)
|
5
|
+
* Finish commander exec portion
|
6
|
+
* Revamp spec
|
7
|
+
* Revamp EOF
|
8
|
+
* Caching
|
9
|
+
* Auto-compliation on modification (optional)
|
10
|
+
* Implement in C
|
11
|
+
* Think of more cool stuff to set apart from Sass
|
12
|
+
* Benchmark VS Sass
|
13
|
+
* Order properties alphabetically
|
14
|
+
* Different compressions / aggregations of style sheets
|
15
|
+
* nested like sass:
|
16
|
+
font
|
17
|
+
weight
|
18
|
+
color
|
19
|
+
family
|
20
|
+
|
21
|
+
== Minor:
|
22
|
+
|
23
|
+
* Nothing
|
24
|
+
|
25
|
+
== Brainstorming:
|
26
|
+
|
27
|
+
* Nothing
|
data/ass.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ass}
|
5
|
+
s.version = "0.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["TJ Holowaychuk"]
|
9
|
+
s.date = %q{2009-01-15}
|
10
|
+
s.default_executable = %q{ass}
|
11
|
+
s.description = %q{'Amazing Style Sheets'}
|
12
|
+
s.email = %q{tj@vision-media.ca}
|
13
|
+
s.executables = ["ass"]
|
14
|
+
s.extra_rdoc_files = ["bin/ass", "lib/ass/parser.rb", "lib/ass/version.rb", "lib/ass.rb", "README.rdoc", "tasks/benchmark.rake", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
|
15
|
+
s.files = ["ass.gemspec", "bin/ass", "examples/benchmarks.rb", "History.rdoc", "lib/ass/parser.rb", "lib/ass/version.rb", "lib/ass.rb", "Manifest", "Rakefile", "README.rdoc", "spec/fixtures/test.ass", "spec/functional/parser_spec.rb", "spec/spec_helper.rb", "tasks/benchmark.rake", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "Todo.rdoc"]
|
16
|
+
s.has_rdoc = true
|
17
|
+
s.homepage = %q{http://github.com/visionmedia/ass}
|
18
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ass", "--main", "README.rdoc"]
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubyforge_project = %q{ass}
|
21
|
+
s.rubygems_version = %q{1.3.1}
|
22
|
+
s.summary = %q{'Amazing Style Sheets'}
|
23
|
+
|
24
|
+
if s.respond_to? :specification_version then
|
25
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
|
+
s.specification_version = 2
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_runtime_dependency(%q<visionmedia-commander>, [">= 0"])
|
30
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 0"])
|
33
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
34
|
+
end
|
35
|
+
else
|
36
|
+
s.add_dependency(%q<visionmedia-commander>, [">= 0"])
|
37
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
38
|
+
end
|
39
|
+
end
|
data/bin/ass
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'commander'
|
5
|
+
require 'ass'
|
6
|
+
|
7
|
+
program :name, 'ass'
|
8
|
+
program :version, Ass::VERSION::STRING
|
9
|
+
program :description, 'Amazing Style Sheets.'
|
10
|
+
|
11
|
+
command :compile do |c|
|
12
|
+
c.syntax = 'ass compile <file | dir ...> [options]'
|
13
|
+
c.summary = 'Compile ass files to css'
|
14
|
+
c.description = 'Compile a single, or several *.ass files into Cascading Style Sheets. The combinations of compilation below may be mixed to your needs.'
|
15
|
+
c.example 'Compile a single file with output to STDOUT', 'ass compile style.ass'
|
16
|
+
c.example 'Compile several files to a specific directory (defaults to same dir)', 'ass compile style.ass print.ass iphone.ass --to-dir ./stylesheets'
|
17
|
+
c.example 'Compile several files in a directory to a single file', 'ass compile directory_of_ass --to-file ./compiled-style.css'
|
18
|
+
c.option '--to-dir', 'Compile file(s) to a directory, maintaining their original names.'
|
19
|
+
c.option '--to-file', 'Compile file(s) to a new file, aggregating when multiple files are compiled.'
|
20
|
+
c.option '--verbose', 'Output compilation information while in progress'
|
21
|
+
c.when_called do |args, options|
|
22
|
+
# TODO
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../lib/'
|
3
|
+
require 'ass'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
large_ass = <<-ASS
|
7
|
+
/* Inline comment
|
8
|
+
|
9
|
+
// Literal imports
|
10
|
+
@import 'something.css'
|
11
|
+
|
12
|
+
// Constants
|
13
|
+
|
14
|
+
:primary_color = #fff
|
15
|
+
:heading_size = 16px
|
16
|
+
|
17
|
+
// Mixins
|
18
|
+
+large_font
|
19
|
+
font-size 16px
|
20
|
+
font-weight bold
|
21
|
+
|
22
|
+
+add_color
|
23
|
+
color :primary_color
|
24
|
+
|
25
|
+
+clearfix
|
26
|
+
display block
|
27
|
+
content '.'
|
28
|
+
height 0
|
29
|
+
clear both
|
30
|
+
visibility hidden
|
31
|
+
+add_color
|
32
|
+
+large_font
|
33
|
+
|
34
|
+
// Stylesheet
|
35
|
+
|
36
|
+
body
|
37
|
+
font 12px
|
38
|
+
color :primary_color
|
39
|
+
|
40
|
+
h1, h2, h3
|
41
|
+
font-weight bold
|
42
|
+
font-size :heading_size
|
43
|
+
color #fff
|
44
|
+
|
45
|
+
a
|
46
|
+
color black
|
47
|
+
|
48
|
+
:hover
|
49
|
+
color blue
|
50
|
+
|
51
|
+
#primary .content
|
52
|
+
margin 15px
|
53
|
+
|
54
|
+
#comments
|
55
|
+
padding 5px
|
56
|
+
font-size 11px
|
57
|
+
color gray
|
58
|
+
|
59
|
+
.comment
|
60
|
+
border white 1px solid
|
61
|
+
|
62
|
+
a
|
63
|
+
color black !important
|
64
|
+
|
65
|
+
#footer
|
66
|
+
+clearfix
|
67
|
+
|
68
|
+
ASS
|
69
|
+
|
70
|
+
Benchmark.bm(15) do |x|
|
71
|
+
x.report("60 lines") {
|
72
|
+
Ass::Parser.parse(large_ass)
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
data/lib/ass/parser.rb
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
|
2
|
+
module Ass
|
3
|
+
class Parser
|
4
|
+
|
5
|
+
OPEN_BRACE = " {\n"
|
6
|
+
CLOSING_BRACE = "}\n"
|
7
|
+
|
8
|
+
AT = /^ *@/
|
9
|
+
COMMENT = /^ *\/\*(.*)(?:\*\/)?$/
|
10
|
+
ASS_COMMENT = /&\/\//
|
11
|
+
BLANK = /^ *$/ # TODO: Single \n char as well, update test.ass
|
12
|
+
WORD = /([\w]+)/
|
13
|
+
HYPHENATED_WORD = /([\w\-]+)/
|
14
|
+
MIXIN = /^ *\+#{WORD}/
|
15
|
+
SELECTOR = /^([#\w\-\.,:\[\]\~\* ]+) *$/ # TODO: review CSS specification
|
16
|
+
EQUALS = / *= */
|
17
|
+
CONSTANT = /:#{WORD}/
|
18
|
+
CONSTANT_VALUE = /([#\w]+)/
|
19
|
+
CONSTANT_WITH_VALUE = /^ *#{CONSTANT}#{EQUALS}#{CONSTANT_VALUE}/
|
20
|
+
PROPERTY = /^ *#{HYPHENATED_WORD}/
|
21
|
+
|
22
|
+
attr_accessor :ass, :constants, :css
|
23
|
+
alias :to_s :ass
|
24
|
+
|
25
|
+
def initialize ass = ''
|
26
|
+
@ass, @css, @constants = ass, '', {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse!
|
30
|
+
mixins = Hash.new ''
|
31
|
+
in_block, in_mixin = false, false
|
32
|
+
last_selector = ''
|
33
|
+
lines = @ass.split "\n"
|
34
|
+
lines.each do |line|
|
35
|
+
if line.match COMMENT
|
36
|
+
@css << "/* #{$1.strip} */\n"
|
37
|
+
elsif line.match CONSTANT_WITH_VALUE
|
38
|
+
@constants[$1.to_sym] = $2
|
39
|
+
elsif not in_block and line.match MIXIN
|
40
|
+
in_mixin, in_block = $1, true
|
41
|
+
elsif in_block and line.match MIXIN
|
42
|
+
next if in_mixin
|
43
|
+
@css << mixins[$1]
|
44
|
+
elsif in_block and line.match BLANK
|
45
|
+
in_block = false
|
46
|
+
next if in_mixin
|
47
|
+
@css << CLOSING_BRACE
|
48
|
+
elsif line.match AT
|
49
|
+
@css << line << "\n"
|
50
|
+
elsif line.match BLANK or line.match ASS_COMMENT
|
51
|
+
# Do nothing
|
52
|
+
elsif not in_block and line.match SELECTOR
|
53
|
+
in_block = true
|
54
|
+
if sub_selector?($1, last_selector)
|
55
|
+
next if in_mixin
|
56
|
+
selector = join_selectors last_selector, $1.strip
|
57
|
+
@css << selector << OPEN_BRACE
|
58
|
+
else
|
59
|
+
in_mixin = false
|
60
|
+
selector = $1.strip
|
61
|
+
@css << selector << OPEN_BRACE
|
62
|
+
end
|
63
|
+
last_selector = selector
|
64
|
+
elsif line.match PROPERTY
|
65
|
+
if mixin = in_mixin
|
66
|
+
mixins[mixin] << format_property(line)
|
67
|
+
else
|
68
|
+
@css << format_property(line)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def join_selectors selector_a, selector_b
|
76
|
+
if selector_b[0,1] == ':'
|
77
|
+
if selector_a.include? ','
|
78
|
+
selector_a.split(',').collect { |selector| selector << selector_b }.join(',')
|
79
|
+
else
|
80
|
+
selector_a << selector_b
|
81
|
+
end
|
82
|
+
else
|
83
|
+
if selector_a.include? ','
|
84
|
+
selector_a.split(',').collect { |selector| selector << ' ' << selector_b }.join(',')
|
85
|
+
else
|
86
|
+
selector_a << ' ' << selector_b
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def sub_selector? selector_a, selector_b
|
92
|
+
true if indents_in(selector_a) > indents_in(selector_b)
|
93
|
+
end
|
94
|
+
|
95
|
+
def indents_in string
|
96
|
+
string.match(/^( *)/).captures.first.length / 2 rescue 0
|
97
|
+
end
|
98
|
+
|
99
|
+
def format_property line
|
100
|
+
line.gsub! PROPERTY, ' \1:'
|
101
|
+
line.gsub! CONSTANT do |constant|
|
102
|
+
constant_sym = constant.gsub(':', '').to_sym
|
103
|
+
@constants[constant_sym] || 'undefined_constant'
|
104
|
+
end
|
105
|
+
line << ";\n"
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.parse ass
|
109
|
+
new(ass).parse!.css
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.parse_file file
|
113
|
+
new(File.read(file)).parse!.css
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end
|
data/lib/ass/version.rb
ADDED
data/lib/ass.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2008 TJ Holowaychuk
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
$:.unshift File.dirname(__FILE__)
|
25
|
+
|
26
|
+
require 'ass/version'
|
27
|
+
require 'ass/parser'
|
@@ -0,0 +1,159 @@
|
|
1
|
+
|
2
|
+
describe Ass::Parser do
|
3
|
+
|
4
|
+
before :each do
|
5
|
+
@parser = Ass::Parser.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should determine indentations (2 spaces)" do
|
9
|
+
@parser.indents_in('none').should == 0
|
10
|
+
@parser.indents_in(' one').should == 1
|
11
|
+
@parser.indents_in(' two').should == 2
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should determine sub selectors" do
|
15
|
+
@parser.sub_selector?(' sub', 'primary').should be_true
|
16
|
+
@parser.sub_selector?('primary', 'primary').should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should join sub selectors" do
|
20
|
+
@parser.join_selectors('a', ':hover').should == 'a:hover'
|
21
|
+
@parser.join_selectors('h1', 'a').should == 'h1 a'
|
22
|
+
@parser.join_selectors('h1, h2, h3', ':hover').should == 'h1:hover, h2:hover, h3:hover'
|
23
|
+
@parser.join_selectors('h1, h2, h3', 'a').should == 'h1 a, h2 a, h3 a'
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should populate constants" do
|
27
|
+
@parser.ass = <<-ASS
|
28
|
+
:primary_color = #fff
|
29
|
+
:primary_size = 15px
|
30
|
+
:tertiary_size = 9em
|
31
|
+
ASS
|
32
|
+
@parser.parse!
|
33
|
+
@parser.constants[:primary_color].should == '#fff'
|
34
|
+
@parser.constants[:primary_size].should == '15px'
|
35
|
+
@parser.constants[:tertiary_size].should == '9em'
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should translate ass document from file" do
|
39
|
+
Ass::Parser.parse_file(File.dirname(__FILE__) + '/../fixtures/test.ass').should == <<-ASS.deindent
|
40
|
+
body.some-class {
|
41
|
+
margin: 0;
|
42
|
+
}
|
43
|
+
ASS
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should fail when parsing a file that does not exist" do
|
47
|
+
lambda { Ass::Parser.parse_file('does_not_exist.ass') }.should raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should translate an ass document" do
|
51
|
+
ass = <<-ASS.deindent
|
52
|
+
/* Inline comment
|
53
|
+
|
54
|
+
// Literal imports
|
55
|
+
@import 'something.css'
|
56
|
+
|
57
|
+
// Constants
|
58
|
+
|
59
|
+
:primary_color = #fff
|
60
|
+
:heading_size = 16px
|
61
|
+
|
62
|
+
// Mixins
|
63
|
+
+large font
|
64
|
+
font-size 16px
|
65
|
+
font-weight bold
|
66
|
+
|
67
|
+
+add color
|
68
|
+
color :primary_color
|
69
|
+
|
70
|
+
+clearfix
|
71
|
+
display block
|
72
|
+
content '.'
|
73
|
+
height 0
|
74
|
+
clear both
|
75
|
+
visibility hidden
|
76
|
+
+add color
|
77
|
+
+large font
|
78
|
+
|
79
|
+
// Stylesheet
|
80
|
+
|
81
|
+
body
|
82
|
+
font 12px
|
83
|
+
color :primary_color
|
84
|
+
|
85
|
+
h1, h2, h3
|
86
|
+
font-weight bold
|
87
|
+
font-size :heading_size
|
88
|
+
color #fff
|
89
|
+
|
90
|
+
a
|
91
|
+
color black
|
92
|
+
|
93
|
+
:hover
|
94
|
+
color blue
|
95
|
+
|
96
|
+
#primary .content
|
97
|
+
margin 15px
|
98
|
+
|
99
|
+
#comments
|
100
|
+
padding 5px
|
101
|
+
font-size 11px
|
102
|
+
color gray
|
103
|
+
|
104
|
+
.comment
|
105
|
+
border white 1px solid
|
106
|
+
|
107
|
+
a
|
108
|
+
color black !important
|
109
|
+
|
110
|
+
#footer
|
111
|
+
+clearfix
|
112
|
+
|
113
|
+
ASS
|
114
|
+
Ass::Parser.parse(ass).should == <<-CSS.deindent
|
115
|
+
/* Inline comment */
|
116
|
+
@import 'something.css'
|
117
|
+
body {
|
118
|
+
font: 12px;
|
119
|
+
color: #fff;
|
120
|
+
}
|
121
|
+
h1, h2, h3 {
|
122
|
+
font-weight: bold;
|
123
|
+
font-size: 16px;
|
124
|
+
color: #fff;
|
125
|
+
}
|
126
|
+
a {
|
127
|
+
color: black;
|
128
|
+
}
|
129
|
+
a:hover {
|
130
|
+
color: blue;
|
131
|
+
}
|
132
|
+
#primary .content {
|
133
|
+
margin: 15px;
|
134
|
+
}
|
135
|
+
#primary .content #comments {
|
136
|
+
padding: 5px;
|
137
|
+
font-size: 11px;
|
138
|
+
color: gray;
|
139
|
+
}
|
140
|
+
#primary .content #comments .comment {
|
141
|
+
border: white 1px solid;
|
142
|
+
}
|
143
|
+
#primary .content #comments .comment a {
|
144
|
+
color: black !important;
|
145
|
+
}
|
146
|
+
#footer {
|
147
|
+
font-size: 16px;
|
148
|
+
font-weight: bold;
|
149
|
+
color: #fff;
|
150
|
+
display: block;
|
151
|
+
content: '.';
|
152
|
+
height: 0;
|
153
|
+
clear: both;
|
154
|
+
visibility: hidden;
|
155
|
+
}
|
156
|
+
CSS
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/tasks/docs.rake
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Remove rdoc products'
|
5
|
+
task :remove => [:clobber_docs]
|
6
|
+
|
7
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
8
|
+
task :open do
|
9
|
+
browser = ENV["BROWSER"] || "safari"
|
10
|
+
sh "open -a #{browser} doc/index.html"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visionmedia-ass
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Holowaychuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-15 00:00:00 -08:00
|
13
|
+
default_executable: ass
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: visionmedia-commander
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: echoe
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: "0"
|
32
|
+
version:
|
33
|
+
description: "'Amazing Style Sheets'"
|
34
|
+
email: tj@vision-media.ca
|
35
|
+
executables:
|
36
|
+
- ass
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files:
|
40
|
+
- bin/ass
|
41
|
+
- lib/ass/parser.rb
|
42
|
+
- lib/ass/version.rb
|
43
|
+
- lib/ass.rb
|
44
|
+
- README.rdoc
|
45
|
+
- tasks/benchmark.rake
|
46
|
+
- tasks/docs.rake
|
47
|
+
- tasks/gemspec.rake
|
48
|
+
- tasks/spec.rake
|
49
|
+
files:
|
50
|
+
- ass.gemspec
|
51
|
+
- bin/ass
|
52
|
+
- examples/benchmarks.rb
|
53
|
+
- History.rdoc
|
54
|
+
- lib/ass/parser.rb
|
55
|
+
- lib/ass/version.rb
|
56
|
+
- lib/ass.rb
|
57
|
+
- Manifest
|
58
|
+
- Rakefile
|
59
|
+
- README.rdoc
|
60
|
+
- spec/fixtures/test.ass
|
61
|
+
- spec/functional/parser_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
- tasks/benchmark.rake
|
64
|
+
- tasks/docs.rake
|
65
|
+
- tasks/gemspec.rake
|
66
|
+
- tasks/spec.rake
|
67
|
+
- Todo.rdoc
|
68
|
+
has_rdoc: true
|
69
|
+
homepage: http://github.com/visionmedia/ass
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options:
|
72
|
+
- --line-numbers
|
73
|
+
- --inline-source
|
74
|
+
- --title
|
75
|
+
- Ass
|
76
|
+
- --main
|
77
|
+
- README.rdoc
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "1.2"
|
91
|
+
version:
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: ass
|
95
|
+
rubygems_version: 1.2.0
|
96
|
+
signing_key:
|
97
|
+
specification_version: 2
|
98
|
+
summary: "'Amazing Style Sheets'"
|
99
|
+
test_files: []
|
100
|
+
|