hum 0.0.3 → 0.0.4

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
@@ -8,4 +8,8 @@
8
8
 
9
9
  ## 0.0.3
10
10
 
11
- * Added support for other bits of .sass, better processing
11
+ * Added support for other bits of .sass, better processing
12
+
13
+ ## 0.0.4
14
+
15
+ * Will now run in ruby 1.8.7, support for removing comments
data/lib/hum/engine.rb CHANGED
@@ -32,7 +32,7 @@ module Hum
32
32
  @directory = File.dirname(file)
33
33
 
34
34
  #the output path
35
- @output_path = File.absolute_path(file).gsub(/\..*/, ".html")
35
+ @output_path = File.expand_path(file).gsub(/\..*/, ".html")
36
36
 
37
37
  #the name of the output file
38
38
  @output_name = File.basename(@output_path)
@@ -53,7 +53,7 @@ module Hum
53
53
  #close the output file
54
54
  @output_file.close()
55
55
 
56
- puts "updated #{@output_name}".green
56
+ puts "updated #{@output_name}".bold
57
57
  end
58
58
 
59
59
  def run_haml
@@ -74,27 +74,34 @@ module Hum
74
74
  end
75
75
 
76
76
  def render_sass
77
+ opts = { :cache => false, :read_cache => true, :syntax => :scss }
78
+
77
79
  #read content
78
80
  content = @input_file.read
81
+
82
+ #remove /**/ comments
83
+ content.gsub!(/.*\/\*([\s\S]*?)\*\//, "")
79
84
 
80
- #remove all comments
81
- content.gsub!(/\/\*([\s\S]*?)\*\//, "")
82
-
85
+ #remove // coments
86
+ content.gsub!(/.*\/\/.*/, "")
87
+
83
88
  #if CSS render SASS
84
89
  if @input_name.match(/\.css/)
85
90
  @sass = Sass::CSS.new(content).render(:sass)
86
91
 
87
92
  #if SCSS convert to SASS
88
93
  elsif @input_name.match(/\.scss/)
89
- @sass = ::Sass::Engine.new(content, { :cache => false, :read_cache => true, :syntax => :scss }).to_tree.send("to_sass")
94
+ @sass = ::Sass::Engine.new(content, opts).to_tree.send("to_sass")
90
95
 
91
96
  #if sass keep as it
92
97
  elsif @input_name.match(/\.sass/)
93
- @sass = content
94
-
98
+ #doing this at the moment to make sure the sass is formatted correctly, as using sass-convert does some nifty formatting
99
+ scss = ::Sass::Engine.new(content, {:cache => false, :read_cache => true, :syntax => :sass}).to_tree.send("to_scss")
100
+ @sass = ::Sass::Engine.new(scss, opts).to_tree.send("to_sass")
101
+
95
102
  #if nothing then put error
96
103
  else
97
- puts "Hum only works with .scss, .sass and .css files.".red
104
+ puts "Hum only works with .scss, .sass and .css files.".bold
98
105
  exit 1
99
106
  end
100
107
  end
data/lib/hum/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hum
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/engine_tests.rb CHANGED
@@ -72,6 +72,11 @@ class HumText < Test::Unit::TestCase
72
72
  quick_test
73
73
  end
74
74
 
75
+ def test_comments
76
+ @file = "comments"
77
+ quick_test
78
+ end
79
+
75
80
  private
76
81
 
77
82
  def quick_test
@@ -0,0 +1,7 @@
1
+ %html
2
+ %head
3
+ %link{:type => 'text/css', :rel => 'stylesheet', :href => 'comments.css'}
4
+ %body
5
+ %div.foo
6
+ %div.bar
7
+ %div.baz Inner content
@@ -0,0 +1,11 @@
1
+ /*
2
+ comment
3
+ */
4
+ .foo
5
+ //comment
6
+ color: white
7
+ .bar
8
+ color: black
9
+ .baz
10
+ color: red
11
+ /* comment * comment */
@@ -1,6 +1,6 @@
1
1
  .foo
2
2
  color: white
3
- &.bar
4
- color: black
5
- .baz
3
+ &.bar
4
+ color: black
5
+ .baz
6
6
  color: red
@@ -1,6 +1,6 @@
1
1
  .foo
2
2
  color: white
3
- .bar
4
- color: black
5
- &.baz, &.buz
6
- color: red
3
+ .bar
4
+ color: black
5
+ &.baz, &.buz
6
+ color: red
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.3
4
+ version: 0.0.4
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-16 00:00:00.000000000Z
12
+ date: 2012-01-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sass
16
- requirement: &2153483860 !ruby/object:Gem::Requirement
16
+ requirement: &2156107980 !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: *2153483860
24
+ version_requirements: *2156107980
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: haml
27
- requirement: &2153483160 !ruby/object:Gem::Requirement
27
+ requirement: &2156107400 !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: *2153483160
35
+ version_requirements: *2156107400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fssm
38
- requirement: &2153482500 !ruby/object:Gem::Requirement
38
+ requirement: &2156106720 !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: *2153482500
46
+ version_requirements: *2156106720
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: colored
49
- requirement: &2153481820 !ruby/object:Gem::Requirement
49
+ requirement: &2156105960 !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: *2153481820
57
+ version_requirements: *2156105960
58
58
  description: Hum generates HTML from your SASS or CSS. View more info at github.com/jefweg/hum
59
59
  email:
60
60
  - jeff@jwegesin.com
@@ -80,6 +80,7 @@ files:
80
80
  - test/bad_file_test.rb
81
81
  - test/engine_tests.rb
82
82
  - test/haml/anchor_links.haml
83
+ - test/haml/comments.haml
83
84
  - test/haml/direct_child.haml
84
85
  - test/haml/exclude_mixins.haml
85
86
  - test/haml/insert_extra_child.haml
@@ -94,6 +95,7 @@ files:
94
95
  - test/other/bad.file
95
96
  - test/other/example.scss
96
97
  - test/sass/anchor_links.sass
98
+ - test/sass/comments.sass
97
99
  - test/sass/direct_child.sass
98
100
  - test/sass/exclude_mixins.sass
99
101
  - test/sass/insert_extra_child.sass
@@ -134,6 +136,7 @@ test_files:
134
136
  - test/bad_file_test.rb
135
137
  - test/engine_tests.rb
136
138
  - test/haml/anchor_links.haml
139
+ - test/haml/comments.haml
137
140
  - test/haml/direct_child.haml
138
141
  - test/haml/exclude_mixins.haml
139
142
  - test/haml/insert_extra_child.haml
@@ -148,6 +151,7 @@ test_files:
148
151
  - test/other/bad.file
149
152
  - test/other/example.scss
150
153
  - test/sass/anchor_links.sass
154
+ - test/sass/comments.sass
151
155
  - test/sass/direct_child.sass
152
156
  - test/sass/exclude_mixins.sass
153
157
  - test/sass/insert_extra_child.sass