css_builder 0.1.2 → 0.1.3

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/README.md CHANGED
@@ -1,9 +1,14 @@
1
- # css_builder
1
+ # Css Builder
2
2
 
3
3
  A ruby interface for creating CSS files; LESS and SASS planned;
4
4
 
5
+ ## Installation
6
+
7
+ gem install css_builder
8
+
5
9
  ## Usage
6
10
 
11
+ require "css_builder"
7
12
  css = CssBuilder.new
8
13
 
9
14
  css.div(:id => "hello", :class => "world") {
@@ -16,7 +21,7 @@ A ruby interface for creating CSS files; LESS and SASS planned;
16
21
  background_color "#efefef"
17
22
  end
18
23
 
19
- @css.comment! "This is a magical momment"
24
+ css.comment! "This is a magical momment"
20
25
 
21
26
  css.value! # outputs =>
22
27
 
@@ -64,6 +69,20 @@ A ruby interface for creating CSS files; LESS and SASS planned;
64
69
  font-family : Sharp;
65
70
  }
66
71
 
72
+ ###
73
+
74
+ css = CssBuilder.new
75
+
76
+ css.div([], [:selector => "~"], [:tag => "span"]) {
77
+ border "1px"
78
+ }
79
+
80
+ css.value! # outputs =>
81
+
82
+ div ~ span {
83
+ border : 1px;
84
+ }
85
+
67
86
  ## Contributing to css_builder
68
87
 
69
88
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/css_builder.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "css_builder"
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Derrek Van Eaton"]
12
- s.date = "2012-03-23"
12
+ s.date = "2012-03-28"
13
13
  s.description = "A ruby interface for creating CSS files; LESS and SASS planned;"
14
14
  s.email = "jvaneat@iit.edu"
15
15
  s.extra_rdoc_files = [
data/lib/css_builder.rb CHANGED
@@ -9,8 +9,10 @@ class CssBuilder
9
9
  end
10
10
 
11
11
  def comment!(comment)
12
- @css << "/* #{comment} */"
12
+ css! "/* #{comment} */"
13
13
  _newline
14
+ _newline
15
+ @css
14
16
  end
15
17
 
16
18
  def id!(*args, &block)
@@ -51,6 +53,7 @@ private
51
53
 
52
54
  _close
53
55
  _newline
56
+ _newline
54
57
  end
55
58
 
56
59
  def css!(val)
@@ -95,6 +98,9 @@ private
95
98
  end
96
99
 
97
100
  def _args_hash_values(hash)
101
+ if hash.has_key?(:selector)
102
+ css! hash.delete(:selector)
103
+ end
98
104
  css! _dasherize hash.delete(:tag) if hash.has_key?(:tag)
99
105
  css! "##{hash.delete(:id)}" if hash.has_key?(:id)
100
106
  css! _class(hash.delete(:class)) if hash.has_key?(:class)
@@ -53,37 +53,42 @@ describe "CssBuilder" do
53
53
 
54
54
  it "can create a simple css class block" do
55
55
  @css.class!("theMan") {}
56
- @css.value!.should match /^.theMan\s+\{\s+\}/
56
+ @css.value!.should match /^\.theMan\s+\{\s+\}/
57
57
  end
58
58
 
59
59
  it "can create a css class block with an additional class" do
60
60
  @css.class!("henry-theGreat", :class => "sauce") {}
61
- @css.value!.should match /^.henry-theGreat\.sauce\s+\{\s+\}/
61
+ @css.value!.should match /^\.henry-theGreat\.sauce\s+\{\s+\}/
62
62
  end
63
63
 
64
64
  it "can create a css class block with an additional classes by spaces" do
65
65
  @css.class!(" henry theGreat-is not so great ") {}
66
- @css.value!.should match /^.henry\.theGreat-is\.not\.so\.great\s+\{\s+\}/
66
+ @css.value!.should match /^\.henry\.theGreat-is\.not\.so\.great\s+\{\s+\}/
67
67
  end
68
68
 
69
69
  it "can create a css class block with a class and a child ID and class selector" do
70
70
  @css.class!("magic", [:class => "sauce"], [:id => "RED", :class => "tasty"]) {}
71
- @css.value!.should match /^.magic\.sauce\s+#RED\.tasty\s+\{\s+\}/
71
+ @css.value!.should match /^\.magic\.sauce\s+#RED\.tasty\s+\{\s+\}/
72
72
  end
73
73
 
74
74
  it "can create a css class block with a class and a child class with a psuedo selector" do
75
75
  @css.class!("magic", [:class => "sauce"], [:class => "tasty", :hover => nil]) {}
76
- @css.value!.should match /^.magic\.sauce\s+\.tasty:hover\(\)\s+\{\s+\}/
76
+ @css.value!.should match /^\.magic\.sauce\s+\.tasty:hover\(\)\s+\{\s+\}/
77
77
  end
78
78
 
79
79
  it "can create a css class block with a class and a child class with a psuedo selector with params" do
80
- @css.id!("the_magic", [:class => "sauce"], [:class => "tasty", :nth_child => 2]) {}
81
- @css.value!.should match /^.the-magic\.sauce\s+\.tasty:nth-child\(2\)\s+\{\s+\}/
80
+ @css.class!("the_magic", [:class => "sauce"], [:class => "tasty", :nth_child => 2]) {}
81
+ @css.value!.should match /^\.the-magic\.sauce\s+\.tasty:nth-child\(2\)\s+\{\s+\}/
82
82
  end
83
83
 
84
84
  it "can create a css class block tag sub-selector" do
85
85
  @css.class!("water", [:class => "melon"], [:class => "alls", :tag => "section"]) {}
86
- @css.value!.should match /^.water\.melon\s+section\.alls\s+\{\s+\}/
86
+ @css.value!.should match /^\.water\.melon\s+section\.alls\s+\{\s+\}/
87
+ end
88
+
89
+ it "can create a css class block with css3 sub-selectors" do
90
+ @css.class!("food", [], [:selector => ">"], [:tag => "div"]) {}
91
+ @css.value!.should match /^\.food\s+>\s+div\s+\{\s+\}/
87
92
  end
88
93
 
89
94
  end
@@ -130,6 +135,11 @@ describe "CssBuilder" do
130
135
  @css.value!.should match /^table\s+tr\s+td\.overalls\s+\{\s+\}/
131
136
  end
132
137
 
138
+ it "can create a css tag block with css3 sub-selectors" do
139
+ @css.table([], [:selector => "~"], [:tag => "td"]) {}
140
+ @css.value!.should match /^table\s+~\s+td\s+\{\s+\}/
141
+ end
142
+
133
143
  end
134
144
 
135
145
  describe "Blocks" do
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.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-23 00:00:00.000000000 Z
12
+ date: 2012-03-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2163175620 !ruby/object:Gem::Requirement
16
+ requirement: &2161210120 !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: *2163175620
24
+ version_requirements: *2161210120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &2163189760 !ruby/object:Gem::Requirement
27
+ requirement: &2161209160 !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: *2163189760
35
+ version_requirements: *2161209160
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
38
- requirement: &2163185460 !ruby/object:Gem::Requirement
38
+ requirement: &2161869580 !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: *2163185460
46
+ version_requirements: *2161869580
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &2163198960 !ruby/object:Gem::Requirement
49
+ requirement: &2161868200 !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: *2163198960
57
+ version_requirements: *2161868200
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: 958114106684494051
93
+ hash: -2673597597399935291
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements: