kompress 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -28,6 +28,7 @@ require 'rspec/core'
28
28
  require 'rspec/core/rake_task'
29
29
  RSpec::Core::RakeTask.new(:spec) do |spec|
30
30
  spec.pattern = FileList['spec/**/*_spec.rb']
31
+ spec.rspec_opts = ['--color', '--format nested']
31
32
  end
32
33
 
33
34
  RSpec::Core::RakeTask.new(:rcov) do |spec|
data/kompress.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{kompress}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Al Shaw"]
@@ -29,7 +29,14 @@ module Kompress
29
29
 
30
30
  def initialize(html)
31
31
  @html = html
32
+
33
+ # take out spaces between the beginning or any number
34
+ # of spaces until a tag
32
35
  @html.gsub!(/(?:^|\s+?)(<.*?>)/, '\1')
36
+
37
+ # take out spaces between a tag and the end.
38
+ @html.gsub!(/(<.*?>)(?:\s+)$/,'\1')
39
+
33
40
  @html
34
41
  end
35
42
  end
@@ -1,3 +1,3 @@
1
1
  module Kompress
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,8 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe "Kompress CSS" do
4
- it "should compress css" do
5
- k = Kompress::CSS.new(BIG_CSS)
6
- k.css.should eql SMALL_CSS
3
+ describe "Kompress" do
4
+ %w[css html].each do |lang|
5
+ it "should compress #{lang}" do
6
+ k = Kompress.const_get("#{lang.upcase}").new(Kernel.const_get("BIG_#{lang.upcase}"))
7
+ k.send(lang).should eql Kernel.const_get("SMALL_#{lang.upcase}")
8
+ end
7
9
  end
8
10
  end
data/spec/spec_helper.rb CHANGED
@@ -60,6 +60,58 @@ CSS
60
60
 
61
61
  SMALL_CSS = small_css.strip
62
62
 
63
+ BIG_HTML = <<-HTML
64
+ <div id="banner">
65
+ <div class="wrapper">
66
+ <div id="banner-identity">
67
+ <h1 id="banner-logo"><a href="/" class="pngfix">ProPublica</a></h1>
68
+ <p id="banner-tagline">Journalism in the public interest.</p>
69
+ </div>
70
+ <div id="banner-updates">
71
+ <form method="get" action="http://org2.democracyinaction.org/dia/api/process.jsp">
72
+ <input type="hidden" name="table" value="supporter">
73
+ <input type="hidden" name="key" value="0">
74
+ <input type="hidden" name="required" value="Email">
75
+ <input type="hidden" name="link" value="groups">
76
+ <input type="hidden" name="linkKey" value="90412">
77
+ <input type="hidden" name="redirect" value="http://www.propublica.org/about/thank-you">
78
+ <input type="hidden" name="Receive_Email" value="3">
79
+ <input type="hidden" name="organization_KEY" value="6253">
80
+ <input type="hidden" name="email_trigger_KEYS" value="8405">
81
+ <p>Receive our top stories daily</p>
82
+ <div class="form-row text-row">
83
+ <input type="text" class="text-input" id="subscribe-email" value="Subscribe via e-mail" name="Email" />
84
+ <input type="submit" value="Sign Up" class="btn-input" />
85
+ </div>
86
+ <div class="form-row text-row">
87
+ <input type="text" class="text-input" id="subscribe-zip" value="zip-code" name="Zip" /> <span>optional</span>
88
+ </div>
89
+ </form>
90
+ </div><!-- /#banner-updates -->
91
+ </div><!--/.wrapper-->
92
+ </div><!--#banner-->
93
+ <div id="banner-nav">
94
+ <!--[if IE]>
95
+ <link rel="stylesheet" href="http://www.propublica.org/css/ie.css?1301677503" type="text/css" media="screen" charset="utf-8" />
96
+ <![endif]-->
97
+ <!--[if IE 7]>
98
+ <link rel="stylesheet" href="http://www.propublica.org/css/ie7.css?1301677503" type="text/css" media="screen" charset="utf-8" />
99
+ <!--[if IE]>
100
+ <link rel="stylesheet" href="http://www.propublica.org/css/ie.css?1301677503" type="text/css" media="screen" charset="utf-8" />
101
+ <![endif]-->
102
+ <!--[if IE 7]>
103
+ <link rel="stylesheet" href="http://www.propublica.org/css/ie7.css?1301677503" type="text/css" media="screen" charset="utf-8" />
104
+ <![endif]-->
105
+ <div></div>
106
+ <br>
107
+ HTML
108
+
109
+ small_html = <<-HTML
110
+ <div id="banner"><div class="wrapper"><div id="banner-identity"><h1 id="banner-logo"><a href="/" class="pngfix">ProPublica</a></h1><p id="banner-tagline">Journalism in the public interest.</p></div><div id="banner-updates"><form method="get" action="http://org2.democracyinaction.org/dia/api/process.jsp"><input type="hidden" name="table" value="supporter"><input type="hidden" name="key" value="0"><input type="hidden" name="required" value="Email"><input type="hidden" name="link" value="groups"><input type="hidden" name="linkKey" value="90412"><input type="hidden" name="redirect" value="http://www.propublica.org/about/thank-you"><input type="hidden" name="Receive_Email" value="3"><input type="hidden" name="organization_KEY" value="6253"><input type="hidden" name="email_trigger_KEYS" value="8405"><p>Receive our top stories daily</p><div class="form-row text-row"><input type="text" class="text-input" id="subscribe-email" value="Subscribe via e-mail" name="Email" /><input type="submit" value="Sign Up" class="btn-input" /></div><div class="form-row text-row"><input type="text" class="text-input" id="subscribe-zip" value="zip-code" name="Zip" /><span>optional</span></div></form></div><!-- /#banner-updates --></div><!--/.wrapper--></div><!--#banner--><div id="banner-nav"><!--[if IE]><link rel="stylesheet" href="http://www.propublica.org/css/ie.css?1301677503" type="text/css" media="screen" charset="utf-8" /><![endif]--><!--[if IE 7]><link rel="stylesheet" href="http://www.propublica.org/css/ie7.css?1301677503" type="text/css" media="screen" charset="utf-8" /><!--[if IE]><link rel="stylesheet" href="http://www.propublica.org/css/ie.css?1301677503" type="text/css" media="screen" charset="utf-8" /><![endif]--><!--[if IE 7]><link rel="stylesheet" href="http://www.propublica.org/css/ie7.css?1301677503" type="text/css" media="screen" charset="utf-8" /><![endif]--><div></div><br>
111
+ HTML
112
+
113
+ SMALL_HTML = small_html.strip
114
+
63
115
 
64
116
  RSpec.configure do |config|
65
117
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kompress
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Al Shaw