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 +4 -4
- data/CHANGELOG.md +10 -1
- data/lib/appfuel/domain/entity.rb +1 -1
- data/lib/appfuel/feature/initializer.rb +4 -2
- data/lib/appfuel/storage/repository/mapper.rb +6 -10
- data/lib/appfuel/storage/repository/mapping_dsl.rb +3 -0
- data/lib/appfuel/storage/web_api/http_model.rb +26 -18
- data/lib/appfuel/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c05007c52cdadfd45cb0a021ddd43f8e2d96875a
|
4
|
+
data.tar.gz: db7c77243472aa7c6f35339a7b24fbac384fcc02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
@@ -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 =>
|
28
|
-
|
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(
|
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,
|
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,
|
170
|
-
value = resolve_entity_value(domain,
|
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,
|
195
|
-
chain =
|
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)
|
@@ -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
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
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
|
data/lib/appfuel/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2017-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|