advanced version detection

This commit is contained in:
Christian Mehlmauer
2015-01-19 23:38:26 +01:00
parent 2d39e5b1fa
commit 53f3ce8b1f
3 changed files with 86 additions and 1 deletions

View File

@@ -13,7 +13,15 @@ class WpItem
# This check is needed because readme_url can return nil
if has_readme?
response = Browser.get(readme_url)
@version = response.body[/(?:stable tag|version):\s*(?!trunk)([0-9a-z.-]+)/i, 1]
version = response.body[/(?:stable tag|version):\s*(?!trunk)([0-9a-z.-]+)/i, 1]
if version.nil?
extracted_versions = response.body.scan(/[=]+\s*([0-9.-]+)\s*[=]+/i)
return if extracted_versions.nil? || extracted_versions.length == 0
sorted = extracted_versions.flatten.sort { |x,y| Gem::Version.new(x) <=> Gem::Version.new(y) }
@version = sorted.last
else
@version = version
end
end
end
@version

View File

@@ -0,0 +1,70 @@
=== Like This ===
Contributors: RosemarieP
Tags: karma, likes, post
Requires at least: 3.0
Tested up to: 3.1
Stable tag: trunk
A simple 'I like this' plugin inspired by the facebook 'like' functionality.
== Description ==
A simple 'I like this' plugin inspired by the facebook 'like' functionality. For visitors who don't want to bother with commenting.
http://lifeasrose.ca/2011/03/wordpress-plugin-i-like-this
has a blog entry all about it :)
A big thanks to Dong (ddliuhb@gmail.com) for finding a syntactical error that was causing problems for some people. And thanks to Raphael (ressoosnowdon@googlemail.com) for noticing this error and working hard to figure out what it was.
== Installation ==
1. Upload the files into a folder named `roses-like-this` to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Place `<?php printLikes(get_the_ID()); ?>` in 'the loop' of your posts wherever you want the 'like this' link to appear.
IMPORTANT!!!!
PLEASE MAKE SURE THAT YOUR THEME HAS THE FOLLOWING LINE IN ITS HEADER FILE:
`<?php wp_print_scripts(); ?>`
...Most high quality themes should have this already but if you're writing your own theme or using a custom theme that doesn't include this line, please make sure you include it in header.php, somewhere between `<head>` and `</head>`
== Frequently Asked Questions ==
= How can I make the 'like this' link look prettier? =
With CSS :) Here is the code that I use:
`a.done {
background:url("http://yoururl.com/wordpress/plugins/roses-like-this/action_check.png") bottom right no-repeat;
padding-right:18px;
color:#8bcb46;
}`
= The javascript is not working! =
IMPORTANT!!!!
PLEASE MAKE SURE THAT YOUR THEME HAS THE FOLLOWING LINE IN ITS HEADER FILE:
`<?php wp_print_scripts(); ?>`
= The javascript is STILL not working!!! =
Do you call get_header() in your theme? This is also needed, although almost certainly there anyway.
= The javascript is STILL not working AGAIN!!! =
The plugin expects to find the javascript file in a folder called `roses-like-this` under /plugins. So if you have named the folder something else, you're probably getting a 404 error!
To fix, you can either rename your folder `roses-like-this` OR you can edit the `likethis.php` file and edit line `112` roses-like-this/ to yourfoldername/
== Changelog ==
= 1.0 =
* The very first version of this plugin :)
= 1.01 =
* Made a small change for those of you installing directly from wordpress.org. This changes the default directory from `likeThis` to `roses-like-this` in order to coincide with what wordpress will install. Should lead to less confusion!
= 1.1 =
* Major bug fix! :) Anyone having an issue where the likeThis link clicking wasn't saving in the database should find it fixed.
= 1.2 =
* Bug Fix for those having issues with cookies not being saved correctly.
= 1.3 =
* Added sidebar widget for displaying most liked posts

View File

@@ -54,6 +54,13 @@ shared_examples 'WpItem::Versionable' do
@expected = '2.0.0-beta1'
end
end
context 'when parsing the changelog for version numbers' do
it 'returns it' do
@file = '/changelog_version.txt'
@expected = '1.3'
end
end
end
end
end