praxis-blueprints 3.2 → 3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -0
- data/.travis.yml +5 -3
- data/CHANGELOG.md +6 -0
- data/Gemfile +1 -0
- data/Guardfile +13 -7
- data/Rakefile +4 -3
- data/lib/praxis-blueprints.rb +2 -1
- data/lib/praxis-blueprints/blueprint.rb +68 -89
- data/lib/praxis-blueprints/collection_view.rb +8 -11
- data/lib/praxis-blueprints/config_hash.rb +15 -12
- data/lib/praxis-blueprints/field_expander.rb +46 -52
- data/lib/praxis-blueprints/finalizable.rb +4 -8
- data/lib/praxis-blueprints/renderer.rb +29 -27
- data/lib/praxis-blueprints/version.rb +2 -1
- data/lib/praxis-blueprints/view.rb +23 -28
- data/praxis-blueprints.gemspec +35 -25
- data/spec/praxis-blueprints/blueprint_spec.rb +33 -57
- data/spec/praxis-blueprints/collection_view_spec.rb +6 -10
- data/spec/praxis-blueprints/config_hash_spec.rb +64 -0
- data/spec/praxis-blueprints/field_expander_spec.rb +30 -38
- data/spec/praxis-blueprints/renderer_spec.rb +57 -50
- data/spec/praxis-blueprints/view_spec.rb +8 -12
- data/spec/spec_helper.rb +11 -14
- data/spec/support/spec_blueprints.rb +6 -14
- metadata +44 -8
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'coveralls'
|
2
3
|
Coveralls.wear!
|
3
4
|
|
@@ -7,37 +8,33 @@ require 'rubygems'
|
|
7
8
|
require 'bundler/setup'
|
8
9
|
|
9
10
|
# Configure simplecov gem (must be here at top of file)
|
10
|
-
#require 'simplecov'
|
11
|
-
#SimpleCov.start do
|
11
|
+
# require 'simplecov'
|
12
|
+
# SimpleCov.start do
|
12
13
|
# add_filter 'spec' # Don't include RSpec stuff
|
13
|
-
#end
|
14
|
+
# end
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
# $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
17
|
+
# $LOAD_PATH.unshift(File.dirname(__FILE__))
|
17
18
|
$LOAD_PATH.unshift 'lib'
|
18
19
|
|
19
20
|
Bundler.setup(:default, :development, :test)
|
20
21
|
Bundler.require(:default, :development, :test)
|
21
22
|
|
22
|
-
|
23
23
|
require 'praxis-blueprints'
|
24
24
|
|
25
25
|
require_relative 'support/spec_blueprints'
|
26
26
|
|
27
|
-
|
28
27
|
RSpec.configure do |config|
|
29
28
|
config.backtrace_exclusion_patterns = [
|
30
|
-
|
31
|
-
/
|
29
|
+
%r{/lib/\d*/ruby/},
|
30
|
+
%r{bin/},
|
32
31
|
/gems/,
|
33
|
-
/
|
34
|
-
/
|
35
|
-
/
|
32
|
+
%r{spec/spec_helper.rb},
|
33
|
+
%r{lib/rspec/(core|expectations|matchers|mocks)},
|
34
|
+
%r{org/jruby/.*.java}
|
36
35
|
]
|
37
36
|
|
38
37
|
config.before(:suite) do
|
39
38
|
Praxis::Blueprint.finalize!
|
40
39
|
end
|
41
|
-
|
42
|
-
|
43
40
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Person < Praxis::Blueprint
|
2
3
|
attributes do
|
3
4
|
attribute :name, String, example: /[:first_name:]/
|
@@ -58,24 +59,21 @@ class Person < Praxis::Blueprint
|
|
58
59
|
attribute :address
|
59
60
|
attribute :alive
|
60
61
|
end
|
61
|
-
|
62
62
|
end
|
63
63
|
|
64
|
-
|
65
|
-
class Address < Praxis::Blueprint
|
64
|
+
class Address < Praxis::Blueprint
|
66
65
|
attributes do
|
67
66
|
attribute :id, Integer
|
68
67
|
attribute :name, String
|
69
68
|
attribute :street, String
|
70
|
-
attribute :state, String, values: %w
|
69
|
+
attribute :state, String, values: %w(OR CA)
|
71
70
|
|
72
|
-
attribute :resident, Person, example: proc { |address,context| Person.example(context, address: address) }
|
71
|
+
attribute :resident, Person, example: proc { |address, context| Person.example(context, address: address) }
|
73
72
|
end
|
74
73
|
|
75
74
|
view :default do
|
76
75
|
attribute :street
|
77
76
|
attribute :state
|
78
|
-
|
79
77
|
end
|
80
78
|
|
81
79
|
view :circular do
|
@@ -90,28 +88,22 @@ class Address < Praxis::Blueprint
|
|
90
88
|
attribute :street
|
91
89
|
attribute :resident
|
92
90
|
end
|
93
|
-
|
94
91
|
end
|
95
92
|
|
96
|
-
|
97
93
|
class FullName < Attributor::Model
|
98
|
-
|
99
94
|
attributes do
|
100
95
|
attribute :first, String, example: /[:first_name:]/
|
101
96
|
attribute :last, String, example: /[:last_name:]/
|
102
97
|
end
|
103
|
-
|
104
98
|
end
|
105
99
|
|
106
|
-
|
107
|
-
class SimpleHash < Attributor::Model
|
100
|
+
class SimpleHash < Attributor::Model
|
108
101
|
attributes do
|
109
102
|
attribute :id, Integer
|
110
|
-
attribute :hash,
|
103
|
+
attribute :hash, Hash
|
111
104
|
end
|
112
105
|
end
|
113
106
|
|
114
|
-
|
115
107
|
class SimpleHashCollection < Attributor::Model
|
116
108
|
attributes do
|
117
109
|
attribute :id, Integer
|
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: '3.
|
4
|
+
version: '3.3'
|
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: 2016-
|
12
|
+
date: 2016-08-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: randexp
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 5.
|
34
|
+
version: '5.1'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 5.
|
41
|
+
version: '5.1'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: activesupport
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,9 +221,42 @@ dependencies:
|
|
221
221
|
- - ">="
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
|
-
|
225
|
-
|
226
|
-
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: rubocop
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
type: :development
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
238
|
+
- !ruby/object:Gem::Dependency
|
239
|
+
name: guard-rubocop
|
240
|
+
requirement: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - ">="
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
type: :development
|
246
|
+
prerelease: false
|
247
|
+
version_requirements: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
description: |2
|
253
|
+
Praxis Blueprints is a library that allows for defining a reusable class
|
254
|
+
structures that has a set of typed attributes and a set of views with which
|
255
|
+
to render them. Instantiations of Blueprints resemble ruby Structs which
|
256
|
+
respond to methods of the attribute names. Rendering is format-agnostic in
|
257
|
+
that it results in a structured hash instead of an encoded string.
|
258
|
+
Blueprints can automatically generate object structures that follow the
|
259
|
+
attribute definitions.
|
227
260
|
email:
|
228
261
|
- blanquer@gmail.com
|
229
262
|
- dane.jensen@gmail.com
|
@@ -233,6 +266,7 @@ extra_rdoc_files: []
|
|
233
266
|
files:
|
234
267
|
- ".gitignore"
|
235
268
|
- ".rspec"
|
269
|
+
- ".rubocop.yml"
|
236
270
|
- ".travis.yml"
|
237
271
|
- CHANGELOG.md
|
238
272
|
- Gemfile
|
@@ -252,6 +286,7 @@ files:
|
|
252
286
|
- praxis-blueprints.gemspec
|
253
287
|
- spec/praxis-blueprints/blueprint_spec.rb
|
254
288
|
- spec/praxis-blueprints/collection_view_spec.rb
|
289
|
+
- spec/praxis-blueprints/config_hash_spec.rb
|
255
290
|
- spec/praxis-blueprints/field_expander_spec.rb
|
256
291
|
- spec/praxis-blueprints/renderer_spec.rb
|
257
292
|
- spec/praxis-blueprints/view_spec.rb
|
@@ -277,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
312
|
version: '0'
|
278
313
|
requirements: []
|
279
314
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
315
|
+
rubygems_version: 2.5.1
|
281
316
|
signing_key:
|
282
317
|
specification_version: 4
|
283
318
|
summary: Attributes, views, rendering and example generation for common Blueprint
|
@@ -285,6 +320,7 @@ summary: Attributes, views, rendering and example generation for common Blueprin
|
|
285
320
|
test_files:
|
286
321
|
- spec/praxis-blueprints/blueprint_spec.rb
|
287
322
|
- spec/praxis-blueprints/collection_view_spec.rb
|
323
|
+
- spec/praxis-blueprints/config_hash_spec.rb
|
288
324
|
- spec/praxis-blueprints/field_expander_spec.rb
|
289
325
|
- spec/praxis-blueprints/renderer_spec.rb
|
290
326
|
- spec/praxis-blueprints/view_spec.rb
|