dynamicloud 1.0.3 → 1.0.4

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: fc7588163f0c0c46a3236474c9548f970580694a
4
- data.tar.gz: b4c3084297f32fdea08292ed9080b008132d15b3
3
+ metadata.gz: 9bad066e296ec6b170770297df97e75683f39c91
4
+ data.tar.gz: 6523b783917632f2da2c6ccf500e1e2817e09994
5
5
  SHA512:
6
- metadata.gz: 194b8a5d045fd4022da63e7fc31eebc9197d97627023fedf6b8aef793da8b9d90952c9e20a4c4585ac76fed2c3007d60b3bf53ff36f804bafb5a023b76db8fc9
7
- data.tar.gz: d7d9585f79ceba7eff123bbd7c55fb52d2ad5b4bb6a2c0085bc333d725bc7c2c38d05f57ea2df4a793392eb12a9b13b376b1564b82170e2a2ef48437e1275dcd
6
+ metadata.gz: 33e6c218c06e6acfb7e65f1a3441689f08b0397ad451d15ac88b562ff64acea0d47301804603bbfc9e223f421d1069099ccdbd949a85398def8df025aa2000c5
7
+ data.tar.gz: 7d098f3f194a5bfc3f88339333408f09983469f5bca6574334f4d5c3e514ddf79bb31cb12e432881270ae4554e264cedcae73afae39f8e31e4a5e8d7ade9b7e1
data/lib/configuration.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  # This class maintains properties about api configuration.
2
4
  # @author Eleazar Gomez
3
5
  # @version 1.0.0
@@ -11,7 +13,7 @@ class Configuration
11
13
  # Load the current properties in config.yml.
12
14
  def initialize
13
15
  @config = {
14
- :url => 'http://api.dynamicloud.org',
16
+ :url => 'http://localhost',
15
17
  # this url must be executed using post method
16
18
  :url_get_records => '/api_models/{csk}/{aci}/get_records/{mid}/{count}/{offset}/',
17
19
  # this url must be executed using post method
@@ -40,7 +42,7 @@ class Configuration
40
42
  :url_update_selection => '/api_records/{csk}/{aci}/update_using_selection/{mid}',
41
43
  # this url must be executed using post method
42
44
  :url_delete_selection => '/api_records/{csk}/{aci}/delete_using_selection/{mid}',
43
- :version => '1.0.3'
45
+ :version => '1.0.4'
44
46
  }
45
47
  end
46
48
 
@@ -126,6 +126,105 @@ module Dynamicloud
126
126
  end
127
127
  # End of EqualCondition class
128
128
 
129
+ class BetweenCondition < Condition
130
+
131
+ # Builds an instance with a specific field whose value should be between left and right
132
+ #
133
+ # @param field field in this condition
134
+ # @param left left part of the between condition
135
+ # @param right right part of the between condition
136
+ def initialize(field, left, right)
137
+ @field = field
138
+ @left = left
139
+ @right = right
140
+ end
141
+
142
+ # This method will return a String of this condition
143
+ # @param parent this is the parent of this condition
144
+ # @return a json
145
+ def to_record_string(parent)
146
+ "\"" + @field + "\": { \"$between\": [" + (transform_left_right) + ']}'
147
+ end
148
+
149
+ private
150
+ def transform_left_right
151
+ result = (@left.is_a?(String) ? ("\"" + @left + "\"") : @left.to_s)
152
+ result += ','
153
+ result + (@right.is_a?(String) ? ("\"" + @right + "\"") : @right.to_s)
154
+ end
155
+ end
156
+ # End of BetweenCondition class
157
+
158
+ class ExistsCondition < Condition
159
+ # Builds an instance with a specific model an alias
160
+ #
161
+ # @param model_id Model ID
162
+ # @param aliass alias to this model
163
+ def initialize(model_id, aliass, not_exists)
164
+ @model_id = model_id
165
+ @aliass = aliass
166
+ @not_exists = not_exists
167
+ @conditions = []
168
+ @joins = []
169
+ end
170
+
171
+ # This method will add a new condition to this ExistsCondition.
172
+ # *
173
+ # @param condition new condition to a list of conditions to use
174
+ # @return this instance of ExistsCondition
175
+ def add(condition)
176
+ @conditions.push(condition)
177
+ self
178
+ end
179
+
180
+ # Add a join to the list of joins
181
+ #
182
+ # @param join join clause
183
+ # @return this instance of ExistsCondition
184
+ def join(join)
185
+ @joins.push(join)
186
+ self
187
+ end
188
+
189
+ # Sets the related alias to the model
190
+ #
191
+ # @param aliass related alias to the model
192
+ def set_alias(aliass)
193
+ @alias = aliass
194
+ end
195
+
196
+ # Sets the related model to this exists condition.
197
+ # With this model, you can
198
+ #
199
+ # @param model_id related model
200
+ def set_model(model_id)
201
+ @model_id = model_id
202
+ end
203
+
204
+ # This method will return a String of this condition
205
+ #
206
+ # @param parent this is the parent of this condition
207
+ # @return a json
208
+ def to_record_string(parent)
209
+ built = (@not_exists ? "\"$nexists\"" : "\"$exists\"") + ': { ' + Dynamicloud::API::DynamicloudHelper.build_join_tag(@joins) + ', ' + (@model_id.nil? ? '' : ("\"model\": " + @model_id.to_s + ', ')) + (@aliass.nil? ? '' : ("\"alias\": \"" + @aliass + "\", ")) + "\"where\": {"
210
+
211
+ if @conditions.length > 0
212
+ global = @conditions[0]
213
+ if @conditions.length > 1
214
+ @conditions = @conditions[1..@conditions.length]
215
+ @conditions.each do |condition|
216
+ global = Dynamicloud::API::Criteria::ANDCondition.new global, condition
217
+ end
218
+ end
219
+
220
+ built = built + global.to_record_string(Dynamicloud::API::Criteria::Condition::ROOT)
221
+ end
222
+
223
+ built + '}}'
224
+ end
225
+ end
226
+ # End of ExistsCondition class
227
+
129
228
  class GreaterLesser < Condition
130
229
  def initialize(left, right, greater_lesser)
131
230
  @greater_lesser = greater_lesser
@@ -369,6 +468,34 @@ module Dynamicloud
369
468
  ORCondition.new(left, right)
370
469
  end
371
470
 
471
+ # Builds a between condition
472
+ #
473
+ # @param field field in this condition
474
+ # @param left left part of the between condition
475
+ # @param right right part of the between condition
476
+ # @return a new instance of BetweenCondition
477
+ def self.between(field, left, right)
478
+ return BetweenCondition.new(field, left, right)
479
+ end
480
+
481
+ # Creates a new instance of ExistsCondition
482
+ #
483
+ # @param model_id model ID
484
+ # @param aliass alias to this model (optional)
485
+ # @return a new instance of ExistsCondition
486
+ def self.exists(model_id = nil, aliass = nil)
487
+ ExistsCondition.new(model_id, aliass, false)
488
+ end
489
+
490
+ # Creates a new instance of ExistsCondition
491
+ #
492
+ # @param model_id model ID
493
+ # @param aliass alias to this model (optional)
494
+ # @return a new instance of ExistsCondition
495
+ def self.not_exists(model_id = nil, aliass = nil)
496
+ ExistsCondition.new(model_id, aliass, true)
497
+ end
498
+
372
499
  # It will an in condition using an array of values.
373
500
  # @param left attribute to compare
374
501
  # @param values character values to build IN condition
@@ -18,25 +18,26 @@ module DynamicService
18
18
  http.connect_timeout = 10
19
19
 
20
20
  headers['User-Agent'] = 'Dynamicloud client'
21
- headers['APIVersion'] = Configuration::PROPERTIES.get_property :version
22
- headers['Language'] = 'Ruby'
21
+ headers['API_Version'] = Configuration::PROPERTIES.get_property :version
22
+ headers['Dynamicloud_API'] = 'Ruby'
23
+ headers['Accept-Encoding'] = 'gzip, deflate'
23
24
 
24
25
  # download file
25
26
  if destiny
26
- destiny.write(http.get_content(service_url))
27
+ destiny.write(http.get_content(service_url, headers))
27
28
  return
28
29
  end
29
30
 
30
31
  if method.eql? 'post'
31
- return handle_response(http.post service_url, params)
32
+ return handle_response(http.post service_url, params, headers)
32
33
  end
33
34
 
34
35
  if method.eql? 'get'
35
- return handle_response(http.get service_url, params)
36
+ return handle_response(http.get service_url, params, headers)
36
37
  end
37
38
 
38
39
  if method.eql? 'delete'
39
- return handle_response(http.delete service_url, params)
40
+ return handle_response(http.delete service_url, params, headers)
40
41
  else
41
42
  raise 'Unsupported Http Method - "' << method.to_s << '"'
42
43
  end
@@ -1,3 +1,3 @@
1
1
  module Dynamicloud
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamicloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - dynamicloud