Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue when version is not formatted as expected #57

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sniffles/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def parse(html)

def text_at(pattern)
if (nodes = @doc.search(pattern)).any?
nodes.text
nodes.map(&:value).uniq.first
else
false
end
Expand Down
2 changes: 1 addition & 1 deletion lib/sniffles/sniffers/cms/invision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def parse_version
end

def copyright_link
text_at("//p[@id='copyright']/a")
text_at("//p[@id='copyright']/a/@href")
end
end
end
Expand Down
8 changes: 6 additions & 2 deletions lib/sniffles/sniffers/cms/wordpress.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ def parse_feed

def parse_theme
theme_uri = text_at("//link[@rel='stylesheet' and contains(@href,'wp-content/themes/')][1]/@href")
@output[:theme] = (theme_uri ? clean_theme_uri(theme_uri)[1] : false)
@output[:theme] = theme_uri && clean_theme_uri(theme_uri)&.to_a&.fetch(1, nil)
end

def parse_version
version_meta_tag = text_at("//meta[@name='generator']/@content")
@output[:version] = (version_meta_tag ? extract_version(version_meta_tag)[1] : version_meta_tag)
@output[:version] = version_meta_tag

if @output[:version] && version = extract_version(version_meta_tag)
@output[:version] = version[1]
end
end

def parse_pingback
Expand Down
2 changes: 1 addition & 1 deletion sniffles.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.version = Sniffles::VERSION

gem.add_runtime_dependency("nokogiri", "~> 1.6.1")
gem.add_runtime_dependency("nokogiri", "~> 1.6")

gem.add_development_dependency("rspec", "~> 2.9.0")
gem.add_development_dependency("typhoeus", "~> 0.3.3")
Expand Down