has_friendly_name 0.4 → 0.5
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/lib/has_friendly_name.rb +2 -2
- metadata +4 -4
data/lib/has_friendly_name.rb
CHANGED
|
@@ -17,10 +17,10 @@ module HasFriendlyName
|
|
|
17
17
|
include HasFriendlyName::InstanceMethods
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
def find_by_friendly_name(query)
|
|
20
|
+
def find_by_friendly_name(query, options={})
|
|
21
21
|
obj = find(:first, :conditions => "friendly_name ='#{query}'")
|
|
22
22
|
|
|
23
|
-
if query.match(/\d+/)
|
|
23
|
+
if query.match(/\d+/) and !options[:exact]
|
|
24
24
|
obj = find(:first, :conditions => "friendly_name = '#{query.gsub(/-\d+/, "")}'") unless obj
|
|
25
25
|
obj = find(:first, :conditions => "friendly_name LIKE '#{query.gsub(/-\d+/, "")}-%'") unless obj
|
|
26
26
|
end
|
metadata
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: has_friendly_name
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 1
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
|
-
-
|
|
9
|
-
version: "0.
|
|
8
|
+
- 5
|
|
9
|
+
version: "0.5"
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Dennis Meise
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-08-10 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies: []
|
|
20
20
|
|