hum 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,4 +16,8 @@
16
16
 
17
17
  ## 0.0.5
18
18
 
19
- * Added better support for pseudo elements, fixed some bugs
19
+ * Added better support for pseudo elements, fixed some bugs
20
+
21
+ ## 0.0.6
22
+
23
+ * Added basic support for attribute selectors
data/README.md CHANGED
@@ -1,9 +1,13 @@
1
1
  # Hum
2
2
 
3
- Hum generates HTML from your SASS, SCSS or CSS.
3
+ Hum generates HTML from your SASS, SCSS or CSS. **For now you need Ruby 1.9 and above.**
4
4
 
5
5
  `gem install hum`
6
6
 
7
+ If you're using Windows also install this gem.
8
+
9
+ `gem install win32console`
10
+
7
11
  ## SASS to HTML
8
12
 
9
13
  `hum [stylesheet].sass`
@@ -286,7 +286,7 @@ module Hum
286
286
  hash[:exclude] = true
287
287
 
288
288
  #if this is a named mixin
289
- elsif code.match(/\=/)
289
+ elsif code.match(/^\=/)
290
290
 
291
291
  #ignore the hash on output
292
292
  hash[:exclude] = true
@@ -380,35 +380,62 @@ module Hum
380
380
  tag = tag.gsub("%#", "%div#")
381
381
  end
382
382
 
383
- #give all links an href
384
- if tag.match("%a")
383
+ #if anchor with class
384
+ if tag.match(/%a\./)
385
+
386
+ #get the data
387
+ data = /%a\.(?<tag_class>.*)/.match(tag)
388
+
389
+ #make the tag
390
+ tag = "%a{:href=>'#',:class=>'#{data[:tag_class]}'}"
391
+
392
+ #if anchor with ID
393
+ elsif tag.match(/%a\#/)
394
+
395
+ #get the data
396
+ data = /%a\#(?<tag_id>.*)/.match(tag)
397
+
398
+ #make the tag
399
+ tag = "%a{:href=>'#',:id=>'#{data[:tag_id]}'}"
400
+
401
+ #else just give it an link
402
+ elsif tag.match("%a")
385
403
  tag = tag.gsub("%a", "%a{:href=>'#'}")
386
404
  end
387
405
 
406
+ #if the tag has an attribute selector
407
+ if tag.match(/%.*\[.*\=.*\]/)
408
+
409
+ #get the data
410
+ data = /(?<tag_element>%.*)\[(?<tag_attribute>.*)\=(?<tag_value>.*)\]/.match(tag)
411
+
412
+ tag = data[:tag_element] + "{:#{data[:tag_attribute]}=>'#{data[:tag_value]}'}"
413
+ #make the tag
414
+ end
415
+
388
416
  tag
389
417
  end
390
418
 
391
419
  #Output the HAML
392
420
  def _output_haml
393
-
394
421
  #convert to HAML
395
422
  @haml = "%html\n"
396
423
  @haml += "\t%head\n"
397
424
  @haml += "\t\t%link{:type => 'text/css', :rel => 'stylesheet', :href => '#{@input_name.gsub(/\..*/, ".css")}'}\n"
398
425
  @haml += "\t%body\n"
399
-
426
+
400
427
  #time to build the HAML
401
428
  @tree.each do |hash|
402
429
 
403
430
  if hash[:exclude] != true
404
431
 
405
432
  extra = []
406
-
433
+
407
434
  #if there's a parent, find the extra kids
408
435
  if !hash[:parent].nil?
409
436
  extra = @tree.find_extra_kids(hash)
410
437
  end
411
-
438
+
412
439
  #for each generate the HAML line
413
440
  hash[:haml].each { |haml_tag|
414
441
 
@@ -1,3 +1,3 @@
1
1
  module Hum
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -87,6 +87,11 @@ class HumText < Test::Unit::TestCase
87
87
  quick_test
88
88
  end
89
89
 
90
+ def test_input_elements
91
+ @file = "input_elements"
92
+ quick_test
93
+ end
94
+
90
95
  private
91
96
 
92
97
  def quick_test
@@ -3,3 +3,5 @@
3
3
  %link{:type => 'text/css', :rel => 'stylesheet', :href => 'anchor_links.css'}
4
4
  %body
5
5
  %a{:href=>'#'} Inner content
6
+ %a{:href=>'#',:id=>'foo'} Inner content
7
+ %a{:href=>'#',:class=>'bar'} Inner content
@@ -0,0 +1,8 @@
1
+ %html
2
+ %head
3
+ %link{:type => 'text/css', :rel => 'stylesheet', :href => 'input_elements.css'}
4
+ %body
5
+ %div.foo
6
+ %input Inner content
7
+ %input.bar Inner content
8
+ %input{:type=>'text'} Inner content
@@ -5,4 +5,8 @@ a
5
5
  &:active
6
6
  color: red
7
7
  &:hover
8
- color: purple
8
+ color: purple
9
+ a#foo
10
+ color: black
11
+ a.bar
12
+ color: black
@@ -0,0 +1,8 @@
1
+ .foo
2
+ color: black
3
+ input
4
+ font-size: 10px
5
+ input.bar
6
+ font-size: 11px
7
+ input[type=text]
8
+ font-size: 12px
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-01-18 00:00:00.000000000Z
12
+ date: 2012-01-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
16
- requirement: &2153477380 !ruby/object:Gem::Requirement
16
+ requirement: &2156393620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.12
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153477380
24
+ version_requirements: *2156393620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
27
- requirement: &2153476740 !ruby/object:Gem::Requirement
27
+ requirement: &2156392960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.4
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2153476740
35
+ version_requirements: *2156392960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fssm
38
- requirement: &2153476140 !ruby/object:Gem::Requirement
38
+ requirement: &2156392320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.2.7
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2153476140
46
+ version_requirements: *2156392320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: colored
49
- requirement: &2153475500 !ruby/object:Gem::Requirement
49
+ requirement: &2156391780 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '1.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2153475500
57
+ version_requirements: *2156391780
58
58
  description: Hum creates HTML from your sass, scss and css documents. View more info
59
59
  at github.com/jefweg/hum
60
60
  email:
@@ -85,6 +85,7 @@ files:
85
85
  - test/haml/direct_child.haml
86
86
  - test/haml/exclude_mixins.haml
87
87
  - test/haml/imports.haml
88
+ - test/haml/input_elements.haml
88
89
  - test/haml/insert_extra_child.haml
89
90
  - test/haml/nested_direct_child.haml
90
91
  - test/haml/nests.haml
@@ -102,6 +103,7 @@ files:
102
103
  - test/sass/direct_child.sass
103
104
  - test/sass/exclude_mixins.sass
104
105
  - test/sass/imports.sass
106
+ - test/sass/input_elements.sass
105
107
  - test/sass/insert_extra_child.sass
106
108
  - test/sass/nested_direct_child.sass
107
109
  - test/sass/nests.sass
@@ -145,6 +147,7 @@ test_files:
145
147
  - test/haml/direct_child.haml
146
148
  - test/haml/exclude_mixins.haml
147
149
  - test/haml/imports.haml
150
+ - test/haml/input_elements.haml
148
151
  - test/haml/insert_extra_child.haml
149
152
  - test/haml/nested_direct_child.haml
150
153
  - test/haml/nests.haml
@@ -162,6 +165,7 @@ test_files:
162
165
  - test/sass/direct_child.sass
163
166
  - test/sass/exclude_mixins.sass
164
167
  - test/sass/imports.sass
168
+ - test/sass/input_elements.sass
165
169
  - test/sass/insert_extra_child.sass
166
170
  - test/sass/nested_direct_child.sass
167
171
  - test/sass/nests.sass