minimal_tags 0.2.7 → 0.2.8
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +16 -0
- data/lib/minimal_tags/persistence/activerecord.rb +1 -1
- data/lib/minimal_tags/persistence/sequel.rb +7 -1
- data/lib/minimal_tags/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f0f6f7becf98b488d84976b205a1739a70c2e09
|
4
|
+
data.tar.gz: cacd5d97b9a8ae2e406463f1fcff5bda78f11a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5943435e6b81751c688ae7f4efc0591a0424381972cd1a62d711df933a331a18a0b35661e0e55bd7970f04ccc8284ff56ddef1332a7a579710ba537dcea154f8
|
7
|
+
data.tar.gz: 9ee352fd719c34ebb7f2e6dc67d452957e1e0129725dad0e13535f7826aac47077498fe084a5483e0117f1a1b22414e12216851375642188e370dcc4043933b1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -95,6 +95,22 @@ Document.without_any_tags(['a', 'b', 'c'])
|
|
95
95
|
Document.without_all_tags(['a', 'b', 'c'])
|
96
96
|
```
|
97
97
|
|
98
|
+
### Partial tags
|
99
|
+
|
100
|
+
**Sequel only for now**
|
101
|
+
|
102
|
+
Find with partial tag match:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
Document.partial_tags('hello').all
|
106
|
+
```
|
107
|
+
|
108
|
+
Array of matching tags:
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
Document.partial_tags('hello').select_map(:mt_tags)
|
112
|
+
```
|
113
|
+
|
98
114
|
## Contributing
|
99
115
|
|
100
116
|
1. Fork it
|
@@ -23,7 +23,7 @@ module MinimalTags
|
|
23
23
|
# doc == Post.any_tags(['HELLO WORLD']).first
|
24
24
|
# # => true
|
25
25
|
#
|
26
|
-
# @param [String] field_name The field name to use
|
26
|
+
# @param [String] field_name The field name to use
|
27
27
|
# @param [Object] formatter The formatter to use, overriding the default
|
28
28
|
def tag_field(field_name, formatter: MinimalTags.default_formatter)
|
29
29
|
# Create the scopes for searching tags
|
@@ -28,7 +28,7 @@ module MinimalTags
|
|
28
28
|
# doc == Post.any_tags(['HELLO WORLD']).first
|
29
29
|
# # => true
|
30
30
|
#
|
31
|
-
# @param [String] field_name The field name to use
|
31
|
+
# @param [String] field_name The field name to use
|
32
32
|
# @param [Object] formatter The formatter to use, overriding the default
|
33
33
|
def tag_field(field_name, formatter: MinimalTags.default_formatter)
|
34
34
|
# Create the scopes for searching tags
|
@@ -43,6 +43,12 @@ module MinimalTags
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
define_singleton_method "partial_#{field_name}" do |term|
|
47
|
+
select_all(table_name)
|
48
|
+
.from(table_name, ::Sequel.pg_array_op(field_name).unnest.as(:mt_tags))
|
49
|
+
.grep(:mt_tags, "%#{term}%")
|
50
|
+
end
|
51
|
+
|
46
52
|
tag_fields << field_name
|
47
53
|
|
48
54
|
# # Normalize tags on save
|
data/lib/minimal_tags/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minimal_tags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- harrisbaird
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|