cloudhead-less 0.8.12 → 1.0.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.
Files changed (66) hide show
  1. data/README.md +10 -1
  2. data/Rakefile +21 -2
  3. data/VERSION +1 -1
  4. data/bin/lessc +0 -8
  5. data/less.gemspec +48 -15
  6. data/lib/less/command.rb +24 -25
  7. data/lib/less/engine/builder.rb +13 -0
  8. data/lib/less/engine/less.tt +379 -0
  9. data/lib/less/engine/nodes/element.rb +153 -0
  10. data/lib/less/engine/nodes/entity.rb +59 -0
  11. data/lib/less/engine/nodes/function.rb +61 -0
  12. data/lib/less/engine/nodes/literal.rb +132 -0
  13. data/lib/less/engine/nodes/property.rb +120 -0
  14. data/lib/less/engine/nodes/selector.rb +39 -0
  15. data/lib/less/engine/nodes.rb +8 -0
  16. data/lib/less/engine/parser.rb +3854 -0
  17. data/lib/less/engine.rb +42 -139
  18. data/lib/less.rb +65 -10
  19. data/spec/command_spec.rb +2 -6
  20. data/spec/css/accessors-1.0.css +20 -0
  21. data/spec/css/big-1.0.css +3770 -0
  22. data/spec/css/comments-1.0.css +11 -0
  23. data/spec/css/css-1.0.css +40 -0
  24. data/spec/css/functions-1.0.css +8 -0
  25. data/spec/css/import-1.0.css +13 -0
  26. data/spec/css/mixins-1.0.css +30 -0
  27. data/spec/css/operations-1.0.css +30 -0
  28. data/spec/css/rulesets-1.0.css +19 -0
  29. data/spec/css/scope-1.0.css +16 -0
  30. data/spec/css/strings-1.0.css +14 -0
  31. data/spec/css/variables-1.0.css +7 -0
  32. data/spec/css/whitespace-1.0.css +11 -0
  33. data/spec/engine_spec.rb +66 -18
  34. data/spec/less/accessors-1.0.less +20 -0
  35. data/spec/less/big-1.0.less +4810 -0
  36. data/spec/less/colors-1.0.less +0 -0
  37. data/spec/less/comments-1.0.less +46 -0
  38. data/spec/less/css-1.0.less +82 -0
  39. data/spec/less/exceptions/mixed-units-error.less +0 -0
  40. data/spec/less/exceptions/name-error-1.0.less +0 -0
  41. data/spec/less/exceptions/syntax-error-1.0.less +0 -0
  42. data/spec/less/functions-1.0.less +6 -0
  43. data/spec/less/import/import-test-a.less +2 -0
  44. data/spec/less/import/import-test-b.less +8 -0
  45. data/spec/less/import/import-test-c.less +5 -0
  46. data/spec/less/import-1.0.less +7 -0
  47. data/spec/less/mixins-1.0.less +43 -0
  48. data/spec/less/operations-1.0.less +39 -0
  49. data/spec/less/rulesets-1.0.less +30 -0
  50. data/spec/less/scope-1.0.less +33 -0
  51. data/spec/less/strings-1.0.less +14 -0
  52. data/spec/less/variables-1.0.less +16 -0
  53. data/spec/less/whitespace-1.0.less +21 -0
  54. data/spec/spec.css +81 -23
  55. data/spec/spec.less +3 -4
  56. data/spec/spec_helper.rb +4 -1
  57. metadata +46 -13
  58. data/lib/less/tree.rb +0 -82
  59. data/spec/css/less-0.8.10.css +0 -30
  60. data/spec/css/less-0.8.11.css +0 -31
  61. data/spec/css/less-0.8.12.css +0 -28
  62. data/spec/css/less-0.8.5.css +0 -24
  63. data/spec/css/less-0.8.6.css +0 -24
  64. data/spec/css/less-0.8.7.css +0 -24
  65. data/spec/css/less-0.8.8.css +0 -25
  66. data/spec/tree_spec.rb +0 -5
@@ -0,0 +1,11 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #comments {
4
+ color: red;
5
+ background-color: orange;
6
+ font-size: 12px;
7
+ content: "content";
8
+ border: 1px solid black;
9
+ padding: 0;
10
+ margin: 2em;
11
+ }
@@ -0,0 +1,40 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ div { color: black; }
4
+ div { width: 99%; }
5
+ * { min-width: 45em; }
6
+ h1 { color: none; }
7
+ h2 > a > p { color: none; }
8
+ h3 { color: none; }
9
+ div.class { color: blue; }
10
+ div#id { color: green; }
11
+ .one.two.three { color: grey; }
12
+ @media print { font-size: 3em; }
13
+ @media screen { font-size: 10px; }
14
+ @font-face {
15
+ font-family: 'Garamond Pro';
16
+ src: url("/fonts/garamond-pro.ttf");
17
+ }
18
+ a:hover { color: #999999; }
19
+ a:link { color: #999999; }
20
+ p { text-transform: none; }
21
+ p:first-child { text-transform: none; }
22
+ q:lang(no) { quotes: none; }
23
+ p + h1 { font-size: 2em; }
24
+ input[type="text"] { font-weight: normal; }
25
+ #shorthands {
26
+ border: 1px solid #000000;
27
+ font: 12px/16px Arial;
28
+ margin: 1px 0;
29
+ padding: 0 auto;
30
+ background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
31
+ }
32
+ #more-shorthands {
33
+ margin: 0;
34
+ padding: 1px 0 2px 0;
35
+ font: normal small/20px 'Trebuchet MS', Verdana, sans-serif;
36
+ }
37
+ .misc {
38
+ -moz-border-radius: 2px;
39
+ color: red !important;
40
+ }
@@ -0,0 +1,8 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #functions {
4
+ color: #999999;
5
+ width: 16;
6
+ height: undefined("self");
7
+ border-width: 5;
8
+ }
@@ -0,0 +1,13 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #import { color: red; }
4
+ .mixin {
5
+ height: 10px;
6
+ color: red;
7
+ }
8
+ #import-test {
9
+ height: 10px;
10
+ color: red;
11
+ width: 10px;
12
+ height: 30%;
13
+ }
@@ -0,0 +1,30 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ .mixin { border: 1px solid black; }
4
+ .mixout { border-color: orange; }
5
+ .borders { border-style: dashed; }
6
+ #namespace .borders { border-style: dotted; }
7
+ #namespace .biohazard { content: "death"; }
8
+ #namespace .biohazard .man { color: transparent; }
9
+ #theme > .mixin { background-color: grey; }
10
+ #container {
11
+ color: black;
12
+ border: 1px solid black;
13
+ border-color: orange;
14
+ background-color: grey;
15
+ }
16
+ #header .milk {
17
+ color: white;
18
+ border: 1px solid black;
19
+ background-color: grey;
20
+ }
21
+ #header #cookie { border-style: dashed; }
22
+ #header #cookie .chips { border-style: dotted; }
23
+ #header #cookie .chips .calories {
24
+ color: black;
25
+ border: 1px solid black;
26
+ border-color: orange;
27
+ background-color: grey;
28
+ }
29
+ .secure-zone { color: transparent; }
30
+ .direct { border-style: dotted; }
@@ -0,0 +1,30 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #operations {
4
+ color: #111111;
5
+ height: 9px;
6
+ width: 3em;
7
+ }
8
+ #operations .spacing {
9
+ height: 9px;
10
+ width: 3em;
11
+ }
12
+ .with-variables {
13
+ height: 16em;
14
+ width: 24em;
15
+ size: 1cm;
16
+ }
17
+ .negative {
18
+ height: 0px;
19
+ width: 4px;
20
+ }
21
+ .shorthands { padding: -1px 2px 0 -4px; }
22
+ .colors {
23
+ color: #123123;
24
+ border-color: #345345;
25
+ background-color: #000000;
26
+ }
27
+ .colors .other {
28
+ color: #222222;
29
+ border-color: #222222;
30
+ }
@@ -0,0 +1,19 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #first > .one { font-size: 2em; }
4
+ #first > .one > #second .two > #deux { width: 50%; }
5
+ #first > .one > #second .two > #deux #third { height: 100%; }
6
+ #first > .one > #second .two > #deux #third:focus { color: black; }
7
+ #first > .one > #second .two > #deux #third:focus #fifth > #sixth .seventh #eighth + #ninth { color: purple; }
8
+ #first > .one > #second .two > #deux #fourth { color: #110000; }
9
+ #first > .one > #second .two > #deux #fourth .seven { border: 1px solid black; }
10
+ #first > .one > #second .two > #deux #fourth .eight > #nine { border: 1px solid black; }
11
+ #first > .one > #second .two > #deux #fourth #ten { color: red; }
12
+ #first > .one > #second .two > #deux #five { color: #110000; }
13
+ #first > .one > #second .two > #deux #five .seven { border: 1px solid black; }
14
+ #first > .one > #second .two > #deux #five .eight > #nine { border: 1px solid black; }
15
+ #first > .one > #second .two > #deux #five #ten { color: red; }
16
+ #first > .one > #second .two > #deux #six { color: #110000; }
17
+ #first > .one > #second .two > #deux #six .seven { border: 1px solid black; }
18
+ #first > .one > #second .two > #deux #six .eight > #nine { border: 1px solid black; }
19
+ #first > .one > #second .two > #deux #six #ten { color: red; }
@@ -0,0 +1,16 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ .tiny-scope {
4
+ color: none;
5
+ border-color: #989989;
6
+ }
7
+ .scope1 {
8
+ color: blue;
9
+ border-color: black;
10
+ }
11
+ .scope1 .scope2 { color: blue; }
12
+ .scope1 .scope2 .scope3 {
13
+ color: red;
14
+ border-color: black;
15
+ background-color: white;
16
+ }
@@ -0,0 +1,14 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ #strings {
4
+ background-image: url("http://son-of-a-banana.com");
5
+ quotes: "~" "~";
6
+ content: "#*%:&^,)!.(~*})";
7
+ empty: "";
8
+ }
9
+ #comments { content: "/* hello */ // not-so-secret"; }
10
+ #single-quote {
11
+ quotes: "'" "'";
12
+ content: '""#!&""';
13
+ empty: '';
14
+ }
@@ -0,0 +1,7 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ .variables { width: 14cm; }
4
+ .variables {
5
+ height: 24px;
6
+ color: #888888;
7
+ }
@@ -0,0 +1,11 @@
1
+ /* Generated with Less 1.0.0 */
2
+
3
+ .whitespace { color: white; }
4
+ .whitespace { color: white; }
5
+ .whitespace { color: white; }
6
+ .whitespace { color: white; }
7
+ .whitespace { color: white; }
8
+ .white { color: white; }
9
+ .space { color: white; }
10
+ .mania { color: white; }
11
+ .no-semi-column { color: white; }
data/spec/engine_spec.rb CHANGED
@@ -1,8 +1,16 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
1
+ require 'spec/spec_helper'
2
2
 
3
3
  module LessEngineSpecHelper
4
- def lessify(string)
5
- return Less::Engine.new(string).to_css(:desc)
4
+ def lessify arg
5
+ if arg.is_a? String or arg.is_a? File
6
+ return Less::Engine.new(arg).to_css
7
+ else
8
+ lessify File.new("spec/less/#{arg}-1.0.less")
9
+ end
10
+ end
11
+
12
+ def css file
13
+ File.read("spec/css/#{file}-1.0.css")
6
14
  end
7
15
  end
8
16
 
@@ -10,29 +18,69 @@ describe Less::Engine do
10
18
  include LessEngineSpecHelper
11
19
 
12
20
  describe "to_css" do
13
- it "should return an empty string for p {}" do
14
- lessify('p {}').should == ''
21
+ it "should parse css" do
22
+ lessify(:css).should == css(:css)
15
23
  end
16
-
17
- it "should return css with variable usage" do
18
- lessify("@brand_color: #4D926F;\n #header { color: @brand_color; }").should == "#header { color: #4D926F; }"
24
+
25
+ it "should parse comments" do
26
+ lessify(:comments).should == css(:comments)
19
27
  end
20
-
21
- it "should return css as shown on home page" do
22
- lessify("#header { \n color: red;\n a {\n font-weight: bold;\n text-decoration: none;\n }\n}").should == "#header { color: red; }\n#header a { font-weight: bold; text-decoration: none; }"
28
+
29
+ it "should deal with whitespace" do
30
+ lessify(:whitespace).should == css(:whitespace)
23
31
  end
24
-
25
- it "should handle :hover" do
26
- lessify("a:hover {\n color: red; }").should == "a:hover { color: red; }"
32
+
33
+ it "should parse nested rules" do
34
+ lessify(:rulesets).should == css(:rulesets)
35
+ end
36
+
37
+ it "should parse variables" do
38
+ lessify(:variables).should == css(:variables)
39
+ end
40
+
41
+ it "should parse operations" do
42
+ lessify(:operations).should == css(:operations)
43
+ end
44
+
45
+ it "should manage scope" do
46
+ lessify(:scope).should == css(:scope)
47
+ end
48
+
49
+ it "should parse strings" do
50
+ lessify(:strings).should == css(:strings)
51
+ end
52
+
53
+ it "should parse accessors" do
54
+ lessify(:accessors).should == css(:accessors)
55
+ end
56
+
57
+ it "should parse mixins" do
58
+ lessify(:mixins).should == css(:mixins)
27
59
  end
28
60
 
29
- it "should handle instances of double-quotes" do
30
- lessify("blockquote:before, blockquote:after, q:before, q:after {\n content: \"\"; }").should == "blockquote:before, blockquote:after, q:before, q:after { content: ''; }"
61
+ it "should handle custom functions" do
62
+ module Less::Functions
63
+ def color arg
64
+ Less::Node::Color.new("#999999") if arg == "evil red"
65
+ end
66
+
67
+ def increment a
68
+ Less::Node::Number.new(a.to_i + 1)
69
+ end
70
+
71
+ def add a, b
72
+ Less::Node::Number.new(a + b)
73
+ end
74
+ end
75
+ lessify(:functions).should == css(:functions)
31
76
  end
32
77
 
33
- it "should parse tag attributes" do
34
- lessify("input[type=text] { color: red; }").should == "input[type=text] { color: red; }"
78
+ it "should work with import" do
79
+ lessify(:import).should == css(:import)
35
80
  end
81
+
82
+ it "should parse a big file"
83
+ it "should handle complex color operations"
36
84
  end
37
85
  end
38
86
 
@@ -0,0 +1,20 @@
1
+ .magic-box {
2
+ @trim: orange;
3
+ content: "gold";
4
+ width: 60cm;
5
+ height: 40cm;
6
+ #lock {
7
+ color: silver;
8
+ }
9
+ }
10
+
11
+ #accessors {
12
+ content: .magic-box['content']; // "gold"
13
+ width: .magic-box['width']; // 60cm
14
+ }
15
+
16
+ .unlock {
17
+ .magic-box;
18
+ color: #lock['color']; // silver
19
+ border-color: .magic-box[@trim]; // orange
20
+ }