minimal_tags 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 982ffb3fcbf0aae167cfc494d8422f4f29d14583
4
- data.tar.gz: c99866038a6379463d73299e27631db7b99d2d56
3
+ metadata.gz: 3f0f6f7becf98b488d84976b205a1739a70c2e09
4
+ data.tar.gz: cacd5d97b9a8ae2e406463f1fcff5bda78f11a33
5
5
  SHA512:
6
- metadata.gz: 1ece0a77b308a0d362d4fb2e08f4cc50246fd03315108e8f865ffffff07f07519e587528b9b6fe93c5ecbc6d167331e4f32b473988a11fd19d36ed634794ba35
7
- data.tar.gz: 42e3d2a8015fda7db10bf596a0f4f0c6586c526adeca0d4d06c5fbee0490751297b96bba8d0e66b8b3bb970a13aae990ccdb788000327ba9fe72451388efa205
6
+ metadata.gz: 5943435e6b81751c688ae7f4efc0591a0424381972cd1a62d711df933a331a18a0b35661e0e55bd7970f04ccc8284ff56ddef1332a7a579710ba537dcea154f8
7
+ data.tar.gz: 9ee352fd719c34ebb7f2e6dc67d452957e1e0129725dad0e13535f7826aac47077498fe084a5483e0117f1a1b22414e12216851375642188e370dcc4043933b1
data/.travis.yml CHANGED
@@ -19,3 +19,4 @@ before_script:
19
19
  addons:
20
20
  code_climate:
21
21
  repo_token: 3c954617ba40beceb056cc73b82e00a6dc1fa2193cda386dc6c2128bdd61a804
22
+ postgresql: "9.3"
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 in mongo and searching methods
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 in mongo and searching methods
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
@@ -1,3 +1,3 @@
1
1
  module MinimalTags
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
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.7
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-23 00:00:00.000000000 Z
11
+ date: 2016-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg