css_builder 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/VERSION +1 -1
- data/css_builder.gemspec +1 -1
- data/lib/css_builder.rb +4 -8
- data/spec/css_builder_spec.rb +22 -0
- metadata +10 -10
data/README.md
CHANGED
@@ -11,6 +11,13 @@ A ruby interface for creating CSS files; LESS and SASS planned;
|
|
11
11
|
background_color "blue"
|
12
12
|
}
|
13
13
|
|
14
|
+
css.table([], [:tag => "tr"], [:tag => "td", :nth_child => "odd"]) do
|
15
|
+
border "1px #345 solid"
|
16
|
+
background_color "#efefef"
|
17
|
+
end
|
18
|
+
|
19
|
+
@css.comment! "This is a magical momment"
|
20
|
+
|
14
21
|
css.value! # outputs =>
|
15
22
|
|
16
23
|
div#hello.world {
|
@@ -18,6 +25,13 @@ A ruby interface for creating CSS files; LESS and SASS planned;
|
|
18
25
|
background-color : blue;
|
19
26
|
}
|
20
27
|
|
28
|
+
table tr td:nth-child(odd) {
|
29
|
+
border : 1px #345 solid;
|
30
|
+
background-color : #efefef;
|
31
|
+
}
|
32
|
+
|
33
|
+
/* This is a magical momment */
|
34
|
+
|
21
35
|
###
|
22
36
|
|
23
37
|
css = CssBuilder.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/css_builder.gemspec
CHANGED
data/lib/css_builder.rb
CHANGED
@@ -95,15 +95,11 @@ private
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def _args_hash_values(hash)
|
98
|
+
css! _dasherize hash.delete(:tag) if hash.has_key?(:tag)
|
99
|
+
css! "##{hash.delete(:id)}" if hash.has_key?(:id)
|
100
|
+
css! _class(hash.delete(:class)) if hash.has_key?(:class)
|
98
101
|
hash.each do |k,v|
|
99
|
-
|
100
|
-
when :id
|
101
|
-
css! "##{v}"
|
102
|
-
when :class
|
103
|
-
css! _class(v)
|
104
|
-
else
|
105
|
-
css! ":#{_dasherize k}(#{v})"
|
106
|
-
end
|
102
|
+
css! ":#{_dasherize k}(#{v})"
|
107
103
|
end
|
108
104
|
end
|
109
105
|
|
data/spec/css_builder_spec.rb
CHANGED
@@ -42,6 +42,11 @@ describe "CssBuilder" do
|
|
42
42
|
@css.value!.should match /^#the-magic\.sauce\s+\.tasty:nth-child\(2\)\s+\{\s+\}/
|
43
43
|
end
|
44
44
|
|
45
|
+
it "can create a css ID block tag sub-selector" do
|
46
|
+
@css.id!("the_magic", [:class => "sauce"], [:class => "word", :tag => "div"]) {}
|
47
|
+
@css.value!.should match /^#the-magic\.sauce\s+div\.word\s+\{\s+\}/
|
48
|
+
end
|
49
|
+
|
45
50
|
end
|
46
51
|
|
47
52
|
describe "Classes" do
|
@@ -76,6 +81,11 @@ describe "CssBuilder" do
|
|
76
81
|
@css.value!.should match /^.the-magic\.sauce\s+\.tasty:nth-child\(2\)\s+\{\s+\}/
|
77
82
|
end
|
78
83
|
|
84
|
+
it "can create a css class block tag sub-selector" do
|
85
|
+
@css.class!("water", [:class => "melon"], [:class => "alls", :tag => "section"]) {}
|
86
|
+
@css.value!.should match /^.water\.melon\s+section\.alls\s+\{\s+\}/
|
87
|
+
end
|
88
|
+
|
79
89
|
end
|
80
90
|
|
81
91
|
describe "Tags" do
|
@@ -115,6 +125,11 @@ describe "CssBuilder" do
|
|
115
125
|
@css.value!.should match /^a:hover\(\)\s+\{\s+\}/
|
116
126
|
end
|
117
127
|
|
128
|
+
it "can create a css tag block tag sub-selectors" do
|
129
|
+
@css.table([], [:tag => "tr"], [:class => "overalls", :tag => "td"]) {}
|
130
|
+
@css.value!.should match /^table\s+tr\s+td\.overalls\s+\{\s+\}/
|
131
|
+
end
|
132
|
+
|
118
133
|
end
|
119
134
|
|
120
135
|
describe "Blocks" do
|
@@ -135,6 +150,13 @@ describe "CssBuilder" do
|
|
135
150
|
@css.value!.should match /^h1\s+\{\s+color\s+:\s+#438;\s+font-size\s+:\s+10em;\s+border\s+:\s+0px\s+green\s+solid;\s+\}/
|
136
151
|
end
|
137
152
|
|
153
|
+
it "can have css attributes and many selectors" do
|
154
|
+
@css.body([], [:tag => 'p'], [:tag => 'span']) {
|
155
|
+
background_image "url('http://magical.mystery.code.com/placeholder.image')"
|
156
|
+
}
|
157
|
+
@css.value!.should match /^body\s+p\s+span\s+\{\s+background-image\s+:\s+url\('http:\/\/magical.mystery.code.com\/placeholder.image'\);\s+\}/
|
158
|
+
end
|
159
|
+
|
138
160
|
end
|
139
161
|
|
140
162
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: css_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-23 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2163175620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 2.8.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2163175620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rdoc
|
27
|
-
requirement: &
|
27
|
+
requirement: &2163189760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.12'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2163189760
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &2163185460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 1.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2163185460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: jeweler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2163198960 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.8.3
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2163198960
|
58
58
|
description: A ruby interface for creating CSS files; LESS and SASS planned;
|
59
59
|
email: jvaneat@iit.edu
|
60
60
|
executables: []
|
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
segments:
|
92
92
|
- 0
|
93
|
-
hash:
|
93
|
+
hash: 958114106684494051
|
94
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|