praxis-blueprints 2.1 → 2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c0621988651c28b2a7067510da6b334b3bb788fd
|
|
4
|
+
data.tar.gz: f89f81316cb31874e7353cf86b85e5f29552112e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a9d0c616bb141113114edadd7aa8446ad686da969bb0bb7f4b018b5999a7190cb8f8f570b003503728849841dfbee17be1c5bd21a14e50cd9a1e147e58724f82
|
|
7
|
+
data.tar.gz: e5c20f1b9577216b1a480cabfbf1fcb0941391f3937b0096ce0f1e7c11212e6eba64e60aad6b3be0b4403a6f6584a4ba83d561c53bc3591d6e017d0e1deff60c
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
## next
|
|
4
4
|
|
|
5
|
+
## 2.2
|
|
6
|
+
|
|
7
|
+
* Added instrumentation through `ActiveSupport::Notifications`
|
|
8
|
+
* Use the 'praxis.blueprint.render to subscribe to `Blueprint#render` calls
|
|
9
|
+
|
|
5
10
|
|
|
6
11
|
## 2.1
|
|
7
12
|
|
|
@@ -9,7 +14,7 @@
|
|
|
9
14
|
* Bumped attributor dependnecy to >= 4.0.1
|
|
10
15
|
|
|
11
16
|
|
|
12
|
-
## 2.0.1
|
|
17
|
+
## 2.0.1
|
|
13
18
|
|
|
14
19
|
* relaxed attributor dependency to >= 3.0
|
|
15
20
|
|
|
@@ -300,7 +300,7 @@ module Praxis
|
|
|
300
300
|
raise "view with name '#{view_name.inspect}' is not defined in #{self.class}"
|
|
301
301
|
end
|
|
302
302
|
|
|
303
|
-
rendered_key = if fields = opts[:fields]
|
|
303
|
+
rendered_key = if (fields = opts[:fields])
|
|
304
304
|
if fields.is_a? Array
|
|
305
305
|
# Accept a simple array of fields, and transform it to a 1-level hash with nil values
|
|
306
306
|
opts[:fields] = opts[:fields].each_with_object({}) {|field, hash| hash[field] = nil }
|
|
@@ -315,7 +315,15 @@ module Praxis
|
|
|
315
315
|
return CIRCULAR_REFERENCE_MARKER if @active_renders.include?(rendered_key)
|
|
316
316
|
@active_renders << rendered_key
|
|
317
317
|
|
|
318
|
-
|
|
318
|
+
notification_payload = {
|
|
319
|
+
blueprint: self,
|
|
320
|
+
view: view,
|
|
321
|
+
fields: fields
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
ActiveSupport::Notifications.instrument 'praxis.blueprint.render'.freeze, notification_payload do
|
|
325
|
+
@rendered_views[rendered_key] = view.dump(self, context: context,**opts)
|
|
326
|
+
end
|
|
319
327
|
ensure
|
|
320
328
|
@active_renders.delete rendered_key
|
|
321
329
|
end
|
|
@@ -29,7 +29,6 @@ module Praxis
|
|
|
29
29
|
@contents
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
def dump(object, context: Attributor::DEFAULT_ROOT_CONTEXT,**opts)
|
|
34
33
|
fields = opts[:fields]
|
|
35
34
|
# Restrict which attributes to output if we receive a fields parameter
|
|
@@ -92,7 +91,6 @@ module Praxis
|
|
|
92
91
|
|
|
93
92
|
end
|
|
94
93
|
|
|
95
|
-
|
|
96
94
|
def example(context=nil)
|
|
97
95
|
object = self.schema.example(context)
|
|
98
96
|
opts = {}
|
|
@@ -114,7 +112,7 @@ module Praxis
|
|
|
114
112
|
end
|
|
115
113
|
|
|
116
114
|
private
|
|
117
|
-
def add_subfield_options(
|
|
115
|
+
def add_subfield_options(fields, name, existing_options)
|
|
118
116
|
sub_opts = if fields && fields[name]
|
|
119
117
|
{fields: fields[name] }
|
|
120
118
|
else
|
|
@@ -101,6 +101,19 @@ describe Praxis::Blueprint do
|
|
|
101
101
|
it 'has the right values' do
|
|
102
102
|
subject[:name].should eq(expected_name)
|
|
103
103
|
end
|
|
104
|
+
|
|
105
|
+
it 'sends the correct ActiveSupport::Notification' do
|
|
106
|
+
notification_payload = {
|
|
107
|
+
blueprint: blueprint_instance,
|
|
108
|
+
view: blueprint_class.views[:name_only],
|
|
109
|
+
fields: nil
|
|
110
|
+
}
|
|
111
|
+
ActiveSupport::Notifications.should_receive(:instrument).
|
|
112
|
+
with('praxis.blueprint.render',notification_payload).
|
|
113
|
+
and_call_original
|
|
114
|
+
|
|
115
|
+
blueprint_instance.render(view: :name_only)
|
|
116
|
+
end
|
|
104
117
|
end
|
|
105
118
|
|
|
106
119
|
context 'validation' do
|
|
@@ -217,7 +230,7 @@ describe Praxis::Blueprint do
|
|
|
217
230
|
end
|
|
218
231
|
end
|
|
219
232
|
end
|
|
220
|
-
|
|
233
|
+
|
|
221
234
|
context '.validate' do
|
|
222
235
|
let(:hash) { {name: 'bob'} }
|
|
223
236
|
let(:person) { Person.load(hash) }
|
|
@@ -34,6 +34,9 @@ class Person < Praxis::Blueprint
|
|
|
34
34
|
attribute :address
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
view :name_only do
|
|
38
|
+
attribute :name
|
|
39
|
+
end
|
|
37
40
|
|
|
38
41
|
view :extended do
|
|
39
42
|
attribute :name
|
|
@@ -76,7 +79,7 @@ end
|
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
class FullName < Attributor::Model
|
|
79
|
-
|
|
82
|
+
|
|
80
83
|
attributes do
|
|
81
84
|
attribute :first, String, example: /[:first_name:]/
|
|
82
85
|
attribute :last, String, example: /[:last_name:]/
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: praxis-blueprints
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '2.
|
|
4
|
+
version: '2.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep M. Blanquer
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2015-
|
|
12
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: randexp
|
|
@@ -259,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
259
259
|
version: '0'
|
|
260
260
|
requirements: []
|
|
261
261
|
rubyforge_project:
|
|
262
|
-
rubygems_version: 2.
|
|
262
|
+
rubygems_version: 2.4.5.1
|
|
263
263
|
signing_key:
|
|
264
264
|
specification_version: 4
|
|
265
265
|
summary: Attributes, views, rendering and example generation for common Blueprint
|