set_builder 1.2.0.beta2 → 1.2.0.beta3

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: ad5a691ebe74c5868f2b6bd1ed58b6bfc1e3d5c3
4
- data.tar.gz: 98ad1930d226f419016b39588013352fb50ffc80
3
+ metadata.gz: b72932fe9a27cb708e417d352685eb5a2737c702
4
+ data.tar.gz: 56c5cd7d3731616a8647e927a43d81e0a076b94c
5
5
  SHA512:
6
- metadata.gz: 50f80ac7bf9a588b0f60c1ac5a5836462b37aedebe25fb97b1509241cd8ba352cd9a463ad41af411b9fb405ee6531be5a42b579f6490d5590f1370490dc1f122
7
- data.tar.gz: 5df7956306cc4a5063e0550ea78d20aa636b898f19557e4d455876b9af631aa7caeebc0e59ac6c54d0964a6ffe38862a09b6ccc22f680f313e70ac9117c41cbf
6
+ metadata.gz: 7d2fdb5e59c579e37246537c3313cc60deb1344b3eed5793d741a769388c3529f6ac2e9fbeb8a49e03e6695c816375b24489f0f0debac7c1b86866129b30ff9e
7
+ data.tar.gz: 226cb56332e3daab5df7ce0f5c4089f1bd3608bccdaa9c2dde55c69e90d2c1ab35983355f0381d081305db741b70b04d967034c2016fe9e77059b8944b414cc7
@@ -1,6 +1,6 @@
1
1
  # .travis.yml
2
2
  language: ruby
3
3
  rvm:
4
- - 2.0.0
4
+ - 2.1.2
5
5
  script:
6
6
  - bundle exec rake test
@@ -33,6 +33,17 @@ var SetBuilder = (function() {
33
33
  return _value_maps[key];
34
34
  },
35
35
  getValue: function(key, value) {
36
+ if(Object.prototype.toString.call(value) == '[object Array]') {
37
+ var getValue = arguments.callee;
38
+ var values = value.__collect(function(value) { return getValue(key, value) });
39
+ switch(values.length) {
40
+ case 0: return '';
41
+ case 1: return values[0];
42
+ case 2: return values[0] + ' or ' + values[1];
43
+ default: return values.slice(0, -1).join(', ') + ', or ' + values[values.length - 1];
44
+ }
45
+ }
46
+
36
47
  var match = value.toString(),
37
48
  map = SetBuilder.getValueMap(key);
38
49
  if(map) {
@@ -41,8 +52,6 @@ var SetBuilder = (function() {
41
52
  } else {
42
53
  return value;
43
54
  }
44
- // map = _value_maps[key];
45
- // return map ? map[value.toString()] : value;
46
55
  },
47
56
  getValueMaps: function() {
48
57
  return Object.keys(_value_maps);
@@ -14,6 +14,10 @@ module SetBuilder
14
14
 
15
15
  attr_reader :operator, :values
16
16
 
17
+ def value
18
+ values[0]
19
+ end
20
+
17
21
 
18
22
 
19
23
  def valid?
@@ -64,10 +64,7 @@ module SetBuilder
64
64
  when :in_the_last
65
65
  selector.gteq(get_date)
66
66
  when :between
67
- selector.between(
68
- Date.parse(values[0]),
69
- Date.parse(values[1])
70
- )
67
+ selector.in(Date.parse(values[0])..Date.parse(values[1]))
71
68
  end
72
69
  end
73
70
 
@@ -21,11 +21,11 @@ module SetBuilder
21
21
  def build_conditions_for(selector)
22
22
  case operator
23
23
  when :is
24
- ["#{selector}=?", format_value]
24
+ ["#{selector}=?", value]
25
25
  when :is_less_than
26
- ["#{selector}<?", format_value]
26
+ ["#{selector}<?", value]
27
27
  when :is_greater_than
28
- ["#{selector}>?", format_value]
28
+ ["#{selector}>?", value]
29
29
  when :is_between
30
30
  ["#{selector}>=? AND #{selector}<=?", values[0], values[1]]
31
31
  end
@@ -48,20 +48,6 @@ module SetBuilder
48
48
 
49
49
 
50
50
 
51
- private
52
-
53
-
54
-
55
- def value
56
- values[0]
57
- end
58
-
59
- def format_value
60
- value
61
- end
62
-
63
-
64
-
65
51
  end
66
52
  end
67
53
  end
@@ -15,10 +15,19 @@ module SetBuilder
15
15
 
16
16
 
17
17
  def self.to_s(name, value)
18
+ if value.is_a?(Array)
19
+ values = value.map { |value| self.send(__method__, name, value) }
20
+ return case value.length
21
+ when 0; ""
22
+ when 1; values.first
23
+ when 2; "#{values.first} or #{values.last}"
24
+ else; "#{values[0..-2].join(', ')}, or #{values.last}"
25
+ end
26
+ end
18
27
  name = name.to_sym
19
- map = @registered_value_maps[name]
28
+ map = @registered_value_maps[name]
20
29
  if map
21
- pair = map.find {|pair| pair[0] == value}
30
+ pair = map.find { |pair| pair[0] == value || pair[0] == value.to_s }
22
31
  pair ? pair[1].to_s : "(unknown)"
23
32
  else
24
33
  value.to_s
@@ -59,4 +68,4 @@ module SetBuilder
59
68
 
60
69
 
61
70
 
62
- end
71
+ end
@@ -1,3 +1,3 @@
1
1
  module SetBuilder
2
- VERSION = "1.2.0.beta2"
2
+ VERSION = "1.2.0.beta3"
3
3
  end
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "rails"
22
- spec.add_dependency "arel"
21
+ spec.add_dependency "rails", ">= 3.1", "< 5.0"
22
+ spec.add_dependency "arel", "~> 5.0"
23
23
  spec.add_development_dependency "bundler", "~> 1.3"
24
24
  spec.add_development_dependency "rake"
25
- spec.add_development_dependency "turn"
26
25
  spec.add_development_dependency "pry"
27
26
  end
@@ -2,7 +2,6 @@ require "rubygems"
2
2
  require "rails"
3
3
  require "rails/test_help"
4
4
  require "active_support/core_ext"
5
- require "turn"
6
5
  require "set_builder"
7
6
  require "pry"
8
7
  require "support/fake_connection"
metadata CHANGED
@@ -1,97 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: set_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0.beta2
4
+ version: 1.2.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bob Lail
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: arel
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - '>='
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: '5.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - '>='
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: '5.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: bundler
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - ~>
51
+ - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '1.3'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ~>
58
+ - - "~>"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.3'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: turn
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
65
+ - - ">="
74
66
  - !ruby/object:Gem::Version
75
67
  version: '0'
76
68
  type: :development
77
69
  prerelease: false
78
70
  version_requirements: !ruby/object:Gem::Requirement
79
71
  requirements:
80
- - - '>='
72
+ - - ">="
81
73
  - !ruby/object:Gem::Version
82
74
  version: '0'
83
75
  - !ruby/object:Gem::Dependency
84
76
  name: pry
85
77
  requirement: !ruby/object:Gem::Requirement
86
78
  requirements:
87
- - - '>='
79
+ - - ">="
88
80
  - !ruby/object:Gem::Version
89
81
  version: '0'
90
82
  type: :development
91
83
  prerelease: false
92
84
  version_requirements: !ruby/object:Gem::Requirement
93
85
  requirements:
94
- - - '>='
86
+ - - ">="
95
87
  - !ruby/object:Gem::Version
96
88
  version: '0'
97
89
  description: A gem for describing constraints on data sets
@@ -101,8 +93,8 @@ executables: []
101
93
  extensions: []
102
94
  extra_rdoc_files: []
103
95
  files:
104
- - .gitignore
105
- - .travis.yml
96
+ - ".gitignore"
97
+ - ".travis.yml"
106
98
  - Gemfile
107
99
  - MIT-LICENSE
108
100
  - README.md
@@ -173,17 +165,17 @@ require_paths:
173
165
  - lib
174
166
  required_ruby_version: !ruby/object:Gem::Requirement
175
167
  requirements:
176
- - - '>='
168
+ - - ">="
177
169
  - !ruby/object:Gem::Version
178
170
  version: '0'
179
171
  required_rubygems_version: !ruby/object:Gem::Requirement
180
172
  requirements:
181
- - - '>'
173
+ - - ">"
182
174
  - !ruby/object:Gem::Version
183
175
  version: 1.3.1
184
176
  requirements: []
185
177
  rubyforge_project:
186
- rubygems_version: 2.2.1
178
+ rubygems_version: 2.2.2
187
179
  signing_key:
188
180
  specification_version: 4
189
181
  summary: Define traits on a model, create sets that constrain those traits, and generate