mobility 0.4.1 → 0.4.2

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: 5b4475c1c4828150f79f535dd8974561e2d5b819
4
- data.tar.gz: 03ce38c5557fb60468f07b3eae5b8f797625c798
3
+ metadata.gz: 940b49f8c3a48cc006aa2a981627065adcc7a645
4
+ data.tar.gz: 75aef5224d15662c0297f5bf0665d496d08c2118
5
5
  SHA512:
6
- metadata.gz: 2a19d72816a4c76d79a6e46a7d5a5f3eb63e6620a38a0bd29f1cc0dd7ed2361dbae12b3678afde7277d29397d8de1aed4788d99718edbea5139b0c3b0899a754
7
- data.tar.gz: d9d15056bd2bfdc5238e5bb4003ae3352df6581175abd6d899546064bda8e1f41f3377124ea5309df78715fdb4d3e6262624ccdccf9c8203d94e84c3a19f86d3
6
+ metadata.gz: a4e0c11a3349d6761afe95d858a9c85887ddb442713076a6f064ab59bcb6e957646bbaac68c3b0d8b9715e54af5dca03b1332cc55d06defaa62e8406e5a11778
7
+ data.tar.gz: cff9fff5d014f38c90a81ade0ce87f8d007c02dcfd7090a61c73e0472c939c95fe05048256b7d09a3676a8cd9648d618db0a2ba14abc3ab723cbeb5d9b8040b3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -2,8 +2,12 @@
2
2
 
3
3
  ## 0.4
4
4
 
5
+ ### 0.4.2 (January 29, 2018)
6
+ * Refactor find_by for translated attributes
7
+ ([#160](https://github.com/shioyama/mobility/pull/160))
8
+
5
9
  ### 0.4.1 (January 29, 2018)
6
- * Use element operator instead of contains for jsonb query8ing
10
+ * Use element operator instead of contains for jsonb querying
7
11
  ([#159](https://github.com/shioyama/mobility/pull/159))
8
12
 
9
13
  ### 0.4.0 (January 24, 2018)
@@ -1,52 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mobility (0.4.0)
4
+ mobility (0.4.1)
5
5
  i18n (>= 0.6.10, < 0.10)
6
6
  request_store (~> 1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (5.2.0.beta2)
12
- actionview (= 5.2.0.beta2)
13
- activesupport (= 5.2.0.beta2)
14
- rack (~> 2.0)
15
- rack-test (>= 0.6.3)
16
- rails-dom-testing (~> 2.0)
17
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
18
- actionview (5.2.0.beta2)
19
- activesupport (= 5.2.0.beta2)
20
- builder (~> 3.1)
21
- erubi (~> 1.4)
22
- rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
24
- activemodel (5.2.0.beta2)
25
- activesupport (= 5.2.0.beta2)
26
- activerecord (5.2.0.beta2)
27
- activemodel (= 5.2.0.beta2)
28
- activesupport (= 5.2.0.beta2)
29
- arel (>= 9.0)
30
- activesupport (5.2.0.beta2)
31
- concurrent-ruby (~> 1.0, >= 1.0.2)
32
- i18n (~> 0.7)
33
- minitest (~> 5.1)
34
- tzinfo (~> 1.1)
35
- arel (9.0.0)
36
11
  benchmark-ips (2.7.2)
37
- builder (3.2.3)
38
12
  byebug (9.1.0)
39
13
  coderay (1.1.2)
40
14
  concurrent-ruby (1.0.5)
41
- crass (1.0.3)
42
15
  database_cleaner (1.6.2)
43
16
  diff-lcs (1.3)
44
- erubi (1.7.0)
45
17
  ffi (1.9.18)
46
18
  formatador (0.2.5)
47
- generator_spec (0.9.4)
48
- activesupport (>= 3.0.0)
49
- railties (>= 3.0.0)
50
19
  guard (2.14.2)
51
20
  formatador (>= 0.2.4)
52
21
  listen (>= 2.7, < 4.0)
@@ -67,17 +36,10 @@ GEM
67
36
  rb-fsevent (~> 0.9, >= 0.9.4)
68
37
  rb-inotify (~> 0.9, >= 0.9.7)
69
38
  ruby_dep (~> 1.2)
70
- loofah (2.1.1)
71
- crass (~> 1.0.2)
72
- nokogiri (>= 1.5.9)
73
39
  lumberjack (1.0.12)
74
40
  method_source (0.9.0)
75
- mini_portile2 (2.3.0)
76
- minitest (5.11.3)
77
41
  mysql2 (0.4.10)
78
42
  nenv (0.3.0)
79
- nokogiri (1.8.1)
80
- mini_portile2 (~> 2.3.0)
81
43
  notiffany (0.1.1)
82
44
  nenv (~> 0.1)
83
45
  shellany (~> 0.0)
@@ -89,19 +51,6 @@ GEM
89
51
  byebug (~> 9.1)
90
52
  pry (~> 0.10)
91
53
  rack (2.0.3)
92
- rack-test (0.8.2)
93
- rack (>= 1.0, < 3)
94
- rails-dom-testing (2.0.3)
95
- activesupport (>= 4.2.0)
96
- nokogiri (>= 1.6)
97
- rails-html-sanitizer (1.0.3)
98
- loofah (~> 2.0)
99
- railties (5.2.0.beta2)
100
- actionpack (= 5.2.0.beta2)
101
- activesupport (= 5.2.0.beta2)
102
- method_source
103
- rake (>= 0.8.7)
104
- thor (>= 0.18.1, < 2.0)
105
54
  rake (12.3.0)
106
55
  rb-fsevent (0.10.2)
107
56
  rb-inotify (0.9.10)
@@ -122,31 +71,27 @@ GEM
122
71
  rspec-support (~> 3.7.0)
123
72
  rspec-support (3.7.0)
124
73
  ruby_dep (1.5.0)
74
+ sequel (5.4.0)
125
75
  shellany (0.0.1)
126
76
  sqlite3 (1.3.13)
127
77
  thor (0.20.0)
128
- thread_safe (0.3.6)
129
- tzinfo (1.2.4)
130
- thread_safe (~> 0.1)
131
78
  yard (0.9.12)
132
79
 
133
80
  PLATFORMS
134
81
  ruby
135
82
 
136
83
  DEPENDENCIES
137
- activerecord (>= 5.2.0.beta1, < 5.3)
138
84
  benchmark-ips
139
85
  bundler (~> 1.12)
140
86
  database_cleaner (~> 1.5, >= 1.5.3)
141
- generator_spec (~> 0.9.4)
142
87
  guard-rspec
143
88
  mobility!
144
89
  mysql2 (~> 0.4.9)
145
90
  pg (< 1.0)
146
91
  pry-byebug
147
- railties (>= 5.2.0.beta1, < 5.3)
148
92
  rake (~> 12, >= 12.2.1)
149
93
  rspec (~> 3.0)
94
+ sequel (>= 5.0.0, < 6.0.0)
150
95
  sqlite3
151
96
  yard (~> 0.9.0)
152
97
 
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.1'
57
+ gem 'mobility', '~> 0.4.2'
58
58
  ```
59
59
 
60
60
  Mobility is cryptographically signed. To be sure the gem you install hasn't
@@ -10,12 +10,6 @@ module Mobility
10
10
  define_method :where! do |opts, *rest|
11
11
  super(q.convert_opts(opts), *rest)
12
12
  end
13
-
14
- attributes.each do |attribute|
15
- define_method :"find_by_#{attribute}" do |value|
16
- find_by(Column.column_name_for(attribute) => value)
17
- end
18
- end
19
13
  end
20
14
 
21
15
  def extended(relation)
@@ -9,12 +9,6 @@ module Mobility
9
9
 
10
10
  define_join_method(association_name, class_name)
11
11
  define_query_methods(association_name)
12
-
13
- attributes.each do |attribute|
14
- define_method :"find_by_#{attribute}" do |value|
15
- find_by(attribute.to_sym => value)
16
- end
17
- end
18
12
  end
19
13
 
20
14
  def extended(relation)
@@ -11,6 +11,12 @@ models. For details see backend-specific subclasses.
11
11
  # @param [Array<String>] attributes Translated attributes
12
12
  def initialize(attributes, _)
13
13
  @attributes = attributes
14
+
15
+ attributes.each do |attribute|
16
+ define_method :"find_by_#{attribute}" do |value|
17
+ find_by(attribute.to_sym => value)
18
+ end
19
+ end
14
20
  end
15
21
 
16
22
  # @param [ActiveRecord::Relation] relation Relation being extended
@@ -11,12 +11,6 @@ module Mobility
11
11
 
12
12
  define_join_method(association_name, translation_class, **options)
13
13
  define_query_methods(association_name, translation_class, **options)
14
-
15
- attributes.each do |attribute|
16
- define_method :"find_by_#{attribute}" do |value|
17
- find_by(attribute.to_sym => value)
18
- end
19
- end
20
14
  end
21
15
 
22
16
  def extended(relation)
@@ -18,12 +18,6 @@ module Mobility
18
18
  end
19
19
  end
20
20
  end
21
-
22
- attributes.each do |attribute|
23
- define_method :"first_by_#{attribute}" do |value|
24
- where(attribute.to_sym => value).first
25
- end
26
- end
27
21
  end
28
22
  end
29
23
  end
@@ -11,16 +11,8 @@ module Mobility
11
11
 
12
12
  def initialize(attributes, options)
13
13
  super
14
- column_name = @column_name = options[:column_name]
15
-
14
+ @column_name = options[:column_name]
16
15
  define_query_methods
17
-
18
- attributes.each do |attribute|
19
- define_method :"first_by_#{attribute}" do |value|
20
- where(::Sequel.pg_jsonb_op(column_name)[Mobility.locale.to_s].contains({ attribute => value })).
21
- select_all(model.table_name).first
22
- end
23
- end
24
16
  end
25
17
 
26
18
  private
@@ -8,23 +8,10 @@ module Mobility
8
8
  class Sequel::Hstore::QueryMethods < Sequel::QueryMethods
9
9
  include Sequel::PgQueryMethods
10
10
 
11
- def initialize(attributes, _)
12
- super
13
-
14
- define_query_methods
15
-
16
- attributes.each do |attribute|
17
- define_method :"first_by_#{attribute}" do |value|
18
- where(::Sequel.hstore(attribute.to_sym).contains(::Sequel.hstore({ Mobility.locale.to_s => value }))).
19
- select_all(model.table_name).first
20
- end
21
- end
22
- end
23
-
24
11
  private
25
12
 
26
13
  def matches(key, value, locale)
27
- build_op(key).contains(locale => value.to_s)
14
+ build_op(key)[locale] =~ value.to_s
28
15
  end
29
16
 
30
17
  def has_locale(key, locale)
@@ -8,19 +8,6 @@ module Mobility
8
8
  class Sequel::Jsonb::QueryMethods < Sequel::QueryMethods
9
9
  include Sequel::PgQueryMethods
10
10
 
11
- def initialize(attributes, _)
12
- super
13
-
14
- define_query_methods
15
-
16
- attributes.each do |attribute|
17
- define_method :"first_by_#{attribute}" do |value|
18
- where(::Sequel.pg_jsonb_op(attribute).contains({ Mobility.locale => value })).
19
- select_all(model.table_name).first
20
- end
21
- end
22
- end
23
-
24
11
  private
25
12
 
26
13
  def matches(key, value, locale)
@@ -8,12 +8,6 @@ module Mobility
8
8
 
9
9
  define_join_method(association_name, class_name)
10
10
  define_query_methods(association_name)
11
-
12
- attributes.each do |attribute|
13
- define_method :"first_by_#{attribute}" do |value|
14
- where(attribute => value).select_all(model.table_name).first
15
- end
16
- end
17
11
  end
18
12
 
19
13
  private
@@ -18,6 +18,10 @@ jsonb columns.)
18
18
 
19
19
  =end
20
20
  module PgQueryMethods
21
+ def initialize(attributes, _)
22
+ super
23
+ define_query_methods
24
+ end
21
25
 
22
26
  # Create query for conditions and translated keys
23
27
  # @note This is a destructive action, it will alter +cond+.
@@ -13,6 +13,12 @@ models. For details see backend-specific subclasses.
13
13
  # @param [Array<String>] attributes Translated attributes
14
14
  def initialize(attributes, _)
15
15
  @attributes = attributes.map!(&:to_sym)
16
+
17
+ attributes.each do |attribute|
18
+ define_method :"first_by_#{attribute}" do |value|
19
+ where(attribute.to_sym => value).select_all(model.table_name).first
20
+ end
21
+ end
16
22
  end
17
23
 
18
24
  def extract_attributes(cond)
@@ -9,12 +9,6 @@ module Mobility
9
9
 
10
10
  define_join_method(association_name, translation_class, **options)
11
11
  define_query_methods(association_name, translation_class, **options)
12
-
13
- attributes.each do |attribute|
14
- define_method :"first_by_#{attribute}" do |value|
15
- where(attribute => value).select_all(model.table_name).first
16
- end
17
- end
18
12
  end
19
13
 
20
14
  def define_join_method(association_name, translation_class, table_name: nil, foreign_key: nil, **)
@@ -1,3 +1,3 @@
1
1
  module Mobility
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
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.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Salzberg
metadata.gz.sig CHANGED
Binary file