hum 0.0.4 → 0.0.5

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/CHANGELOG.md CHANGED
@@ -12,4 +12,8 @@
12
12
 
13
13
  ## 0.0.4
14
14
 
15
- * Will now run in ruby 1.8.7, support for removing comments
15
+ * Will now run in ruby 1.8.7, support for removing comments
16
+
17
+ ## 0.0.5
18
+
19
+ * Added better support for pseudo elements, fixed some bugs
data/hum.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["Jeffrey Wegesin"]
9
9
  s.email = ["jeff@jwegesin.com"]
10
10
  s.homepage = ""
11
- s.summary = %q{Generate HTML from your SASS or CSS}
12
- s.description = %q{Hum generates HTML from your SASS or CSS. View more info at github.com/jefweg/hum}
11
+ s.summary = %q{Create HTML from your sass, scss or css documents}
12
+ s.description = %q{Hum creates HTML from your sass, scss and css documents. View more info at github.com/jefweg/hum}
13
13
 
14
14
  s.rubyforge_project = "hum"
15
15
 
data/lib/hum/engine.rb CHANGED
@@ -85,6 +85,9 @@ module Hum
85
85
  #remove // coments
86
86
  content.gsub!(/.*\/\/.*/, "")
87
87
 
88
+ #remove @imports
89
+ content.gsub!(/.*@import.*/, "")
90
+
88
91
  #if CSS render SASS
89
92
  if @input_name.match(/\.css/)
90
93
  @sass = Sass::CSS.new(content).render(:sass)
@@ -308,21 +311,35 @@ module Hum
308
311
  def _process_special
309
312
  #in each line
310
313
  @tree.each { |hash|
311
-
314
+
312
315
  #for each select
313
316
  hash[:select].each do |code|
314
-
317
+
315
318
  #if this has a pseudo element
316
319
  if code.match(/:/)
320
+
321
+ #exclude the hash
322
+ hash[:exclude] = true
317
323
 
318
- #remove it
319
- code.gsub!(/:.*/, "")
324
+ #and any children of the hash
325
+ if hash[:kids].length > 0
326
+
327
+ #for each kid
328
+ hash[:kids].each do |kid|
329
+
330
+ #find the child
331
+ child = @tree.find_line(kid)
332
+
333
+ #exclude the child
334
+ child[:exclude] = true
335
+ end
336
+ end
320
337
  end
321
-
338
+
322
339
  end
323
340
  }
324
341
  end
325
-
342
+
326
343
  def _grab_select(code)
327
344
  result = []
328
345
  temp = code.gsub(/\n/, "").gsub(/ /, "")
@@ -379,7 +396,7 @@ module Hum
379
396
  @haml += "\t%head\n"
380
397
  @haml += "\t\t%link{:type => 'text/css', :rel => 'stylesheet', :href => '#{@input_name.gsub(/\..*/, ".css")}'}\n"
381
398
  @haml += "\t%body\n"
382
-
399
+
383
400
  #time to build the HAML
384
401
  @tree.each do |hash|
385
402
 
@@ -412,12 +429,16 @@ module Hum
412
429
 
413
430
  #get the hash
414
431
  extra_hash = @tree.find_line(line)
415
-
416
- #for each generate the HAML line
417
- extra_hash[:haml].each do |haml_tag|
418
432
 
433
+ #for each generate the HAML line
434
+ extra_hash[:haml].each do |extra_haml_tag|
435
+
436
+ ignore = _ignore_tag?(extra_haml_tag, hash)
437
+
419
438
  #do it
420
- @haml += _generate_haml_line(haml_tag, extra_hash)
439
+ if ignore == false
440
+ @haml += _generate_haml_line(extra_haml_tag, extra_hash)
441
+ end
421
442
  end
422
443
  }
423
444
  end
@@ -472,6 +493,35 @@ module Hum
472
493
  haml
473
494
  end
474
495
 
496
+
497
+ def _ignore_tag?(extra_haml_tag, hash)
498
+ #should we ignore?
499
+ ignore = false
500
+
501
+ #if this hash has kids, ensure no duplicates
502
+ if hash[:kids].length > 0
503
+
504
+ #for each kid
505
+ hash[:kids].each do |kid|
506
+
507
+ #find it
508
+ child = @tree.find_line(kid)
509
+
510
+ #for each haml tag
511
+ child[:haml].each { |kid_haml_tag|
512
+
513
+ #if they match, ignore it cause it's already there
514
+ if extra_haml_tag == kid_haml_tag
515
+ ignore = true
516
+ end
517
+ }
518
+ end
519
+
520
+ end
521
+
522
+ ignore
523
+ end
524
+
475
525
  #insert the inner content for HTML tags
476
526
  def _grab_content(hash, found = "")
477
527
 
data/lib/hum/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hum
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/test/engine_tests.rb CHANGED
@@ -77,6 +77,16 @@ class HumText < Test::Unit::TestCase
77
77
  quick_test
78
78
  end
79
79
 
80
+ def test_imports
81
+ @file = "imports"
82
+ quick_test
83
+ end
84
+
85
+ def test_remove_dup_children
86
+ @file = "remove_dup_children"
87
+ quick_test
88
+ end
89
+
80
90
  private
81
91
 
82
92
  def quick_test
@@ -0,0 +1,7 @@
1
+ %html
2
+ %head
3
+ %link{:type => 'text/css', :rel => 'stylesheet', :href => 'imports.css'}
4
+ %body
5
+ %div.foo
6
+ %div.bar
7
+ %div.baz Inner content
@@ -0,0 +1,8 @@
1
+ %html
2
+ %head
3
+ %link{:type => 'text/css', :rel => 'stylesheet', :href => 'remove_dup_children.css'}
4
+ %body
5
+ %div.foo
6
+ %div.bar Inner content
7
+ %div.foo.baz
8
+ %div.bar Inner content
@@ -1,2 +1,8 @@
1
1
  a
2
- color: blue
2
+ color: blue
3
+ &:visited
4
+ color: blue
5
+ &:active
6
+ color: red
7
+ &:hover
8
+ color: purple
@@ -0,0 +1,9 @@
1
+ @import compass/css3
2
+
3
+ =foo
4
+ .foo
5
+ color: black
6
+ .bar
7
+ color: white
8
+ .baz
9
+ color: red
@@ -1,3 +1,15 @@
1
1
  .foo
2
- .bar:last-of-type
3
- color: white
2
+ div:first-of-type
3
+ color: black
4
+ div:last-of-type
5
+ color: white
6
+ div:only-of-type
7
+ color: red
8
+ .bar
9
+ color: black
10
+ &:first-of-type
11
+ color: white
12
+ &:last-of-type
13
+ color: red
14
+ &:only-of-type
15
+ font-size: 12px
@@ -0,0 +1,8 @@
1
+ .foo
2
+ color: black
3
+ .bar
4
+ color: white
5
+ &.baz
6
+ color: red
7
+ .bar
8
+ color: blue
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.4
4
+ version: 0.0.5
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-17 00:00:00.000000000Z
12
+ date: 2012-01-18 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
16
- requirement: &2156107980 !ruby/object:Gem::Requirement
16
+ requirement: &2153477380 !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: *2156107980
24
+ version_requirements: *2153477380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
27
- requirement: &2156107400 !ruby/object:Gem::Requirement
27
+ requirement: &2153476740 !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: *2156107400
35
+ version_requirements: *2153476740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fssm
38
- requirement: &2156106720 !ruby/object:Gem::Requirement
38
+ requirement: &2153476140 !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: *2156106720
46
+ version_requirements: *2153476140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: colored
49
- requirement: &2156105960 !ruby/object:Gem::Requirement
49
+ requirement: &2153475500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,8 +54,9 @@ dependencies:
54
54
  version: '1.2'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2156105960
58
- description: Hum generates HTML from your SASS or CSS. View more info at github.com/jefweg/hum
57
+ version_requirements: *2153475500
58
+ description: Hum creates HTML from your sass, scss and css documents. View more info
59
+ at github.com/jefweg/hum
59
60
  email:
60
61
  - jeff@jwegesin.com
61
62
  executables:
@@ -83,6 +84,7 @@ files:
83
84
  - test/haml/comments.haml
84
85
  - test/haml/direct_child.haml
85
86
  - test/haml/exclude_mixins.haml
87
+ - test/haml/imports.haml
86
88
  - test/haml/insert_extra_child.haml
87
89
  - test/haml/nested_direct_child.haml
88
90
  - test/haml/nests.haml
@@ -90,6 +92,7 @@ files:
90
92
  - test/haml/parent_siblings.haml
91
93
  - test/haml/property_value.haml
92
94
  - test/haml/pseudo_elements.haml
95
+ - test/haml/remove_dup_children.haml
93
96
  - test/haml/siblings.haml
94
97
  - test/haml/single_line_nest.haml
95
98
  - test/other/bad.file
@@ -98,6 +101,7 @@ files:
98
101
  - test/sass/comments.sass
99
102
  - test/sass/direct_child.sass
100
103
  - test/sass/exclude_mixins.sass
104
+ - test/sass/imports.sass
101
105
  - test/sass/insert_extra_child.sass
102
106
  - test/sass/nested_direct_child.sass
103
107
  - test/sass/nests.sass
@@ -105,6 +109,7 @@ files:
105
109
  - test/sass/parent_siblings.sass
106
110
  - test/sass/property_value.sass
107
111
  - test/sass/pseudo_elements.sass
112
+ - test/sass/remove_dup_children.sass
108
113
  - test/sass/siblings.sass
109
114
  - test/sass/single_line_nest.sass
110
115
  - test/sass_convert_test.rb
@@ -131,7 +136,7 @@ rubyforge_project: hum
131
136
  rubygems_version: 1.8.5
132
137
  signing_key:
133
138
  specification_version: 3
134
- summary: Generate HTML from your SASS or CSS
139
+ summary: Create HTML from your sass, scss or css documents
135
140
  test_files:
136
141
  - test/bad_file_test.rb
137
142
  - test/engine_tests.rb
@@ -139,6 +144,7 @@ test_files:
139
144
  - test/haml/comments.haml
140
145
  - test/haml/direct_child.haml
141
146
  - test/haml/exclude_mixins.haml
147
+ - test/haml/imports.haml
142
148
  - test/haml/insert_extra_child.haml
143
149
  - test/haml/nested_direct_child.haml
144
150
  - test/haml/nests.haml
@@ -146,6 +152,7 @@ test_files:
146
152
  - test/haml/parent_siblings.haml
147
153
  - test/haml/property_value.haml
148
154
  - test/haml/pseudo_elements.haml
155
+ - test/haml/remove_dup_children.haml
149
156
  - test/haml/siblings.haml
150
157
  - test/haml/single_line_nest.haml
151
158
  - test/other/bad.file
@@ -154,6 +161,7 @@ test_files:
154
161
  - test/sass/comments.sass
155
162
  - test/sass/direct_child.sass
156
163
  - test/sass/exclude_mixins.sass
164
+ - test/sass/imports.sass
157
165
  - test/sass/insert_extra_child.sass
158
166
  - test/sass/nested_direct_child.sass
159
167
  - test/sass/nests.sass
@@ -161,6 +169,7 @@ test_files:
161
169
  - test/sass/parent_siblings.sass
162
170
  - test/sass/property_value.sass
163
171
  - test/sass/pseudo_elements.sass
172
+ - test/sass/remove_dup_children.sass
164
173
  - test/sass/siblings.sass
165
174
  - test/sass/single_line_nest.sass
166
175
  - test/sass_convert_test.rb