dry_css 0.0.2 → 0.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cc21deeea99eb04e0ea76e0ac6fb026b0a5399d
4
- data.tar.gz: c880cb5ffe464fb6708717867a202e525cc54756
3
+ metadata.gz: 682283914a6aa54d3075cd6b9b623165fdf67172
4
+ data.tar.gz: 1d28b2d86093d9b93ba927bc76ddddf8ad2c0133
5
5
  SHA512:
6
- metadata.gz: 2e0929f89775c36e6b4e59f9c1b19eb2ded19a2dfeae09700dbb4d86ba261aca3df5584cf01b72c1081472286ad7d62fd329af8d70857856a16fd58df215f708
7
- data.tar.gz: 4f7873ac64b3dbc17ea39d179d8d3e6593f979eaa442f2cf87bf3a0a8226dfc2d30bc2ca70166fdacfd16d9a426657ff3e67281e93cb3a9549cf9e74a162887c
6
+ metadata.gz: e2195e074ad6cf70d5dcc015df4476d4de7fdc12a2bff223d70dbabf58e6288f1ba74c14b708661466dac98a2c8cc93120bf9c58b2d5b6ac7714a8f8102f80e8
7
+ data.tar.gz: ec09e3e24965c174778cd657442e8673ce7834c71dc13049586938d70f85f0a095ed9143f298b70a37f2c5bd2ec64121ff646a239e858deac701a7619b0522f2
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode # JRuby in 1.9 mode
5
+ - rbx-19mode
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ <img src="https://travis-ci.org/gpxl/DryCss.png?branch=master" />
2
+
1
3
  # DryCss
2
4
 
3
5
  A gem for identifying redundant css
data/dry_css.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "webmock"
25
25
 
26
26
  spec.add_runtime_dependency "css_parser"
27
+ spec.add_runtime_dependency "nokogiri"
27
28
  end
data/lib/dry_css/css.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  module DryCss
2
2
  class CSS
3
3
  attr_reader :parser
4
- def initialize(uri)
4
+ def initialize(*uri)
5
5
  @parser = DryCss::Parser.new
6
- @parser.load_uri!(uri)
6
+ uri.each do |u|
7
+ @parser.load_uri!(u)
8
+ end
7
9
  end
8
10
 
9
11
  def colors
@@ -0,0 +1,23 @@
1
+ require "nokogiri"
2
+
3
+ module DryCss
4
+ include Nokogiri
5
+ class Site
6
+ def initialize(uri)
7
+ @html = Nokogiri::HTML(open(uri))
8
+ end
9
+
10
+ def uris
11
+ @uris ||= find_uris
12
+ end
13
+
14
+ private
15
+
16
+ def find_uris
17
+ @uris = []
18
+ @html.css('link[rel="stylesheet"]').each{|link| @uris << link[:href]}
19
+ return @uris
20
+ end
21
+
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module DryCss
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <title></title>
7
+ <link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-114.png" />
8
+ <link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114.png" />
9
+ <link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-144.png" />
10
+ <link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144.png" />
11
+ <link href="http://www.example.com/example.css" media="all" rel="stylesheet" type="text/css" />
12
+ <link href="http://www.example.com/example2.css" media="all" rel="stylesheet" type="text/css" />
13
+ </head>
14
+ <body>
15
+ <h1>Example Page</h1>
16
+ <p>Just here to test extracting css link uris</p>
17
+ </body>
18
+ </html>
@@ -0,0 +1,8 @@
1
+ body {
2
+ background: #fff;
3
+ color: #000;
4
+ }
5
+
6
+ a {
7
+ color: #000;
8
+ }
data/spec/lib/css_spec.rb CHANGED
@@ -14,4 +14,11 @@ describe DryCss::CSS do
14
14
  @css.colors.should eq({:counts => {:"#fff;"=>1, :"#000;"=>2}, :total => 3})
15
15
  end
16
16
 
17
+ it 'handles multiple uris' do
18
+ file_name = 'file://' + File.expand_path(File.dirname(__FILE__)) + '/../fixtures/example.css'
19
+ file_name2 = 'file://' + File.expand_path(File.dirname(__FILE__)) + '/../fixtures/example2.css'
20
+ @css = DryCss::CSS.new(file_name, file_name2)
21
+ @css.colors.should eq({:counts => {:"#fff;"=>2, :"#000;"=>4}, :total => 6})
22
+ end
23
+
17
24
  end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('../../spec_helper.rb', __FILE__)
2
+
3
+ describe DryCss::Site do
4
+ before(:all) do
5
+ file_name = File.dirname(__FILE__) + '/../fixtures/example.html'
6
+ @site = DryCss::Site.new(file_name)
7
+ end
8
+
9
+ it 'returns array of css uris' do
10
+ @site.uris.should eq(['http://www.example.com/example.css', 'http://www.example.com/example2.css'])
11
+ end
12
+
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gpxl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-14 00:00:00.000000000 Z
11
+ date: 2013-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: A gem for pointing out redundant css
84
98
  email:
85
99
  - gerlando@gmail.com
@@ -88,6 +102,7 @@ extensions: []
88
102
  extra_rdoc_files: []
89
103
  files:
90
104
  - .gitignore
105
+ - .travis.yml
91
106
  - Gemfile
92
107
  - LICENSE.txt
93
108
  - README.md
@@ -96,10 +111,14 @@ files:
96
111
  - lib/dry_css.rb
97
112
  - lib/dry_css/css.rb
98
113
  - lib/dry_css/parser.rb
114
+ - lib/dry_css/site.rb
99
115
  - lib/dry_css/version.rb
100
116
  - spec/fixtures/example.css
117
+ - spec/fixtures/example.html
118
+ - spec/fixtures/example2.css
101
119
  - spec/lib/css_spec.rb
102
120
  - spec/lib/dry_css_spec.rb
121
+ - spec/lib/site_spec.rb
103
122
  - spec/spec_helper.rb
104
123
  homepage: ''
105
124
  licenses:
@@ -127,6 +146,9 @@ specification_version: 4
127
146
  summary: A gem for pointing out redundant css (ironic?)
128
147
  test_files:
129
148
  - spec/fixtures/example.css
149
+ - spec/fixtures/example.html
150
+ - spec/fixtures/example2.css
130
151
  - spec/lib/css_spec.rb
131
152
  - spec/lib/dry_css_spec.rb
153
+ - spec/lib/site_spec.rb
132
154
  - spec/spec_helper.rb