dry_css 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 682283914a6aa54d3075cd6b9b623165fdf67172
4
- data.tar.gz: 1d28b2d86093d9b93ba927bc76ddddf8ad2c0133
3
+ metadata.gz: 2d5bff36db25b372fa7fd3e8aac6a80c11c65907
4
+ data.tar.gz: 2ab2479dee43aa28d9e3b75a2e8d6a651f350c12
5
5
  SHA512:
6
- metadata.gz: e2195e074ad6cf70d5dcc015df4476d4de7fdc12a2bff223d70dbabf58e6288f1ba74c14b708661466dac98a2c8cc93120bf9c58b2d5b6ac7714a8f8102f80e8
7
- data.tar.gz: ec09e3e24965c174778cd657442e8673ce7834c71dc13049586938d70f85f0a095ed9143f298b70a37f2c5bd2ec64121ff646a239e858deac701a7619b0522f2
6
+ metadata.gz: 8d49bd6a74a1111f7a35040e7f76400b45947db6cea395c6e6f6b3b72027b8b4ebb6823bf886a499a0082418a07e674d6750ff1adaf244dae787ac39fbce4e40
7
+ data.tar.gz: 2a216e5f8eaa3f68de20453f833121d94bfcc94cfd19a3df61e2937bb8ff395bc370bbe72a7ec5418ea930548f5f9ec6c4bdbbcc483a6b69ab3c351e6c8a8368
data/lib/dry_css/site.rb CHANGED
@@ -4,6 +4,7 @@ module DryCss
4
4
  include Nokogiri
5
5
  class Site
6
6
  def initialize(uri)
7
+ @uri = uri
7
8
  @html = Nokogiri::HTML(open(uri))
8
9
  end
9
10
 
@@ -15,9 +16,13 @@ module DryCss
15
16
 
16
17
  def find_uris
17
18
  @uris = []
18
- @html.css('link[rel="stylesheet"]').each{|link| @uris << link[:href]}
19
+ @html.css('link[rel="stylesheet"]').each{|link| @uris << ensure_full_uri(link[:href])}
19
20
  return @uris
20
21
  end
21
22
 
23
+ def ensure_full_uri(path)
24
+ path[0] == '/' ? @uri + path : path
25
+ end
26
+
22
27
  end
23
28
  end
@@ -1,3 +1,3 @@
1
1
  module DryCss
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -4,10 +4,6 @@
4
4
  <meta charset='utf-8'>
5
5
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
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
7
  <link href="http://www.example.com/example.css" media="all" rel="stylesheet" type="text/css" />
12
8
  <link href="http://www.example.com/example2.css" media="all" rel="stylesheet" type="text/css" />
13
9
  </head>
@@ -0,0 +1,14 @@
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 href="/example.css" media="all" rel="stylesheet" type="text/css" />
8
+ <link href="/example2.css" media="all" rel="stylesheet" type="text/css" />
9
+ </head>
10
+ <body>
11
+ <h1>Example Page</h1>
12
+ <p>Just here to test extracting css link uris</p>
13
+ </body>
14
+ </html>
@@ -1,13 +1,17 @@
1
1
  require File.expand_path('../../spec_helper.rb', __FILE__)
2
2
 
3
3
  describe DryCss::Site do
4
- before(:all) do
4
+ it 'returns array of css uris' do
5
5
  file_name = File.dirname(__FILE__) + '/../fixtures/example.html'
6
6
  @site = DryCss::Site.new(file_name)
7
+ @site.uris.should eq(['http://www.example.com/example.css', 'http://www.example.com/example2.css'])
7
8
  end
8
9
 
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'])
10
+ it 'returns full uris from relative links' do
11
+ file_name = File.dirname(__FILE__) + '/../fixtures/example_relative.html'
12
+ @site = DryCss::Site.new(file_name)
13
+ # We prepend 'file_name' for tests in place of uri for production
14
+ @site.uris.should eq([file_name + '/example.css', file_name + '/example2.css'])
11
15
  end
12
16
 
13
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gpxl
@@ -116,6 +116,7 @@ files:
116
116
  - spec/fixtures/example.css
117
117
  - spec/fixtures/example.html
118
118
  - spec/fixtures/example2.css
119
+ - spec/fixtures/example_relative.html
119
120
  - spec/lib/css_spec.rb
120
121
  - spec/lib/dry_css_spec.rb
121
122
  - spec/lib/site_spec.rb
@@ -148,6 +149,7 @@ test_files:
148
149
  - spec/fixtures/example.css
149
150
  - spec/fixtures/example.html
150
151
  - spec/fixtures/example2.css
152
+ - spec/fixtures/example_relative.html
151
153
  - spec/lib/css_spec.rb
152
154
  - spec/lib/dry_css_spec.rb
153
155
  - spec/lib/site_spec.rb