foobara 0.0.2 → 0.0.4

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
  SHA256:
3
- metadata.gz: 782f9f751e5ade5abc8f593f9f3fb6afe456df2d2a5636554652432ff44722e5
4
- data.tar.gz: ce77c639a1a7e5f9c79833610655e65ee6ed5e8051ce77c19ca43bbb58c748eb
3
+ metadata.gz: 467a360223436ef05ee0657bdcfbe8b6f8e855fe13a5af8f16d1fc9ef5d3b8e1
4
+ data.tar.gz: 3dcf54e84bd89483b9130d3c6093e1e14908c284904032fdb1c3011c7ca02dfb
5
5
  SHA512:
6
- metadata.gz: dfce0e9aec6e7b6212ee1bc236e8bca42fba3a380ddce7a2fe75db012f738c3ad13d41a9f8d98438d18252ba92f3a87b90cdb5087d5cfc19006672d6d519db6f
7
- data.tar.gz: b2221f7c2920cb7f5978f5ead9e3655a47fe464d6a738445f111e619736d6212f56d97e066d90000934878844c2a6b3937b58366eb086990987fc367b58d1649
6
+ metadata.gz: b58b221f4cfbc3407bcf2098049f9a00e8cc50b9ba97f03ac0c7f50e7e851f44096f98183a5d1e1805559df2ed10cabbc731002eec3ce5bd492db97656fa167e
7
+ data.tar.gz: 813912a5fe4b4aed472f4cf4dc51724e650595b128c422bacb7f6592ab08e319b9d8977b3474df048833f4a5847d037cef6013d498bfe722507e1e313221f361
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [0.0.4] - 2024-08-19
2
+
3
+ - Render element type for Array types in Http::Help
4
+
5
+ ## [0.0.3] - 2024-08-15
6
+
7
+ - Do not automatically try to map subcommand types to calling command result type
8
+ - Add some crude help info for models in http connector
9
+
1
10
  ## [0.0.2] - 2024-06-20
2
11
 
3
12
  - Make sure content-type is json if we are json serializing an HTTP response
@@ -4,22 +4,35 @@ module Foobara
4
4
  module DomainMappers
5
5
  include Concern
6
6
 
7
- def run_mapped_subcommand!(subcommand_class, unmapped_inputs)
7
+ def run_mapped_subcommand!(subcommand_class, *args)
8
+ unmapped_inputs, has_result_type, result_type =
9
+ case args.size
10
+ when 1
11
+ [args.first]
12
+ when 2
13
+ [args[1], true, args[0]]
14
+ else
15
+ # :nocov:
16
+ raise ArgumentError,
17
+ "Wrong number of arguments: (#{args.size}. Expected 2 or 3 argument."
18
+ # :nocov:
19
+ end
20
+
8
21
  inputs = domain_map!(unmapped_inputs, to: subcommand_class, strict: true)
9
22
 
10
23
  result = run_subcommand!(subcommand_class, inputs)
11
24
 
12
- result_mapper = self.class.domain.foobara_domain_mapper_registry.lookup(
13
- from: result,
14
- to: result_type,
15
- strict: true
16
- )
25
+ if has_result_type
26
+ result_mapper = self.class.domain.foobara_domain_mapper_registry.lookup!(
27
+ from: result,
28
+ to: result_type,
29
+ strict: true
30
+ )
17
31
 
18
- if result_mapper
19
- result_mapper.map(result)
20
- else
21
- result
32
+ result = result_mapper.map(result)
22
33
  end
34
+
35
+ result
23
36
  end
24
37
 
25
38
  def domain_map(...)
@@ -103,6 +103,22 @@ module Foobara
103
103
  html << "</li>"
104
104
  end
105
105
  html << "</ul>" unless skip_wrapper
106
+ when Manifest::Array
107
+ html << "<ul>" unless skip_wrapper
108
+ data.relevant_manifest.each_pair do |key, value|
109
+ next if key == :element_type_declaration
110
+
111
+ if key.to_s == "type"
112
+ value = root_manifest.lookup_path(key, value)
113
+ end
114
+ html << "<li>#{key}"
115
+ html << "<ul>"
116
+ html << render_html_list(value, skip_wrapper: true)
117
+ html << "</ul>"
118
+ html << "</li>"
119
+ end
120
+ html << render_html_list({ element_type: data.element_type }, skip_wrapper: true)
121
+ html << "</ul>" unless skip_wrapper
106
122
  when Manifest::TypeDeclaration
107
123
  html << "<ul>" unless skip_wrapper
108
124
  data.relevant_manifest.each_pair do |key, value|
@@ -1 +1,11 @@
1
- <%= full_type_name %>
1
+ <h1><%= full_entity_name %></h1>
2
+ <p><%= description %></p>
3
+
4
+ <h2>Attributes</h2>
5
+ <%= render_html_list(attributes_type) %>
6
+
7
+ <h2>Primary Key</h2>
8
+ <%= primary_key_attribute %>
9
+
10
+ <h2>Possible Errors</h2>
11
+ <%= render_html_list(possible_errors) %>
@@ -1 +1,8 @@
1
- <%= full_type_name %>
1
+ <h1><%= full_model_name %></h1>
2
+ <p><%= description %></p>
3
+
4
+ <h2>Attributes</h2>
5
+ <%= render_html_list(attributes_type) %>
6
+
7
+ <h2>Possible Errors</h2>
8
+ <%= render_html_list(possible_errors) %>
@@ -1,5 +1,30 @@
1
1
  module Foobara
2
2
  class DomainMapper
3
+ class NoDomainMapperFoundError < StandardError
4
+ attr_accessor :value, :from, :to, :has_value
5
+
6
+ def initialize(from, to, **opts)
7
+ valid_keys = [:value]
8
+ invalid_keys = opts.keys - [:value]
9
+
10
+ if invalid_keys.any?
11
+ # :nocov:
12
+ raise ArgumentError, "Invalid keys: #{invalid_keys.join(", ")}. expected one of: #{valid_keys.join(", ")}"
13
+ # :nocov:
14
+ end
15
+
16
+ if opts.key?(:value)
17
+ self.has_value = true
18
+ self.value = opts[:value]
19
+ end
20
+
21
+ self.from = from
22
+ self.to = to
23
+
24
+ super("No domain mapper found for #{value}. from: #{from}. to: #{to}.")
25
+ end
26
+ end
27
+
3
28
  class Registry
4
29
  class AmbiguousDomainMapperError < StandardError
5
30
  attr_accessor :candidates, :from, :to
@@ -17,6 +42,12 @@ module Foobara
17
42
  mappers << mapper
18
43
  end
19
44
 
45
+ def lookup!(from: nil, to: nil, strict: false)
46
+ result = lookup(from:, to:, strict:)
47
+
48
+ result || raise(NoDomainMapperFoundError.new(from, to))
49
+ end
50
+
20
51
  def lookup(from: nil, to: nil, strict: false)
21
52
  candidates = mappers.select do |mapper|
22
53
  mapper.applicable?(from, to)
@@ -4,18 +4,6 @@ module Foobara
4
4
  class AlreadyRegisteredError < StandardError; end
5
5
  class CannotSetTypeConstantError < StandardError; end
6
6
 
7
- class NoDomainMapperFoundError < StandardError
8
- attr_accessor :value, :from, :to
9
-
10
- def initialize(value, from, to)
11
- self.value = value
12
- self.from = from
13
- self.to = to
14
-
15
- super("No domain mapper found for #{value}. from: #{from}. to: #{to}.")
16
- end
17
- end
18
-
19
7
  class << self
20
8
  def global
21
9
  GlobalDomain
@@ -165,9 +153,8 @@ module Foobara
165
153
 
166
154
  def foobara_domain_map!(value, from: value, to: nil, strict: false)
167
155
  mapper = foobara_domain_mapper_registry.lookup(from:, to:, strict:)
168
-
169
156
  unless mapper
170
- raise NoDomainMapperFoundError.new(value, from, to)
157
+ raise Foobara::DomainMapper::NoDomainMapperFoundError.new(from, to, value:)
171
158
  end
172
159
 
173
160
  mapper.call(value)
@@ -8,9 +8,6 @@ module Foobara
8
8
  end
9
9
 
10
10
  module Monorepo
11
- # universal
12
- project "version"
13
-
14
11
  # could be independent projects
15
12
  projects "delegate",
16
13
  "concerns",
@@ -25,6 +25,10 @@ module Foobara
25
25
  super - [primary_key_name]
26
26
  end
27
27
 
28
+ def full_entity_name
29
+ full_model_name
30
+ end
31
+
28
32
  def associations
29
33
  @associations ||= self[:associations].to_h do |path_key, type_name|
30
34
  [path_key.to_sym, Type.new(root_manifest, [:type, type_name])]
@@ -15,6 +15,10 @@ module Foobara
15
15
  attributes_type.attribute_names
16
16
  end
17
17
 
18
+ def full_model_name
19
+ scoped_full_name
20
+ end
21
+
18
22
  # TODO: rename
19
23
  def has_associations?(type = attributes_type)
20
24
  case type
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-21 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foobara-util
@@ -378,8 +378,6 @@ files:
378
378
  - projects/value/src/processor/selection.rb
379
379
  - projects/value/src/transformer.rb
380
380
  - projects/value/src/validator.rb
381
- - projects/version/lib/foobara/version.rb
382
- - projects/version/src/version.rb
383
381
  - projects/weak_object_set/lib/foobara/weak_object_set.rb
384
382
  - projects/weak_object_set/src/weak_object_set.rb
385
383
  homepage: https://github.com/foobara/foobara
@@ -390,7 +388,7 @@ metadata:
390
388
  source_code_uri: https://github.com/foobara/foobara
391
389
  changelog_uri: https://github.com/foobara/foobara/CHANGELOG.md
392
390
  rubygems_mfa_required: 'true'
393
- post_install_message:
391
+ post_install_message:
394
392
  rdoc_options: []
395
393
  require_paths:
396
394
  - "./projects/builtin_types/lib"
@@ -417,7 +415,6 @@ require_paths:
417
415
  - "./projects/type_declarations/lib"
418
416
  - "./projects/types/lib"
419
417
  - "./projects/value/lib"
420
- - "./projects/version/lib"
421
418
  - "./projects/weak_object_set/lib"
422
419
  required_ruby_version: !ruby/object:Gem::Requirement
423
420
  requirements:
@@ -431,7 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
431
428
  version: '0'
432
429
  requirements: []
433
430
  rubygems_version: 3.4.10
434
- signing_key:
431
+ signing_key:
435
432
  specification_version: 4
436
433
  summary: Implements command pattern for encapsulating and managing domain complexity
437
434
  as well as many supporting libraries including entities.
@@ -1,4 +0,0 @@
1
- module Foobara
2
- module Version
3
- end
4
- end
@@ -1,5 +0,0 @@
1
- module Foobara
2
- module Version
3
- VERSION = "0.0.2".freeze
4
- end
5
- end