diff --git a/lib/sniffles/html.rb b/lib/sniffles/html.rb index 2ecb0f0..67e3a57 100644 --- a/lib/sniffles/html.rb +++ b/lib/sniffles/html.rb @@ -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 diff --git a/lib/sniffles/sniffers/cms/invision.rb b/lib/sniffles/sniffers/cms/invision.rb index 2098797..a7a3d50 100644 --- a/lib/sniffles/sniffers/cms/invision.rb +++ b/lib/sniffles/sniffers/cms/invision.rb @@ -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 diff --git a/lib/sniffles/sniffers/cms/wordpress.rb b/lib/sniffles/sniffers/cms/wordpress.rb index 64b5b93..d28f2a6 100644 --- a/lib/sniffles/sniffers/cms/wordpress.rb +++ b/lib/sniffles/sniffers/cms/wordpress.rb @@ -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 diff --git a/sniffles.gemspec b/sniffles.gemspec index e6c7e15..67925c9 100644 --- a/sniffles.gemspec +++ b/sniffles.gemspec @@ -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")