reality-model 1.0.0 → 1.1.0

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: beecc5c47e720929fb5b7c533c1d50600e8925fb
4
- data.tar.gz: 9b08872922ff1cdcbf412dc4e5681f2aff2b6798
3
+ metadata.gz: 8fe355b83ba162dc06b6f7c193d50bf95fa568d4
4
+ data.tar.gz: 47107dc95beadc82f578bfe6475248b76fc0352f
5
5
  SHA512:
6
- metadata.gz: 20ed9a594e568ed7bb43fbecb1741f8b4d004db5d5baa3252ef9eb0884d8041e4ad5343605f63dc2a95a311dca79ad4584585f2ffa9237124291fdae43be6325
7
- data.tar.gz: edbddfbe1eb5f7dd92ec980d7424cf761fd0e86406bf38c8daaa9baafabc6d5a22e9dc9d5c9f9ee4608a55af8a53f6f3ba5381cc323b4c94065c3192c7301b79
6
+ metadata.gz: 06202bcdaa8795d589109d48e49b0d3fc1c77cb3e71b85ee9d43e4c2a518bef9692e6d6b61a50be863677fa79813b28277a9bc49f9e4f2b086ba938da40f0d68
7
+ data.tar.gz: 7cf867c73d8488815cbde92a1874a1c674d158ff8504a7c18073134d78ed113ba92a8f0a9208e2659e227e13a6ba51b2e67c97ce5f2842108bac7d59237d0778
@@ -130,6 +130,10 @@ class #{self.model_classname}
130
130
 
131
131
  public
132
132
 
133
+ def <=>(other)
134
+ self.#{self.id_method} <=> other.#{self.id_method}
135
+ end
136
+
133
137
  def options=(options)
134
138
  options.each_pair do |k, v|
135
139
  keys = k.to_s.split('.')
@@ -180,6 +184,10 @@ end
180
184
  #{child.inverse_access_method}_map.values
181
185
  end
182
186
 
187
+ def #{child.inverse_access_method}_#{Reality::Naming.pluralize(child.id_method)}
188
+ #{child.inverse_access_method}_map.keys
189
+ end
190
+
183
191
  def #{child.access_method}?
184
192
  !#{child.inverse_access_method}_map.empty?
185
193
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{reality-model}
5
- s.version = '1.0.0'
5
+ s.version = '1.1.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -0,0 +1,112 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ class Reality::Model::TestIntegration < Reality::Model::TestCase
4
+
5
+ module ResgenLogContainer
6
+ Reality::Logging.configure(ResgenLogContainer, ::Logger::WARN)
7
+ end
8
+
9
+ module ResgenFacetContainer
10
+ extend Reality::Facets::FacetContainer
11
+ end
12
+
13
+ module ResgenInstanceContainer
14
+ end
15
+
16
+ module ResgenModel
17
+ class Repository
18
+ def catalog(name, path, options = {}, &block)
19
+ Catalog.new(self, name, path, options, &block)
20
+ end
21
+ end
22
+
23
+ class Catalog
24
+ def initialize(repository, name, path, options = {}, &block)
25
+ @path = path
26
+ perform_init(repository, name, options, &block)
27
+ end
28
+
29
+ attr_reader :path
30
+ end
31
+ end
32
+
33
+ def test_create_no_defaults
34
+ Reality::Model::Repository.new(:Resgen,
35
+ ResgenModel,
36
+ :instance_container => ResgenInstanceContainer,
37
+ :facet_container => ResgenFacetContainer,
38
+ :log_container => ResgenLogContainer) do |r|
39
+ r.model_element(:repository)
40
+ r.model_element(:catalog, :repository, :custom_initialize => true)
41
+ r.model_element(:uibinder_file, :catalog, :id_method => :key)
42
+ r.model_element(:uibinder_parameter, :uibinder_file, :access_method => :parameters, :inverse_access_method => :parameter)
43
+ end
44
+
45
+ ResgenFacetContainer.facet(:gwt) do |facet|
46
+ facet.enhance(ResgenModel::Catalog) do
47
+ attr_writer :with_lookup
48
+
49
+ def with_lookup?
50
+ !!(@with_lookup ||= false)
51
+ end
52
+ end
53
+ end
54
+
55
+ assert_equal ResgenInstanceContainer.repository_names, []
56
+ assert_equal ResgenInstanceContainer.repositories, []
57
+
58
+ repository = ResgenInstanceContainer.repository(:Planner) do |r|
59
+ r.enable_facets(:gwt)
60
+ r.catalog(:PlannerCatalog, 'user-experience/src/main/resources', 'gwt.with_lookup' => true) do |c|
61
+ c.uibinder_file(:SomeCell1) do |u|
62
+ u.parameter(:ParamB)
63
+ u.parameter(:ParamA)
64
+ u.parameter(:ParamC)
65
+ end
66
+ c.uibinder_file(:SomeCell2) do |u|
67
+ u.parameter(:ParamB)
68
+ u.parameter(:ParamA)
69
+ u.parameter(:ParamC)
70
+ end
71
+ end
72
+ end
73
+
74
+ assert_equal ResgenInstanceContainer.repository_names, ['Planner']
75
+ assert_equal ResgenInstanceContainer.repositories, [repository]
76
+ assert_equal ResgenInstanceContainer.repository_by_name(:Planner), repository
77
+
78
+ assert_equal repository.gwt?, true
79
+ assert_equal repository.respond_to?(:gwt), false
80
+
81
+ assert_equal repository.catalog_names, ['PlannerCatalog']
82
+ assert_equal repository.catalogs.size, 1
83
+ assert_equal repository.catalog_by_name?('PlannerCatalog'), true
84
+
85
+ catalog = repository.catalog_by_name('PlannerCatalog')
86
+
87
+ assert_equal catalog.gwt?, true
88
+ assert_equal catalog.respond_to?(:gwt), true
89
+ assert_equal catalog.gwt.with_lookup?, true
90
+
91
+ assert_equal catalog.repository, repository
92
+ assert_equal catalog.path, 'user-experience/src/main/resources'
93
+
94
+ assert_equal catalog.uibinder_file_keys, %w(SomeCell1 SomeCell2)
95
+ assert_equal catalog.uibinder_files.size, 2
96
+ assert_equal catalog.uibinder_file_by_key?('SomeCell1'), true
97
+
98
+ uibinder_file = catalog.uibinder_file_by_key('SomeCell1')
99
+
100
+ assert_equal uibinder_file.catalog, catalog
101
+ assert_equal uibinder_file.parameter_names, %w(ParamB ParamA ParamC)
102
+ assert_equal uibinder_file.parameters.size, 3
103
+ assert_equal uibinder_file.parameter_by_name?('ParamA'), true
104
+
105
+ assert_equal uibinder_file.parameters.collect { |p| p.name }, [:ParamB, :ParamA, :ParamC]
106
+ assert_equal uibinder_file.parameters.sort.collect { |p| p.name }, [:ParamA, :ParamB, :ParamC]
107
+
108
+ parameter = uibinder_file.parameter_by_name('ParamA')
109
+
110
+ assert_equal parameter.uibinder_file, uibinder_file
111
+ end
112
+ end
@@ -137,6 +137,10 @@ class Reality::Model::TestModelElement < Reality::Model::TestCase
137
137
  component_map.values
138
138
  end
139
139
 
140
+ def component_names
141
+ component_map.keys
142
+ end
143
+
140
144
  def components?
141
145
  !component_map.empty?
142
146
  end
@@ -178,6 +182,10 @@ CODE
178
182
  component_map.values
179
183
  end
180
184
 
185
+ def component_names
186
+ component_map.keys
187
+ end
188
+
181
189
  def components?
182
190
  !component_map.empty?
183
191
  end
@@ -217,6 +225,10 @@ class Bundle
217
225
 
218
226
  public
219
227
 
228
+ def <=>(other)
229
+ self.name <=> other.name
230
+ end
231
+
220
232
  def options=(options)
221
233
  options.each_pair do |k, v|
222
234
  keys = k.to_s.split('.')
@@ -260,6 +272,10 @@ class Bundle
260
272
 
261
273
  public
262
274
 
275
+ def <=>(other)
276
+ self.name <=> other.name
277
+ end
278
+
263
279
  def options=(options)
264
280
  options.each_pair do |k, v|
265
281
  keys = k.to_s.split('.')
@@ -300,6 +316,10 @@ class Bundle
300
316
 
301
317
  public
302
318
 
319
+ def <=>(other)
320
+ self.name <=> other.name
321
+ end
322
+
303
323
  def options=(options)
304
324
  options.each_pair do |k, v|
305
325
  keys = k.to_s.split('.')
@@ -344,6 +364,10 @@ class Bundle
344
364
 
345
365
  public
346
366
 
367
+ def <=>(other)
368
+ self.name <=> other.name
369
+ end
370
+
347
371
  def options=(options)
348
372
  options.each_pair do |k, v|
349
373
  keys = k.to_s.split('.')
@@ -403,6 +427,10 @@ class Project
403
427
  bundle_map.values
404
428
  end
405
429
 
430
+ def bundle_names
431
+ bundle_map.keys
432
+ end
433
+
406
434
  def bundles?
407
435
  !bundle_map.empty?
408
436
  end
@@ -420,6 +448,10 @@ class Project
420
448
 
421
449
  public
422
450
 
451
+ def <=>(other)
452
+ self.name <=> other.name
453
+ end
454
+
423
455
  def options=(options)
424
456
  options.each_pair do |k, v|
425
457
  keys = k.to_s.split('.')
@@ -459,13 +491,16 @@ CODE
459
491
  assert_equal true, ResgenContainer.const_defined?(:Project)
460
492
  assert_equal true, ResgenContainer.const_defined?(:Bundle)
461
493
 
494
+ assert_true ResgenContainer::Project.instance_methods.include?(:<=>)
462
495
  assert_true ResgenContainer::Project.instance_methods.include?(:name)
463
496
  assert_true ResgenContainer::Project.instance_methods.include?(:bundles)
497
+ assert_true ResgenContainer::Project.instance_methods.include?(:bundle_names)
464
498
  assert_true ResgenContainer::Project.instance_methods.include?(:bundle_by_name)
465
499
  assert_true ResgenContainer::Project.instance_methods.include?(:bundle_by_name?)
466
500
  assert_true ResgenContainer::Project.instance_methods.include?(:bundle)
467
501
  assert_false ResgenContainer::Project.instance_methods.include?(:perform_init)
468
502
 
503
+ assert_true ResgenContainer::Bundle.instance_methods.include?(:<=>)
469
504
  assert_true ResgenContainer::Bundle.instance_methods.include?(:project)
470
505
  assert_true ResgenContainer::Bundle.instance_methods.include?(:name)
471
506
  assert_false ResgenContainer::Bundle.instance_methods.include?(:perform_init)
@@ -495,9 +530,11 @@ CODE
495
530
  assert_equal ResgenContainer2::Prj, model1.model
496
531
  assert_equal ResgenContainer2::Bundle, model2.model
497
532
 
533
+ assert_true ResgenContainer2::Prj.instance_methods.include?(:<=>)
498
534
  assert_true ResgenContainer2::Prj.instance_methods.include?(:key)
499
535
  assert_false ResgenContainer2::Prj.instance_methods.include?(:name)
500
536
  assert_true ResgenContainer2::Prj.instance_methods.include?(:bnds)
537
+ assert_true ResgenContainer2::Prj.instance_methods.include?(:bnd_keys)
501
538
  assert_true ResgenContainer2::Prj.instance_methods.include?(:bnd_by_key)
502
539
  assert_true ResgenContainer2::Prj.instance_methods.include?(:bnd_by_key?)
503
540
 
@@ -505,6 +542,7 @@ CODE
505
542
  assert_false ResgenContainer2::Prj.instance_methods.include?(:bundle)
506
543
  assert_false ResgenContainer2::Prj.instance_methods.include?(:bnd)
507
544
 
545
+ assert_true ResgenContainer2::Bundle.instance_methods.include?(:<=>)
508
546
  assert_true ResgenContainer2::Bundle.instance_methods.include?(:prj)
509
547
  assert_true ResgenContainer2::Bundle.instance_methods.include?(:key)
510
548
  assert_false ResgenContainer2::Bundle.instance_methods.include?(:name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reality-model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald
@@ -115,6 +115,7 @@ files:
115
115
  - lib/reality/model/repository.rb
116
116
  - reality-model.gemspec
117
117
  - test/helper.rb
118
+ - test/test_integration.rb
118
119
  - test/test_model_element.rb
119
120
  - test/test_repository.rb
120
121
  homepage: https://github.com/realityforge/reality-model