rusql 1.0.2 → 1.0.3

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: 6ca832a09fdf83cd1c64656927c8c556aa434b95
4
- data.tar.gz: d87e61a4e1dd20c0cc6e945ca72ea1de0d1c1088
3
+ metadata.gz: 1ff1b4a10ef306cabe203f2af5da46b99e11b1f6
4
+ data.tar.gz: cece6f6999111a263632519870d48bd54f9d3a63
5
5
  SHA512:
6
- metadata.gz: 7b9101f8172c1283da78d13c712e9fdc2663f836af9841a66789e1e8e443a398f71b7c639a551aea118735bb1d76341668ac9c8f5fe77ab03ba6e3f0719f0cd0
7
- data.tar.gz: 60a2f17ea4aabdb96d789d32e7fb7c2209061098a2f76c5c7c9ef2246bcb1c6e0b179708dc769da3d3501607bd5f70c91f7879a5b29ade2e175aba8a253bd9fd
6
+ metadata.gz: dfd7287e5e4040c15ba79c2ce96d259b722b7825c3604b4dace91f95fa9c627958186571416cbd4ccf04bd36bb43efd26b4b801d2d0f02469d151acae331be46
7
+ data.tar.gz: 9ffb4d54d0cae07c5de2f8cdd67380fc46b4559a6b217cdf4ff6f0e836b9300ab83808ce32b1d140ae35eeb3e902129c1e129699e89222c34d42c6ce69cd5214
@@ -23,7 +23,7 @@ module Rusql
23
23
  end
24
24
 
25
25
  def and(condition)
26
- raise Exception.new(Condition, condition.class) unless condition.is_a?(Condition)
26
+ raise TypeException.new(Condition, condition.class) unless condition.is_a?(Condition)
27
27
 
28
28
  c = ComplexCondition.new
29
29
  c.type = :and
@@ -33,7 +33,18 @@ module Rusql
33
33
  c
34
34
  end
35
35
 
36
- def to_s(indent: " ") # to make it compatible with complex condition to_s
36
+ def or(condition)
37
+ raise TypeException.new(Condition, condition.class) unless condition.is_a?(Condition)
38
+
39
+ c = ComplexCondition.new
40
+ c.type = :or
41
+ c.add_condition(self)
42
+ c.add_condition(condition)
43
+
44
+ c
45
+ end
46
+
47
+ def to_s(indent_level: 1) # to make it compatible with complex condition to_s
37
48
  case self.type
38
49
  when :equals
39
50
  "#{left.to_s} = #{convert_value(self.right)}"
@@ -56,8 +56,10 @@ module Rusql
56
56
  new_condition
57
57
  end
58
58
 
59
- def to_s(indent: " ")
60
- self.conditions.map{ |c| c.to_s(indent: indent+" ") }.join("\n#{indent}#{self.type.to_s.upcase} ")
59
+ def to_s(indent_level: 1)
60
+ indent = " "*indent_level
61
+ indent_out = " "*(indent_level-1)
62
+ "(\n" + indent + self.conditions.map{ |c| c.to_s(indent_level: indent_level+1) }.join("\n#{indent}#{self.type.to_s.upcase} ") + "\n#{indent_out})"
61
63
  end
62
64
  end
63
65
  end
data/lib/rusql/query.rb CHANGED
@@ -113,7 +113,7 @@ module Rusql
113
113
  where_part += " "
114
114
  where_part += @condition.to_s
115
115
  elsif @condition.is_a?(ComplexCondition)
116
- where_part += "\n "
116
+ where_part += " "
117
117
  where_part += @condition.to_s
118
118
  end
119
119
 
data/lib/rusql/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rusql
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ajith Hussain
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler