dragoon_system 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dragoon_system.gemspec +2 -1
- data/lib/active_record/base_patch.rb +29 -2
- data/lib/patches.rb +5 -0
- data/test/helper.rb +0 -1
- data/test/test_dragoon_system.rb +1 -5
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/dragoon_system.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{dragoon_system}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["zhanyinan"]
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"dragoon_system.gemspec",
|
28
28
|
"lib/active_record/base_patch.rb",
|
29
29
|
"lib/dragoon_system.rb",
|
30
|
+
"lib/patches.rb",
|
30
31
|
"lib/string_path.rb",
|
31
32
|
"test/helper.rb",
|
32
33
|
"test/test_dragoon_system.rb"
|
@@ -20,13 +20,33 @@ module ActiveRecord
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def newest
|
24
|
+
scoped(:order => "#{self.table_name}.updated_at desc")
|
25
|
+
end
|
26
|
+
|
27
|
+
def desc
|
28
|
+
scoped(:order => "#{self.table_name}.created_at desc")
|
29
|
+
end
|
30
|
+
|
31
|
+
def regexp(field, data, table = table_name)
|
32
|
+
table_name = if table.is_a?(String)
|
33
|
+
table
|
34
|
+
elsif table < ActiveRecord::Base
|
35
|
+
table.table_name
|
36
|
+
else
|
37
|
+
raise ArgumentError
|
38
|
+
end
|
39
|
+
|
40
|
+
regexp_condition(field, data, table_name)
|
41
|
+
end
|
42
|
+
|
23
43
|
private
|
24
44
|
|
25
|
-
def
|
45
|
+
def or_empty_scope(param)
|
26
46
|
unless param.blank?
|
27
47
|
yield
|
28
48
|
else
|
29
|
-
|
49
|
+
scoped
|
30
50
|
end
|
31
51
|
end
|
32
52
|
|
@@ -37,6 +57,13 @@ module ActiveRecord
|
|
37
57
|
input.split(" ").uniq
|
38
58
|
end
|
39
59
|
end
|
60
|
+
|
61
|
+
def regexp_condition(field, data, table)
|
62
|
+
or_empty_scope(data) do
|
63
|
+
data = handle_input(data).join("|")
|
64
|
+
{:conditions => ["#{table}.#{field} regexp ? ", data]}
|
65
|
+
end
|
66
|
+
end
|
40
67
|
end
|
41
68
|
|
42
69
|
|
data/lib/patches.rb
ADDED
data/test/helper.rb
CHANGED
data/test/test_dragoon_system.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragoon_system
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- zhanyinan
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- dragoon_system.gemspec
|
101
101
|
- lib/active_record/base_patch.rb
|
102
102
|
- lib/dragoon_system.rb
|
103
|
+
- lib/patches.rb
|
103
104
|
- lib/string_path.rb
|
104
105
|
- test/helper.rb
|
105
106
|
- test/test_dragoon_system.rb
|