mobility 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aca3c693e765d0214134a9aba41659f40f74f3a0
4
- data.tar.gz: 4f3fd42701ae4dd0bfa0c6ee990a296ec4364d7c
3
+ metadata.gz: 5b4475c1c4828150f79f535dd8974561e2d5b819
4
+ data.tar.gz: 03ce38c5557fb60468f07b3eae5b8f797625c798
5
5
  SHA512:
6
- metadata.gz: 97ffa08e1c6cea2d3301bd642c1ce5c7ea86aae11d59402471afc236cdcc53b6daea6ac9bcfaf34b6cc7e509f09aed205e8b1cba65e1614adb2fd75f0107fda8
7
- data.tar.gz: dc1581bded2b253d645172ad28b1e0f1cede386633d1a4d343603869da6561a165b408b7b6ca7722eca5ada6c1c29052b7c7c3f2f9f24f122b25db0fdc9001f2
6
+ metadata.gz: 2a19d72816a4c76d79a6e46a7d5a5f3eb63e6620a38a0bd29f1cc0dd7ed2361dbae12b3678afde7277d29397d8de1aed4788d99718edbea5139b0c3b0899a754
7
+ data.tar.gz: d9d15056bd2bfdc5238e5bb4003ae3352df6581175abd6d899546064bda8e1f41f3377124ea5309df78715fdb4d3e6262624ccdccf9c8203d94e84c3a19f86d3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## 0.4
4
4
 
5
+ ### 0.4.1 (January 29, 2018)
6
+ * Use element operator instead of contains for jsonb query8ing
7
+ ([#159](https://github.com/shioyama/mobility/pull/159))
8
+
5
9
  ### 0.4.0 (January 24, 2018)
6
10
  * Add new jsonb Container backend
7
11
  ([#157](https://github.com/shioyama/mobility/pull/157))
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (0.4.0.alpha.1)
4
+ mobility (0.4.0)
5
5
  i18n (>= 0.6.10, < 0.10)
6
6
  request_store (~> 1.0)
7
7
 
@@ -61,7 +61,7 @@ GEM
61
61
  guard (~> 2.1)
62
62
  guard-compat (~> 1.1)
63
63
  rspec (>= 2.99.0, < 4.0)
64
- i18n (0.9.1)
64
+ i18n (0.9.3)
65
65
  concurrent-ruby (~> 1.0)
66
66
  listen (3.1.5)
67
67
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -73,7 +73,7 @@ GEM
73
73
  lumberjack (1.0.12)
74
74
  method_source (0.9.0)
75
75
  mini_portile2 (2.3.0)
76
- minitest (5.11.1)
76
+ minitest (5.11.3)
77
77
  mysql2 (0.4.10)
78
78
  nenv (0.3.0)
79
79
  nokogiri (1.8.1)
data/README.md CHANGED
@@ -54,7 +54,7 @@ Installation
54
54
  Add this line to your application's Gemfile:
55
55
 
56
56
  ```ruby
57
- gem 'mobility', '~> 0.4.0'
57
+ gem 'mobility', '~> 0.4.1'
58
58
  ```
59
59
 
60
60
  Mobility is cryptographically signed. To be sure the gem you install hasn't
@@ -14,10 +14,10 @@ module Mobility
14
14
 
15
15
  private
16
16
 
17
- def contains_value(key, value, locale)
18
- build_infix(:'@>',
17
+ def matches(key, value, locale)
18
+ build_infix(:'->',
19
19
  build_infix(:'->', column, quote(locale)),
20
- quote({ key => value }.to_json))
20
+ quote(key)).eq(quote(value.to_json))
21
21
  end
22
22
 
23
23
  def has_locale(key, locale)
@@ -8,7 +8,7 @@ module Mobility
8
8
 
9
9
  private
10
10
 
11
- def contains_value(key, value, locale)
11
+ def matches(key, value, locale)
12
12
  build_infix(:'->', arel_table[key], quote(locale)).eq(quote(value.to_s))
13
13
  end
14
14
  end
@@ -8,8 +8,8 @@ module Mobility
8
8
 
9
9
  private
10
10
 
11
- def contains_value(key, value, locale)
12
- build_infix(:'@>', arel_table[key], quote({locale => value }.to_json))
11
+ def matches(key, value, locale)
12
+ build_infix(:'->', arel_table[key], quote(locale)).eq(quote(value.to_json))
13
13
  end
14
14
  end
15
15
  end
@@ -4,7 +4,7 @@ module Mobility
4
4
  =begin
5
5
 
6
6
  Defines query methods for Postgres backends. Including class must define a
7
- single method, +contains_value+, which accepts a column, value and locale to
7
+ single method, +matches+, which accepts a column, value and locale to
8
8
  match, and returns an Arel node.
9
9
 
10
10
  This module avoids 99% duplication between hstore and jsonb backend querying
@@ -70,7 +70,7 @@ code.
70
70
  Array.wrap(values).map { |value|
71
71
  value.nil? ?
72
72
  has_locale(key, locale).not :
73
- contains_value(key, value, locale)
73
+ matches(key, value, locale)
74
74
  }.inject(&:or)
75
75
  }.inject(&:and)
76
76
  end
@@ -87,14 +87,14 @@ code.
87
87
  values = opts.delete(key)
88
88
 
89
89
  Array.wrap(values).map { |value|
90
- contains_value(key, value, locale).not
90
+ matches(key, value, locale).not
91
91
  }.inject(has_locale(key, locale), &:and)
92
92
  }.inject(&:and)
93
93
  end
94
94
 
95
95
  private
96
96
 
97
- def contains_value(_key, _value, _locale)
97
+ def matches(_key, _value, _locale)
98
98
  raise NotImplementedError
99
99
  end
100
100
 
@@ -25,8 +25,8 @@ module Mobility
25
25
 
26
26
  private
27
27
 
28
- def contains_value(key, value, locale)
29
- build_op(column_name)[locale].contains({ key.to_s => value }.to_json)
28
+ def matches(key, value, locale)
29
+ build_op(column_name)[locale][key.to_s] =~ value.to_json
30
30
  end
31
31
 
32
32
  def has_locale(key, locale)
@@ -23,7 +23,7 @@ module Mobility
23
23
 
24
24
  private
25
25
 
26
- def contains_value(key, value, locale)
26
+ def matches(key, value, locale)
27
27
  build_op(key).contains(locale => value.to_s)
28
28
  end
29
29
 
@@ -23,8 +23,8 @@ module Mobility
23
23
 
24
24
  private
25
25
 
26
- def contains_value(key, value, locale)
27
- build_op(key).contains({ locale => value }.to_json)
26
+ def matches(key, value, locale)
27
+ build_op(key)[locale] =~ value.to_json
28
28
  end
29
29
 
30
30
  def has_locale(key, locale)
@@ -6,14 +6,14 @@ module Mobility
6
6
  Defines query methods for Postgres backends. Including class must define two
7
7
  private methods:
8
8
 
9
- - a private method +contains_value+ which takes a key (column name), value and
9
+ - a private method +matches+ which takes a key (column name), value and
10
10
  locale and returns an SQL expression, and checks that the column has the
11
11
  specified value in the specified locale
12
12
  - a private method +has_locale+ which takes a key (column name) and locale, and
13
13
  returns an SQL expression which checks that the column has a value in the
14
14
  locale
15
15
 
16
- (The +contains_value+ method is implemented slightly differently for hstore and
16
+ (The +matches+ method is implemented slightly differently for hstore and
17
17
  jsonb columns.)
18
18
 
19
19
  =end
@@ -66,13 +66,13 @@ jsonb columns.)
66
66
  locale = Mobility.locale.to_s
67
67
 
68
68
  if invert
69
- has_locale(key, locale) & ~contains_value(key, value, locale)
69
+ has_locale(key, locale) & ~matches(key, value, locale)
70
70
  else
71
- value.nil? ? ~has_locale(key, locale) : contains_value(key, value, locale)
71
+ value.nil? ? ~has_locale(key, locale) : matches(key, value, locale)
72
72
  end
73
73
  end
74
74
 
75
- def contains_value(_key, _value, _locale)
75
+ def matches(_key, _value, _locale)
76
76
  raise NotImplementedError
77
77
  end
78
78
 
@@ -1,3 +1,3 @@
1
1
  module Mobility
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobility
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
@@ -30,7 +30,7 @@ cert_chain:
30
30
  eGDROPZoL5RXwiOnRbexxa7dcAxMrDfGB/hpiunIPWPsi4n5P7K/6OO/sGVMl9xv
31
31
  SZBPXjzrHdyOFLBYXB+PG7s3F/4=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-01-24 00:00:00.000000000 Z
33
+ date: 2018-01-29 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: request_store
metadata.gz.sig CHANGED
Binary file