stowaway 0.1.1 → 0.1.2
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/VERSION.yml +1 -1
- data/lib/stowaway/locator.rb +1 -1
- data/lib/stowaway/matcher.rb +19 -13
- data/spec/data/testfile1.txt +3 -0
- data/spec/lib/sweeper_spec.rb +14 -2
- data/stowaway.gemspec +2 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/stowaway/locator.rb
CHANGED
data/lib/stowaway/matcher.rb
CHANGED
@@ -1,38 +1,44 @@
|
|
1
1
|
module Stowaway
|
2
2
|
class Matcher
|
3
3
|
def match?(line, file)
|
4
|
-
|
5
|
-
return true if
|
6
|
-
return true if
|
4
|
+
@line, @file = line, file
|
5
|
+
return true if html_attr_ref?
|
6
|
+
return true if haml_attr_ref?
|
7
|
+
return true if rails_js_ref?
|
8
|
+
return true if rails_css_ref?
|
7
9
|
end
|
8
10
|
|
9
11
|
private
|
10
12
|
|
11
|
-
def
|
12
|
-
line =~ /(src|link|href)
|
13
|
+
def html_attr_ref?
|
14
|
+
@line =~ /(src|link|href|:href)\s?[=|=>]\s?(["|'])(#{@file.fullpath})(\2)/
|
13
15
|
end
|
14
16
|
|
15
|
-
def
|
16
|
-
|
17
|
+
def haml_attr_ref?
|
18
|
+
@line =~ /(:src|:link|:href)(\s?=>\s?)(["|'])(#{@file.fullpath})(\3)/
|
19
|
+
end
|
20
|
+
|
21
|
+
def rails_js_ref?
|
22
|
+
return false unless @line =~ /=?\s(javascript_include_tag)?\s(["|'])(.+)(\2)/
|
17
23
|
params = $3.gsub(/[\s|"]/, "").split(",")
|
18
24
|
params.each do |f|
|
19
25
|
if f =~ /\.js$/
|
20
|
-
return true if "/public/javascripts/#{f}" == file.fullpath
|
26
|
+
return true if "/public/javascripts/#{f}" == @file.fullpath
|
21
27
|
else
|
22
|
-
return true if "/public/javascripts/#{f}.js" == file.fullpath
|
28
|
+
return true if "/public/javascripts/#{f}.js" == @file.fullpath
|
23
29
|
end
|
24
30
|
end
|
25
31
|
false
|
26
32
|
end
|
27
33
|
|
28
|
-
def rails_css_ref?
|
29
|
-
return false unless line =~ /=?\s(stylesheet_link_tag)?\s(["|'])(.+)(\2)/
|
34
|
+
def rails_css_ref?
|
35
|
+
return false unless @line =~ /=?\s(stylesheet_link_tag)?\s(["|'])(.+)(\2)/
|
30
36
|
params = $3.gsub(/[\s|"]/, "").split(",")
|
31
37
|
params.each do |f|
|
32
38
|
if f =~ /\.css$/
|
33
|
-
return true if "/public/stylesheets/#{f}" == file.fullpath
|
39
|
+
return true if "/public/stylesheets/#{f}" == @file.fullpath
|
34
40
|
else
|
35
|
-
return true if "/public/stylesheets/#{f}.css" == file.fullpath
|
41
|
+
return true if "/public/stylesheets/#{f}.css" == @file.fullpath
|
36
42
|
end
|
37
43
|
end
|
38
44
|
false
|
data/spec/data/testfile1.txt
CHANGED
@@ -5,4 +5,7 @@ this filename on this line should be ignored: file1.js.
|
|
5
5
|
= javascript_include_tag "application"
|
6
6
|
= stylesheet_link_tag "file.css"
|
7
7
|
= stylesheet_link_tag "reset", "common"
|
8
|
+
%a{ :href => "/images/haml.jpg", :title => "haml" }
|
9
|
+
%img{ :src => "/images/file.jpg", :alt => "file" }
|
10
|
+
|
8
11
|
the end.
|
data/spec/lib/sweeper_spec.rb
CHANGED
@@ -14,18 +14,30 @@ describe Stowaway::Sweeper do
|
|
14
14
|
@status_mock = mock("status_mock", :null_object => true)
|
15
15
|
end
|
16
16
|
|
17
|
-
it "should match images
|
17
|
+
it "should match images referenced in a src attribute" do
|
18
18
|
@files << Stowaway::FileObj.new("/fake/path1/button.jpg")
|
19
19
|
sweeper.sweep("spec/data")
|
20
20
|
@files.should be_empty
|
21
21
|
end
|
22
22
|
|
23
|
-
it "should match images
|
23
|
+
it "should match images referenced in an href attribute" do
|
24
24
|
@files << Stowaway::FileObj.new("/fake/path/photo.jpg")
|
25
25
|
sweeper.sweep("spec/data")
|
26
26
|
@files.should be_empty
|
27
27
|
end
|
28
28
|
|
29
|
+
it "should match images referenced in an href attribute when using haml" do
|
30
|
+
@files << Stowaway::FileObj.new("/images/haml.jpg")
|
31
|
+
sweeper.sweep("spec/data")
|
32
|
+
@files.should be_empty
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should match images referenced in a src attribute when using haml" do
|
36
|
+
@files << Stowaway::FileObj.new("/images/file.jpg")
|
37
|
+
sweeper.sweep("spec/data")
|
38
|
+
@files.should be_empty
|
39
|
+
end
|
40
|
+
|
29
41
|
it "should match scripts referenced in a src attribute" do
|
30
42
|
@files << Stowaway::FileObj.new("/fake/path/file.js")
|
31
43
|
sweeper.sweep("spec/data")
|
data/stowaway.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{stowaway}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Emilio Cavazos"]
|
12
|
-
s.date = %q{2010-02-
|
12
|
+
s.date = %q{2010-02-15}
|
13
13
|
s.default_executable = %q{stowaway}
|
14
14
|
s.email = %q{ejcavazos@gmail.com}
|
15
15
|
s.executables = ["stowaway"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stowaway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilio Cavazos
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-15 00:00:00 -08:00
|
13
13
|
default_executable: stowaway
|
14
14
|
dependencies: []
|
15
15
|
|