visual_condition_builder 0.1.0 → 0.1.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: 178da1aa116065c99dc12ee94a452dc9e458f198
4
- data.tar.gz: 133d796fd6b683c0eef3c776afa246d7ec7dc9bc
3
+ metadata.gz: 21b282ae1f76851c3fa269f704e7bce918948b35
4
+ data.tar.gz: ff210a4140a81bb4c3d4da3b3a24df682b0c172f
5
5
  SHA512:
6
- metadata.gz: 85dec3cf9eb10c147f90d280ca0eb52f83adbdb108a91090836b6f7d181d1c031c76a2a9fc13976a819a8dc1ac4f59562bc167c70bd217f844a7327e75171036
7
- data.tar.gz: 4a30c06b5e8564b4a7150d581d15b3c8e1593ccdabdb3a34072fa1b00d9de93e9aa89e344916ca3917601aac142fc505f73de01fa4b36cd067cf142ac33b9cd8
6
+ metadata.gz: e74f401deb7f39c547daa37b2fe48a61a3ec8d839fa9fb6b81686ed0efe014b9d4d37533b6bd44206db5a4eb28682685c37b6e2e0e8517a59a4b1ff6bb12c9eb
7
+ data.tar.gz: 4bbfa1aa0b1ea8033d832710443037963250a6eb70c86ffd0c2b993586adfe818f9dd421a97b56fde09beb7d33f79098197c0b0a19ab10d62e2deee2000f5e6d
data/README.md CHANGED
@@ -1,5 +1,4 @@
1
1
  # Search Builder
2
- [![Code Climate](https://codeclimate.com/github/brunoporto/visual_condition_builder/badges/gpa.svg)](https://codeclimate.com/github/brunoporto/visual_condition_builder)
3
2
 
4
3
  A great and easy search builder to your rails project
5
4
 
@@ -27,9 +27,9 @@ en:
27
27
  not_start: 'not starts with'
28
28
  end: 'ends with'
29
29
  not_end: 'not ends with'
30
- true: 'is true'
30
+ "true": 'is true'
31
31
  not_true: 'not is true'
32
- false: 'is false'
32
+ "false": 'is false'
33
33
  not_false: 'not is false'
34
34
  present: 'is present '
35
35
  blank: 'is blank'
@@ -50,11 +50,15 @@ module VisualConditionBuilder
50
50
  if args[:values].present? && args[:values].is_a?(Proc)
51
51
  args[:values] = args[:values].call
52
52
  end
53
+ if normalized_name(args[:type])==:boolean && args[:label] !~ /\?$/
54
+ args[:label]+='?'
55
+ end
56
+
53
57
  self.dictionaries[@dictionary_name] << args
54
58
  end
55
59
 
56
60
  def operators_by_type(type)
57
- type = type.present? ? type.to_s.downcase.to_sym : 'string'
61
+ type = type.present? ? normalized_name(type) : 'string'
58
62
  operators = case type
59
63
  when :date, :datetime
60
64
  [:eq, :between, :today, :yesterday, :tomorrow, :this_week, :last_week, :next_week, :present, :blank]
@@ -62,6 +66,8 @@ module VisualConditionBuilder
62
66
  [:eq, :between, :present, :blank]
63
67
  when :decimal, :integer
64
68
  [:eq, :between]
69
+ when :boolean
70
+ [:true, :false, :present, :blank]
65
71
  when :string
66
72
  [:cont, :eq, :start, :end, :present, :blank]
67
73
  else
@@ -133,7 +139,7 @@ module VisualConditionBuilder
133
139
  not_null: {no_value: true, multiple: false},
134
140
  }
135
141
  if op.present?
136
- (operators[operator_name(op)] || {})
142
+ (operators[normalized_name(op)] || {})
137
143
  else
138
144
  operators
139
145
  end
@@ -141,7 +147,7 @@ module VisualConditionBuilder
141
147
 
142
148
  def operator_default(op)
143
149
  op_default = operators_list(op)
144
- operator = {operator: operator_name(op)}
150
+ operator = {operator: normalized_name(op)}
145
151
  operator.deep_merge!(op_default) if op_default.present?
146
152
  operator
147
153
  end
@@ -159,7 +165,7 @@ module VisualConditionBuilder
159
165
  array.reduce Hash.new, :merge
160
166
  end
161
167
 
162
- def operator_name(op)
168
+ def normalized_name(op)
163
169
  op.to_s.downcase.to_sym
164
170
  end
165
171
  end
@@ -1,3 +1,3 @@
1
1
  module VisualConditionBuilder
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_condition_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bruno Porto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2016-11-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A great and easy visual condition builder to your rails project
14
14
  email: