appfuel 0.5.6 → 0.5.7

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: 9b872574eb5144fa78c7334c325d1329308c97ea
4
- data.tar.gz: dbdaa30f3fc8dbea57efe547a1c32d84cf869ff3
3
+ metadata.gz: c05007c52cdadfd45cb0a021ddd43f8e2d96875a
4
+ data.tar.gz: db7c77243472aa7c6f35339a7b24fbac384fcc02
5
5
  SHA512:
6
- metadata.gz: d588321d6a7c4ce57573ed3e60d9aaa6bfc474fde2abaccc191ccc90dda1698c18d211ec2a777aa9cf5728bf93fedbb6d4bdc9eaa321c797b4fdd0feea592ed7
7
- data.tar.gz: 598e3156b838624e479879370fbde73c2127cdd0d49fddf2673773fb8f89c778be7e842026e1e6c0b20506b37441da096e18ddd844d8d82c34075de19fc42b89
6
+ metadata.gz: b7764d6b15834ddae5d2e2916cdb50a313b98cf6d2d03d9965589e721e6a5335649def32835a6360cf674db9cc79bcdd5b1dba97b526741a81a9de43bf0ff7f8
7
+ data.tar.gz: c5bcdc614ee39ab5964a979d6d4fd5bde21cba7295f39c28e361d0f043e4a905021df23eef4b7de90ecbe8e13a16fd54e438e3e92d6a6dcf36925573a51656e5
data/CHANGELOG.md CHANGED
@@ -5,7 +5,16 @@ All notable changes to this project will be documented in this file. (Pending ap
5
5
 
6
6
 
7
7
  # Releases
8
- ## [[0.5.6]] (https://github.com/rsb/appfuel/releases/tag/0.5.5) 2017-07-11
8
+ ## [[0.5.7]] (https://github.com/rsb/appfuel/releases/tag/0.5.7) 2017-07-18
9
+ ### Changed
10
+ - domain entity `attr_typed!` will always converts the type name to a symbol
11
+
12
+ ### Fixed
13
+ - web_api http model handles exceptions
14
+ - fixed `entity_value` in repo mapper it had an old interface
15
+ - mapping_dsl was missing `skip` property
16
+
17
+ ## [[0.5.6]] (https://github.com/rsb/appfuel/releases/tag/0.5.6) 2017-07-11
9
18
  ### Fixed
10
19
  - Fixed registering classes in the feature initializer, it now skips when
11
20
  already registered
@@ -65,7 +65,7 @@ module Appfuel
65
65
  end
66
66
 
67
67
  def attr_typed!(name, value)
68
- self.class.schema[name][value]
68
+ self.class.schema[name.to_sym][value]
69
69
  end
70
70
 
71
71
  def data_typed!(type_name, value)
@@ -24,8 +24,10 @@ module Appfuel
24
24
  feature_path = "#{container[:features_path]}/#{name}"
25
25
  begin
26
26
  require feature_path
27
- rescue LoadError => _e
28
- raise "[#{feature_key} initialize] could not load #{feature_path}"
27
+ rescue LoadError => e
28
+ trace = e.backtrace.join("\n")
29
+ raise "[#{feature_key} initialize] could not load " +
30
+ "#{feature_path}: #{e.message} #{trace}"
29
31
  end
30
32
  end
31
33
 
@@ -137,10 +137,10 @@ module Appfuel
137
137
  excluded = opts[:exclude] || []
138
138
  data = {}
139
139
  domain_name = domain.domain_name
140
- map.each_attr(domain_name, type) do |domain_attr, storage_attr, skip|
140
+ map.each_attr(type, domain_name) do |domain_attr, storage_attr, skip|
141
141
  next if excluded.include?(storage_attr) || skip == true
142
142
 
143
- data[storage_attr] = entity_value(domain, entry)
143
+ data[storage_attr] = entity_value(domain, domain_attr)
144
144
  end
145
145
 
146
146
  data
@@ -166,12 +166,8 @@ module Appfuel
166
166
  end
167
167
  end
168
168
 
169
- def entity_value(domain, map_entry)
170
- value = resolve_entity_value(domain, map_entry.domain_attr)
171
- if map_entry.computed_attr?
172
- value = map_entry.computed_attr(value, domain)
173
- end
174
-
169
+ def entity_value(domain, domain_attr)
170
+ value = resolve_entity_value(domain, domain_attr)
175
171
  value = nil if undefined?(value)
176
172
 
177
173
  value
@@ -191,8 +187,8 @@ module Appfuel
191
187
  value == Types::Undefined
192
188
  end
193
189
 
194
- def resolve_entity_value(domain, entity_attr)
195
- chain = entity_attr.split('.')
190
+ def resolve_entity_value(domain, domain_attr)
191
+ chain = domain_attr.split('.')
196
192
  target = domain
197
193
  chain.each do |attr_method|
198
194
  return nil unless target.respond_to?(attr_method)
@@ -54,9 +54,12 @@ module Appfuel
54
54
 
55
55
  domain_attr = name if domain_attr.nil?
56
56
 
57
+ skip = opts[:skip] == true ? true : false
58
+
57
59
  data = opts.merge({
58
60
  domain_attr: domain_attr,
59
61
  storage_attr: name,
62
+ skip: skip
60
63
  })
61
64
 
62
65
  entries << data
@@ -25,18 +25,6 @@ module Appfuel
25
25
  end
26
26
 
27
27
  def load_http_adapter
28
- container = app_container
29
- if container.key?('web_api.http_adapter')
30
- container['web_api.http_adapter']
31
- else
32
- load_default_http_adapter
33
- end
34
- end
35
-
36
- def load_default_http_adapter
37
- unless Kernel.const_defined?(:RestClient)
38
- require 'rest-client'
39
- end
40
28
  RestClient
41
29
  end
42
30
 
@@ -63,20 +51,40 @@ module Appfuel
63
51
  def request(method, path, options = {})
64
52
  add_content_type(options)
65
53
  http_url = url(path)
54
+ if options[:relative_url] === false
55
+ http_url = path
56
+ options.delete(:relative_url)
57
+ end
58
+
66
59
  begin
67
60
  data = options.merge({method: method, url: http_url })
68
61
  response = adapter::Request.execute(data)
69
- parse_json = options.delete(:json)
70
- if parse_json == true
71
- response = json(response.body)
72
- end
73
- rescue => err
74
- raise err.exception("[#{http_url}] #{err.message}")
62
+ response = handle_response(response, options[:headers])
63
+ rescue RestClient::ExceptionWithResponse => err
64
+ data = handle_response(err.response, options[:headers])
65
+ handle_http_error(err.http_code, data, http_url, err.message)
75
66
  end
76
67
 
77
68
  response
78
69
  end
79
70
 
71
+
72
+ def handle_http_error(code, body, url, msg)
73
+ if body.is_a?(Hash)
74
+ body = body.map{|k,v| "#{k}: #{v}"}.join('&')
75
+ end
76
+ str = "[#{url} #{code}] #{msg} #{body}"
77
+ raise str
78
+ end
79
+
80
+ def handle_response(response, headers = {})
81
+ if content_type == :json || headers[:content_type] == :json
82
+ return json(response.body)
83
+ end
84
+
85
+ response.body
86
+ end
87
+
80
88
  def json(data)
81
89
  JSON.parse(data)
82
90
  end
@@ -1,3 +1,3 @@
1
1
  module Appfuel
2
- VERSION = "0.5.6"
2
+ VERSION = "0.5.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appfuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Scott-Buccleuch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord