logical_model 0.2.21 → 0.2.22

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.21
1
+ 0.2.22
data/lib/logical_model.rb CHANGED
@@ -18,7 +18,7 @@ require 'safe_log'
18
18
  # api_key_name: api key parameter name. eg: app_key
19
19
  # api_key: api_key. eg: "asd32fa4s4pdf35tr"
20
20
  # log_path: Path to log file. Will be ignored if using Rails.
21
- # json_root: TODO doc
21
+ # json_root: Used to build parameters. Default: class name underscored
22
22
  #
23
23
  # You may use validations such as validates_presence_of, etc.
24
24
  #
@@ -204,7 +204,7 @@ class LogicalModel
204
204
  end
205
205
 
206
206
  def self.log_ok(response)
207
- self.logger.info("LogicalModel Log: #{response.code} #{mask_api_key(response.request.url)} in #{response.time}s")
207
+ self.logger.info("LogicalModel Log: #{response.code} #{mask_api_key(response.effective_url)} in #{response.time}s")
208
208
  self.logger.debug("LogicalModel Log RESPONSE: #{response.body}")
209
209
  end
210
210
 
@@ -218,7 +218,7 @@ class LogicalModel
218
218
  rescue => e
219
219
  error_message = "error"
220
220
  end
221
- msg = "LogicalModel Log: #{response.code} #{mask_api_key(response.request.url)} in #{response.time}s FAILED: #{error_message}"
221
+ msg = "LogicalModel Log: #{response.code} #{mask_api_key(response.effective_url)} in #{response.time}s FAILED: #{error_message}"
222
222
  self.logger.warn(msg)
223
223
  self.logger.debug("LogicalModel Log RESPONSE: #{response.body}")
224
224
  end
@@ -445,9 +445,9 @@ class LogicalModel
445
445
  params = self.class.merge_key(params)
446
446
 
447
447
  response = nil
448
- #Timeout::timeout(self.class.timeout/1000) do
449
- response = Typhoeus::Request.post( self.class.resource_uri, :params => params, :timeout => self.class.timeout )
450
- #end
448
+ Timeout::timeout(self.class.timeout/1000) do
449
+ response = Typhoeus::Request.post( self.class.resource_uri, :body => params, :timeout => self.class.timeout )
450
+ end
451
451
  if response.code == 201
452
452
  log_ok(response)
453
453
  self.id = ActiveSupport::JSON.decode(response.body)["id"]
@@ -484,26 +484,18 @@ class LogicalModel
484
484
 
485
485
  params = self.class.merge_key(attribute_params)
486
486
 
487
- e = Typhoeus::Easy.new
488
-
489
- e.url = self.class.resource_uri(_id)
490
- e.method = :put
491
- e.params = params
492
-
493
487
  response = nil
494
488
  Timeout::timeout(self.class.timeout/1000) do
495
- # using Typhoeus::Easy avoids PUT hang issue: https://github.com/dbalatero/typhoeus/issues/69
496
- e.perform
489
+ response = Typhoeus::Request.put( self.class.resource_uri(id),
490
+ :params => params,
491
+ :timeout => self.class.timeout )
497
492
  end
498
493
 
499
- if e.response_code == 200
500
- self.class.logger.info("LogicalModel Log: #{e.response_code} #{e.url} in #{e.total_time_taken}s")
501
- self.class.logger.debug("LogicalModel Log RESPONSE: #{e.response_body}")
494
+ if response.code == 200
495
+ log_ok(response)
502
496
  return self
503
497
  else
504
- msg = "LogicalModel Log: #{e.response_code} #{e.url} in #{e.total_time_taken}s FAILED"
505
- self.class.logger.warn(msg)
506
- self.class.logger.debug("LogicalModel Log RESPONSE: #{e.response_body}")
498
+ log_failed(response)
507
499
  return nil
508
500
  end
509
501
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "logical_model"
8
- s.version = "0.2.21"
8
+ s.version = "0.2.22"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dwayne Macgowan"]
12
- s.date = "2012-08-19"
12
+ s.date = "2012-08-21"
13
13
  s.description = "LogicalModel allows to use a resource as a model. It is based on web presentation http://www.slideshare.net/ihower/serviceoriented-design-and-implement-with-rails3"
14
14
  s.email = "dwaynemac@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logical_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-19 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
@@ -329,7 +329,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
329
329
  version: '0'
330
330
  segments:
331
331
  - 0
332
- hash: -777852493
332
+ hash: 415513441
333
333
  required_rubygems_version: !ruby/object:Gem::Requirement
334
334
  none: false
335
335
  requirements: