Improves plugin/theme version detection by looking at the "Version: "- Fixes #732

This commit is contained in:
erwanlr
2014-12-05 18:11:49 +01:00
parent a8c55ddee3
commit c24ed707ef
3 changed files with 22 additions and 4 deletions

View File

@@ -13,7 +13,7 @@ class WpItem
# This check is needed because readme_url can return nil # This check is needed because readme_url can return nil
if has_readme? if has_readme?
response = Browser.get(readme_url) response = Browser.get(readme_url)
@version = response.body[%r{stable tag: #{WpVersion.version_pattern}}i, 1] @version = response.body[%r{(?:stable tag|version): #{WpVersion.version_pattern}}i, 1]
end end
end end
@version @version

View File

@@ -0,0 +1,9 @@
=== WP Photo Album Plus ===
Contributors: opajaap
Tags: photo, album, photoalbum, gallery, slideshow, sidebar widget, photowidget, photoblog, widget, qtranslate, cubepoints, multisite, network, lightbox, comment, watermark, iptc, exif, responsive, mobile
Stable tag: trunk
Version: 5.1.15
Author: J.N. Breetvelt
Author URI: http://www.opajaap.nl/
Requires at least: 3.1
Tested up to: 3.7.1

View File

@@ -27,11 +27,20 @@ shared_examples 'WpItem::Versionable' do
end end
context 'when the version is valid' do context 'when the version is valid' do
context 'when leaked from the stable tag' do
it 'returns it' do it 'returns it' do
@file = '/simple-login-lockdown-0.4.txt' @file = '/simple-login-lockdown-0.4.txt'
@expected = '0.4' @expected = '0.4'
end end
end end
context 'when leaked from the version' do
it 'returns it' do
@file = '/wp-photo-plus-5.1.15.txt'
@expected = '5.1.15'
end
end
end
end end
end end