sunstone 1.0.0 → 1.1.0

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: c22d4667778ecfe53034454215950b7c93c82dac
4
- data.tar.gz: fab3525c04c36627f5df0788ab9357fe5b020135
3
+ metadata.gz: 567a0950650c172c56b5c8d23061ff04efe5ecc2
4
+ data.tar.gz: 95cd7fcc96e4aaefb0ce439548fb2e5eb9d2aff1
5
5
  SHA512:
6
- metadata.gz: 0758fa4348af24daae4be0a7217385e7e648dd8ff8790521a12411559b3b0f15892028eb6c2398b85e67546b40fc1c9c2edfa3a93d6bb2b07f920411e11cb17f
7
- data.tar.gz: ef3c3385aa3502ce96e787e53b653cb8b9901fc9dcd11b756c9098e24ad3e3d2ea30abb8017913df15d6bcffc4b527d96f8185d4eb0d63415539193bbc510221
6
+ metadata.gz: 82626c3c9861b180c9021eb845d2988e467a7564e0f9f5c040e202eb6ff996670d777f7f636924b8f2dc1d4738600b03381d2495c769e8a8288db534a8feccd8
7
+ data.tar.gz: fd7e2ec407a4f2ae055a710613c3e1ae35d486679d2299bfe29f3a661e13396f687d597e8eecec056a42b418bf8138a02f0454a7a97f0f6c7b9e93b9c8a99ad4
@@ -2,7 +2,7 @@ module Arel
2
2
  module Collectors
3
3
  class Sunstone < Arel::Collectors::Bind
4
4
 
5
- attr_accessor :request_type, :table, :where, :limit, :offset, :order, :operation, :columns
5
+ attr_accessor :request_type, :table, :where, :limit, :offset, :order, :operation, :columns, :updates
6
6
 
7
7
  def substitute_binds hash, bvs
8
8
  if hash.is_a?(Array)
@@ -36,7 +36,7 @@ module Arel
36
36
  end
37
37
  end
38
38
 
39
- def compile bvs
39
+ def compile bvs, conn = nil
40
40
  path = "/#{table}"
41
41
 
42
42
  case operation
@@ -63,6 +63,9 @@ module Arel
63
63
  end
64
64
 
65
65
  request = request_type.new(path)
66
+ if updates
67
+ request.body = {table.singularize => substitute_binds(updates.clone, bvs)}.to_json
68
+ end
66
69
 
67
70
  request
68
71
  end
@@ -64,6 +64,19 @@ module Arel
64
64
 
65
65
  collector
66
66
  end
67
+
68
+ def visit_Arel_Nodes_InsertStatement o, collector
69
+ collector.request_type = Net::HTTP::Post
70
+ collector.table = o.relation.name
71
+ collector.operation = :insert
72
+
73
+ if o.values
74
+ collector.updates = o.values.right.map { |x| visit(x, collector) }.zip(o.values.left).to_h
75
+ end
76
+
77
+ collector
78
+ end
79
+
67
80
 
68
81
 
69
82
  #
@@ -114,23 +127,6 @@ module Arel
114
127
  # collector
115
128
  # end
116
129
  #
117
- # def visit_Arel_Nodes_InsertStatement o, collector
118
- # collector << "INSERT INTO "
119
- # collector = visit o.relation, collector
120
- # if o.columns.any?
121
- # collector << " (#{o.columns.map { |x|
122
- # quote_column_name x.name
123
- # }.join ', '})"
124
- # end
125
- #
126
- # if o.values
127
- # maybe_visit o.values, collector
128
- # elsif o.select
129
- # maybe_visit o.select, collector
130
- # else
131
- # collector
132
- # end
133
- # end
134
130
  #
135
131
  # def visit_Arel_Nodes_Exists o, collector
136
132
  # collector << "EXISTS ("
@@ -179,7 +175,6 @@ module Arel
179
175
  # end
180
176
  #
181
177
  # def visit_Arel_Nodes_Values o, collector
182
- # collector << "VALUES ("
183
178
  #
184
179
  # len = o.expressions.length - 1
185
180
  # o.expressions.zip(o.columns).each_with_index { |(value, attr), i|
@@ -193,11 +188,9 @@ module Arel
193
188
  # end
194
189
  # }
195
190
  #
196
- # collector << ")"
197
191
  # end
198
192
  #
199
-
200
-
193
+ #
201
194
  #
202
195
  # def visit_Arel_Nodes_Bin o, collector
203
196
  # visit o.expr, collector
@@ -425,9 +418,6 @@ module Arel
425
418
  end
426
419
 
427
420
  def visit_Arel_Nodes_Avg o, collector
428
- # puts o.inspect
429
- # #<Arel::Nodes::Avg:0x007fd863f55df0 @expressions=["rate_per_sqft_per_year"], @alias="avg_id", @distinct=false>
430
-
431
421
  collector.operation = :average
432
422
  if o.expressions.first.is_a?(Arel::Attributes::Attribute)
433
423
  relation = o.expressions.first.relation
@@ -115,7 +115,7 @@ module Sunstone
115
115
  if response['X-42Floors-API-Version-Deprecated']
116
116
  logger.warn("DEPRECATION WARNING: API v#{API_VERSION} is being phased out")
117
117
  end
118
-
118
+
119
119
  validate_response_code(response)
120
120
 
121
121
  # Get the cookies
@@ -132,6 +132,7 @@ module Sunstone
132
132
  end
133
133
  end
134
134
 
135
+
135
136
 
136
137
  return_value
137
138
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "sunstone"
3
- s.version = '1.0.0'
3
+ s.version = '1.1.0'
4
4
  s.authors = ["Jon Bracy"]
5
5
  s.email = ["jonbracy@gmail.com"]
6
6
  s.homepage = "http://sunstonerb.com"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunstone
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-08 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake