azahara_schema 0.4.5 → 0.5.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
  SHA256:
3
- metadata.gz: 90e7c8c4bcba4a03fc760342834e6d41da75254716d2a85c3bcaa3c29a3b16b7
4
- data.tar.gz: 2cafa249a27c2bedd66fe1ad8da3bbd6c87a5d7e6e3aa62d49cdf7adc8c3a35b
3
+ metadata.gz: bda25d077a33a251950c828875e82a1a959890d18b617a8b0dc1062f74ab0388
4
+ data.tar.gz: 92bfc2024428a90b4886aecb76ab2a3bd0fd5ded5061813b5357c0dfb117ec44
5
5
  SHA512:
6
- metadata.gz: cfae28b25d20524be4c1df713330300b633fa4423c25b53c1da59cf3c1874351e89e43940e2175d830edd36cfbaa490f804413dc901eb760838b2c3bf50855d1
7
- data.tar.gz: '0569975263efd31d2cd9e268c06637f1ba63b63caaac46dd812aecd3d7a86c11f91e3ed59845395075318530008b19c51b04e2ded7dc777662e958d46f73a88b'
6
+ metadata.gz: d5bbe4f88b69265cb246a2fc12fa5d4a7972a88550e60fc11464cb7794610144e186b6d40c68a90a682308a26d794f3c551154ad8a2459f9e3f39ed01d0c2b1d
7
+ data.tar.gz: ad30146b413c18d7a2d81580a32d82d10f2233c107c97340f5cc2586f2cdf7055476d4c1b23ad9d1e953229c528e2f5ca77ddf64111b66c2a50b8c813dd6f839
@@ -79,7 +79,7 @@ module AzaharaSchema
79
79
  end
80
80
 
81
81
  def attribute_formatter_for(schema_or_model, **options)
82
- ::AzaharaSchema::Presenter.formatter_for(schema_or_model).new(schema_or_model, self, options)
82
+ ::AzaharaSchema::Presenter.formatter_for(schema_or_model).new(schema_or_model, self, **options)
83
83
  end
84
84
 
85
85
  def unfilled_attribute_message
@@ -8,14 +8,14 @@ module AzaharaSchema
8
8
  end
9
9
 
10
10
  def human(**options)
11
- I18n.t(i18n_scoped_key, options.merge(default: i18n_fallback_keys))
11
+ I18n.t(i18n_scoped_key, **(options.merge(default: i18n_fallback_keys)))
12
12
  end
13
13
 
14
14
  # translates values to list_values
15
15
  # TODO: not needed to do it for every value - for example districts are not translatable
16
16
  def human_list_value(value, **options)
17
17
  return '' unless value.present?
18
- I18n.t(i18n_scoped_list_key(value.to_s), options.merge(default: i18n_list_fallback_keys(value)+[value.to_s]))
18
+ I18n.t(i18n_scoped_list_key(value.to_s), **options.merge(default: i18n_list_fallback_keys(value)+[value.to_s]))
19
19
  end
20
20
 
21
21
  def model_i18n_key
@@ -2,7 +2,7 @@ module AzaharaSchema
2
2
  module ControllerAdditions
3
3
 
4
4
  def azahara_schema_index(**options, &block)
5
- azahara_schema_for_index(options, &block)
5
+ azahara_schema_for_index(**options, &block)
6
6
  respond_to do |format|
7
7
  format.html
8
8
  format.json {
@@ -28,7 +28,7 @@ module AzaharaSchema
28
28
  end
29
29
 
30
30
  def azahara_schema_api_index(**options, &block)
31
- azahara_schema_for_index(options, &block)
31
+ azahara_schema_for_index(**options, &block)
32
32
  respond_to do |format|
33
33
  format.json {
34
34
  json_result = {}
@@ -3,7 +3,7 @@ module AzaharaSchema
3
3
 
4
4
  def initialize(*attrs)
5
5
  attributes = attrs.last.is_a?(Hash) ? attrs.pop : {}
6
- super(attrs.first || model, attributes)
6
+ super(attrs.first || model, **attributes)
7
7
  end
8
8
 
9
9
  def export_template
@@ -52,7 +52,7 @@ module AzaharaSchema
52
52
  when 'love'
53
53
  attribute.available_values.detect{|l, v| v == value }.try(:[], 0)
54
54
  when 'list'
55
- attribute.attribute_name.human_list_value(value, options)
55
+ attribute.attribute_name.human_list_value(value, **options)
56
56
  when 'datetime'
57
57
  value ? l(value) : value
58
58
  when 'date'
@@ -62,38 +62,38 @@ module AzaharaSchema
62
62
  end
63
63
  end
64
64
 
65
- def attribute_human_value(attribute, entity, **options)
65
+ def attribute_human_value(attribute, entity, **_options)
66
66
  human_value(attribute, attribute.value(entity))
67
67
  end
68
68
 
69
69
  def formatted_value(attribute, entity, **options)
70
- real_formatter(attribute).format_value(attribute, attribute_human_value(attribute, entity), formatting_options(attribute,entity).merge(options))
70
+ real_formatter(attribute).format_value(attribute, attribute_human_value(attribute, entity), **formatting_options(attribute,entity).merge(options))
71
71
  end
72
72
 
73
73
  def html_formatted_value(attribute, entity, **options)
74
- format_value_html(attribute, attribute_human_value(attribute, entity, options), formatting_options(attribute,entity).merge(options))
74
+ format_value_html(attribute, attribute_human_value(attribute, entity, **options), **formatting_options(attribute,entity).merge(options))
75
75
  end
76
76
 
77
77
  def attribute_html_label(attribute, **options)
78
- attribute.attribute_name.human(options)
78
+ attribute.attribute_name.human(**options)
79
79
  end
80
80
 
81
81
  def labeled_html_attribute_value(attribute, entity, **options)
82
82
  template.content_tag('div', class: 'attribute') do
83
83
  s = ''.html_safe
84
- s << template.content_tag('div', attribute_html_label(attribute, options), class: 'label')
85
- s << template.content_tag('div', html_formatted_value(attribute, entity, options), class: 'value')
84
+ s << template.content_tag('div', attribute_html_label(attribute, **options), class: 'label')
85
+ s << template.content_tag('div', html_formatted_value(attribute, entity, **options), class: 'value')
86
86
  s
87
87
  end
88
88
  end
89
89
 
90
90
 
91
- def format_value(attribute, unformated_value, **options)
91
+ def format_value(attribute, unformated_value, **_options)
92
92
  unformated_value
93
93
  end
94
94
 
95
95
  def format_value_html(attribute, unformated_value, **options)
96
- real_formatter(attribute).format_value(attribute, unformated_value, options) || template.unfilled_attribute_message
96
+ real_formatter(attribute).format_value(attribute, unformated_value, **options) || template.unfilled_attribute_message
97
97
  end
98
98
 
99
99
  def formatting_options(attribute, entity)
@@ -102,7 +102,7 @@ module AzaharaSchema
102
102
 
103
103
  def real_formatter(attribute)
104
104
  if attribute.respond_to?(:attribute)
105
- self.class.formatter_for(attribute.attribute.model).new(attribute.attribute.model, template, @options).real_formatter(attribute.attribute)
105
+ self.class.formatter_for(attribute.attribute.model).new(attribute.attribute.model, template, **@options).real_formatter(attribute.attribute)
106
106
  else
107
107
  self
108
108
  end
@@ -110,7 +110,7 @@ module AzaharaSchema
110
110
 
111
111
  def real_formatter_and_attribute(attribute)
112
112
  if attribute.respond_to?(:attribute)
113
- self.class.formatter_for(attribute.attribute.model).new(attribute.attribute.model, template, @options).real_formatter_and_attribute(attribute.attribute)
113
+ self.class.formatter_for(attribute.attribute.model).new(attribute.attribute.model, template, **@options).real_formatter_and_attribute(attribute.attribute)
114
114
  else
115
115
  [self, attribute]
116
116
  end
@@ -16,7 +16,7 @@ module AzaharaSchema
16
16
  AzaharaSchema::Schema
17
17
  end
18
18
 
19
- def self.schema_for(klass, *attributes)
19
+ def self.schema_for(klass, **attributes)
20
20
  model = klass
21
21
  klasses = [klass]
22
22
  while klass != klass.base_class
@@ -26,10 +26,10 @@ module AzaharaSchema
26
26
  klasses.each do |kls|
27
27
  schema_klass = "#{kls.name}Schema".safe_constantize
28
28
  if schema_klass
29
- return kls.try(:abstract_class?) ? schema_klass.new(model, *attributes) : schema_klass.new(*attributes)
29
+ return kls.try(:abstract_class?) ? schema_klass.new(model, **attributes) : schema_klass.new(**attributes)
30
30
  end
31
31
  end
32
- AzaharaSchema::Schema.new(model, *attributes)
32
+ AzaharaSchema::Schema.new(model, **attributes)
33
33
  end
34
34
 
35
35
  def self.attribute_type(model, name, col=nil)
@@ -1,3 +1,3 @@
1
1
  module AzaharaSchema
2
- VERSION = '0.4.5'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azahara_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-27 00:00:00.000000000 Z
11
+ date: 2024-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,21 @@ dependencies:
29
29
  version: '5.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
+ - !ruby/object:Gem::Dependency
34
+ name: sprockets-rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: sqlite3
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -50,14 +64,14 @@ dependencies:
50
64
  requirements:
51
65
  - - "~>"
52
66
  - !ruby/object:Gem::Version
53
- version: '3.6'
67
+ version: '6.1'
54
68
  type: :development
55
69
  prerelease: false
56
70
  version_requirements: !ruby/object:Gem::Requirement
57
71
  requirements:
58
72
  - - "~>"
59
73
  - !ruby/object:Gem::Version
60
- version: '3.6'
74
+ version: '6.1'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: factory_bot_rails
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +136,7 @@ homepage: https://git.justice.cz/libraries/azahara_schema
122
136
  licenses:
123
137
  - EUPL-1.2
124
138
  metadata: {}
125
- post_install_message:
139
+ post_install_message:
126
140
  rdoc_options: []
127
141
  require_paths:
128
142
  - lib
@@ -137,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  requirements: []
140
- rubygems_version: 3.1.6
141
- signing_key:
154
+ rubygems_version: 3.5.3
155
+ signing_key:
142
156
  specification_version: 4
143
157
  summary: Gem to support developement of rails application with schema over an entity
144
158
  test_files: []