wallaby-core 0.2.9 → 0.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/wallaby/resources_controller.rb +20 -7
  3. data/app/security/ability.rb +1 -1
  4. data/config/routes.rb +21 -14
  5. data/lib/adaptors/wallaby/custom/default_provider.rb +1 -1
  6. data/lib/adaptors/wallaby/custom/model_decorator.rb +5 -17
  7. data/lib/adaptors/wallaby/custom/model_finder.rb +3 -3
  8. data/lib/adaptors/wallaby/custom/model_pagination_provider.rb +1 -1
  9. data/lib/adaptors/wallaby/custom/model_service_provider.rb +1 -1
  10. data/lib/authorizers/wallaby/cancancan_authorization_provider.rb +12 -5
  11. data/lib/authorizers/wallaby/default_authorization_provider.rb +10 -1
  12. data/lib/authorizers/wallaby/model_authorizer.rb +41 -16
  13. data/lib/authorizers/wallaby/pundit_authorization_provider.rb +22 -8
  14. data/lib/concerns/wallaby/application_concern.rb +41 -71
  15. data/lib/concerns/wallaby/authentication_concern.rb +29 -127
  16. data/lib/concerns/wallaby/authorizable.rb +14 -57
  17. data/lib/concerns/wallaby/baseable.rb +24 -57
  18. data/lib/concerns/wallaby/configurable.rb +416 -0
  19. data/lib/concerns/wallaby/decoratable.rb +24 -60
  20. data/lib/concerns/wallaby/engineable.rb +29 -46
  21. data/lib/concerns/wallaby/fieldable.rb +45 -56
  22. data/lib/concerns/wallaby/paginatable.rb +20 -51
  23. data/lib/concerns/wallaby/prefixable.rb +24 -4
  24. data/lib/concerns/wallaby/resourcable.rb +130 -72
  25. data/lib/concerns/wallaby/resources_concern.rb +205 -305
  26. data/lib/concerns/wallaby/servicable.rb +8 -48
  27. data/lib/concerns/wallaby/urlable.rb +69 -0
  28. data/lib/decorators/wallaby/resource_decorator.rb +72 -34
  29. data/lib/errors/wallaby/class_not_found.rb +1 -2
  30. data/lib/errors/wallaby/forbidden.rb +1 -2
  31. data/lib/errors/wallaby/general_error.rb +1 -1
  32. data/lib/errors/wallaby/invalid_error.rb +1 -2
  33. data/lib/errors/wallaby/method_removed.rb +5 -0
  34. data/lib/errors/wallaby/model_not_found.rb +1 -2
  35. data/lib/errors/wallaby/not_authenticated.rb +1 -2
  36. data/lib/errors/wallaby/not_found.rb +1 -2
  37. data/lib/errors/wallaby/not_implemented.rb +1 -2
  38. data/lib/errors/wallaby/resource_not_found.rb +1 -2
  39. data/lib/errors/wallaby/unprocessable_entity.rb +1 -2
  40. data/lib/fields/wallaby/all_fields.rb +63 -0
  41. data/lib/forms/wallaby/form_builder.rb +2 -2
  42. data/lib/generators/wallaby/engine/application_generator.rb +33 -0
  43. data/lib/generators/wallaby/engine/authorizer/USAGE +20 -0
  44. data/lib/generators/wallaby/engine/authorizer/authorizer_generator.rb +19 -0
  45. data/lib/generators/wallaby/engine/authorizer/templates/authorizer.rb.erb +35 -0
  46. data/lib/generators/wallaby/engine/controller/USAGE +20 -0
  47. data/lib/generators/wallaby/engine/controller/controller_generator.rb +23 -0
  48. data/lib/generators/wallaby/engine/controller/templates/controller.rb.erb +130 -0
  49. data/lib/generators/wallaby/engine/decorator/USAGE +20 -0
  50. data/lib/generators/wallaby/engine/decorator/decorator_generator.rb +19 -0
  51. data/lib/generators/wallaby/engine/decorator/templates/decorator.rb.erb +5 -0
  52. data/lib/generators/wallaby/engine/install/USAGE +19 -0
  53. data/lib/generators/wallaby/engine/install/install_generator.rb +91 -0
  54. data/lib/generators/wallaby/engine/install/templates/application_authorizer.rb.erb +37 -0
  55. data/lib/generators/wallaby/engine/install/templates/application_controller.rb.erb +173 -0
  56. data/lib/generators/wallaby/engine/install/templates/application_decorator.rb.erb +7 -0
  57. data/lib/generators/wallaby/engine/install/templates/application_paginator.rb.erb +27 -0
  58. data/lib/generators/wallaby/engine/install/templates/application_servicer.rb.erb +47 -0
  59. data/lib/generators/wallaby/engine/install/templates/initializer.rb.erb +16 -0
  60. data/lib/generators/wallaby/engine/paginator/USAGE +20 -0
  61. data/lib/generators/wallaby/engine/paginator/paginator_generator.rb +19 -0
  62. data/lib/generators/wallaby/engine/paginator/templates/paginator.rb.erb +25 -0
  63. data/lib/generators/wallaby/engine/servicer/USAGE +20 -0
  64. data/lib/generators/wallaby/engine/servicer/servicer_generator.rb +19 -0
  65. data/lib/generators/wallaby/engine/servicer/templates/servicer.rb.erb +45 -0
  66. data/lib/helpers/wallaby/application_helper.rb +10 -59
  67. data/lib/helpers/wallaby/base_helper.rb +11 -11
  68. data/lib/helpers/wallaby/configuration_helper.rb +36 -4
  69. data/lib/helpers/wallaby/form_helper.rb +1 -1
  70. data/lib/helpers/wallaby/index_helper.rb +19 -9
  71. data/lib/helpers/wallaby/links_helper.rb +13 -80
  72. data/lib/helpers/wallaby/resources_helper.rb +39 -7
  73. data/lib/helpers/wallaby/secure_helper.rb +20 -19
  74. data/lib/interfaces/wallaby/mode.rb +8 -8
  75. data/lib/interfaces/wallaby/model_authorization_provider.rb +23 -22
  76. data/lib/interfaces/wallaby/model_decorator.rb +36 -48
  77. data/lib/interfaces/wallaby/model_finder.rb +3 -3
  78. data/lib/interfaces/wallaby/model_pagination_provider.rb +2 -6
  79. data/lib/interfaces/wallaby/model_service_provider.rb +4 -4
  80. data/lib/paginators/wallaby/model_paginator.rb +1 -1
  81. data/lib/responders/wallaby/json_api_responder.rb +10 -5
  82. data/lib/responders/wallaby/resources_responder.rb +7 -2
  83. data/lib/routes/wallaby/engines/base_route.rb +78 -0
  84. data/lib/routes/wallaby/engines/custom_app_route.rb +92 -0
  85. data/lib/routes/wallaby/engines/engine_route.rb +77 -0
  86. data/lib/routes/wallaby/resources_router.rb +100 -45
  87. data/lib/servicers/wallaby/model_servicer.rb +13 -13
  88. data/lib/services/wallaby/authorizer_finder.rb +23 -0
  89. data/lib/services/wallaby/class_finder.rb +42 -0
  90. data/lib/services/wallaby/controller_finder.rb +29 -0
  91. data/lib/services/wallaby/decorator_finder.rb +34 -0
  92. data/lib/services/wallaby/default_models_excluder.rb +45 -0
  93. data/lib/services/wallaby/engine_name_finder.rb +14 -11
  94. data/lib/services/wallaby/engine_url_for.rb +82 -37
  95. data/lib/services/wallaby/fields_regulator.rb +34 -0
  96. data/lib/services/wallaby/map/mode_mapper.rb +4 -4
  97. data/lib/services/wallaby/map/model_class_mapper.rb +1 -1
  98. data/lib/services/wallaby/model_class_filter.rb +29 -0
  99. data/lib/services/wallaby/paginator_finder.rb +24 -0
  100. data/lib/services/wallaby/prefixes_builder.rb +49 -8
  101. data/lib/services/wallaby/servicer_finder.rb +31 -0
  102. data/lib/services/wallaby/sorting/hash_builder.rb +9 -0
  103. data/lib/services/wallaby/sorting/link_builder.rb +7 -10
  104. data/lib/services/wallaby/sorting/next_builder.rb +1 -12
  105. data/lib/services/wallaby/sorting/single_builder.rb +1 -1
  106. data/lib/support/action_dispatch/routing/mapper.rb +29 -4
  107. data/lib/utils/wallaby/field_utils.rb +9 -8
  108. data/lib/utils/wallaby/inflector.rb +94 -0
  109. data/lib/utils/wallaby/locale.rb +2 -2
  110. data/lib/utils/wallaby/module_utils.rb +3 -10
  111. data/lib/utils/wallaby/utils.rb +21 -14
  112. data/lib/wallaby/class_array.rb +18 -13
  113. data/lib/wallaby/class_hash.rb +16 -14
  114. data/lib/wallaby/classifier.rb +4 -2
  115. data/lib/wallaby/configuration/features.rb +8 -2
  116. data/lib/wallaby/configuration/mapping.rb +66 -112
  117. data/lib/wallaby/configuration/metadata.rb +15 -12
  118. data/lib/wallaby/configuration/models.rb +27 -25
  119. data/lib/wallaby/configuration/pagination.rb +15 -19
  120. data/lib/wallaby/configuration/security.rb +88 -80
  121. data/lib/wallaby/configuration/sorting.rb +15 -17
  122. data/lib/wallaby/configuration.rb +58 -23
  123. data/lib/wallaby/constants.rb +21 -13
  124. data/lib/wallaby/core/version.rb +1 -1
  125. data/lib/wallaby/core.rb +34 -10
  126. data/lib/wallaby/deprecator.rb +81 -0
  127. data/lib/wallaby/engine.rb +1 -19
  128. data/lib/wallaby/guesser.rb +45 -0
  129. data/lib/wallaby/logger.rb +35 -13
  130. data/lib/wallaby/map.rb +14 -87
  131. data/lib/wallaby/preloader.rb +13 -25
  132. metadata +120 -15
  133. data/config/locales/wallaby_class.en.yml +0 -9
  134. data/lib/concerns/wallaby/defaultable.rb +0 -38
  135. data/lib/concerns/wallaby/shared_helpers.rb +0 -22
  136. data/lib/services/wallaby/map/model_class_collector.rb +0 -49
  137. data/lib/services/wallaby/type_renderer.rb +0 -40
  138. data/lib/utils/wallaby/model_utils.rb +0 -52
  139. data/lib/utils/wallaby/test_utils.rb +0 -34
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wallaby
4
+ # Guess the associated class for give class
5
+ class Guesser
6
+ SUFFIX = /(Controller|Decorator|Servicer|Authorizer|Paginator)$/.freeze # :no_doc:
7
+
8
+ class << self
9
+ # Find out the first demodulized class constant for the give class name.
10
+ # For example, if given class name is **Admin::Order::ItemsController**,
11
+ # then it will try to constantize the following demodulized class names
12
+ # and return the first one that is successfully constantized:
13
+ #
14
+ # - Admin::Order::Item
15
+ # - Order::Item
16
+ # - Item
17
+ # @param class_name [String]
18
+ # @param options [Hash]
19
+ # @return [Class] found associated class
20
+ # @return [nil] if not found
21
+ def class_for(class_name, options = {}, &block)
22
+ suffix = options[:suffix] || EMPTY_STRING
23
+ replacement = options[:replacement] || SUFFIX
24
+ denamespace = options.key?(:denamespace) ? options[:denamespace] : true
25
+ base_name = class_name.gsub(replacement, EMPTY_STRING).singularize << suffix
26
+ possible_class_from(base_name, denamespace: denamespace, &block)
27
+ end
28
+
29
+ def possible_class_from(class_name, denamespace: false)
30
+ target = nil
31
+ parts = denamespace ? class_name.split(COLONS) : [class_name]
32
+ parts.each_with_index.find do |_, index|
33
+ klass = Classifier.to_class(parts[index..].join(COLONS))
34
+ next unless klass
35
+ # additional checking, the given block should return true to continue
36
+ next if block_given? && !yield(klass)
37
+
38
+ target = klass
39
+ end
40
+
41
+ target
42
+ end
43
+ end
44
+ end
45
+ end
@@ -4,31 +4,53 @@ module Wallaby
4
4
  # Custom logger
5
5
  module Logger
6
6
  class << self
7
- %i(unknown fatal error warn info debug deprecated).each do |method_id|
7
+ %i[unknown fatal error warn info debug].each do |method_id|
8
8
  define_method method_id do |message, replacements = {}|
9
- sourcing = replacements.delete :sourcing # sourcing can be set to false
9
+ sourcing = replacements.delete(:sourcing) # sourcing can be set to false
10
10
  heading = replacements.delete(:heading) || 'WALLABY '
11
- new_message, from = normalize message, sourcing != false && Array(caller[sourcing || 0]) || nil
12
- Rails.logger.public_send(
13
- method_id == :deprecated ? :warn : method_id,
11
+ new_message, from = normalize(
12
+ message, (sourcing != false && Array.wrap(caller[sourcing || 0])) || nil
13
+ )
14
+ Wallaby.configuration.logger.try(
15
+ method_id,
14
16
  "#{heading}#{method_id.to_s.upcase}: #{format new_message, replacements}#{from}"
15
17
  )
16
18
  nil
17
19
  end
18
20
  end
19
21
 
22
+ # @param key [Symbol,String]
23
+ # @param message_or_config [String, false]
24
+ # @param replacements [Hash]
25
+ # @example to disable a particular hint message:
26
+ # Wallaby::Logger.hint(:customize_controller, false) if Wallaby::Logger.debug?
27
+ def hint(key, message_or_config, replacements = {})
28
+ @hint ||= {}
29
+ return @hint[key] = false if message_or_config == false
30
+ return if @hint[key] == false || !message_or_config.is_a?(String)
31
+
32
+ new_message = <<~MESSAGE
33
+ #{message_or_config}
34
+ This kind of debug message can be disabled in `config/initializers/wallaby.rb`:
35
+
36
+ Wallaby::Logger.hint(#{key.inspect}, false) if Wallaby::Logger.debug?
37
+ MESSAGE
38
+ debug(new_message, replacements.merge(sourcing: false))
39
+ end
40
+
20
41
  protected
21
42
 
22
- # @param message [Object]
43
+ # @param message [String,StandardError,Object]
44
+ # @param sources [Array<String>] array of files
23
45
  def normalize(message, sources)
24
- case message
25
- when String
26
- [message, sources && "\nfrom #{sources.join(" \n")}"]
27
- when StandardError
28
- [message.message, sources && "\n#{message.backtrace.join("\n")}"]
29
- else
30
- [message.inspect, sources && "\nfrom #{sources.join(" \n")}"]
46
+ if message.is_a?(StandardError)
47
+ return [
48
+ message.message,
49
+ sources && "\n#{message.backtrace.join("\n")}"
50
+ ]
31
51
  end
52
+
53
+ [message.to_s, sources && "\nfrom #{sources.join(" \n")}"]
32
54
  end
33
55
  end
34
56
  end
data/lib/wallaby/map.rb CHANGED
@@ -10,20 +10,23 @@ module Wallaby
10
10
  attr_writer :modes
11
11
 
12
12
  # @!attribute [r] modes
13
- # @return [Array<String>] all {Wallaby::Mode}s
13
+ # @return [Array<String>] all {Mode}s
14
14
  def modes
15
15
  @modes ||= ClassArray.new Mode.descendants
16
16
  end
17
17
 
18
- # @return [Wallaby::ClassHash] { Model Class => {Wallaby::Mode} }
18
+ # @return [ClassHash] { Model Class => {Mode} }
19
19
  def mode_map
20
- @mode_map ||= ModeMapper.execute(modes).freeze
20
+ @mode_map ||= begin
21
+ # NOTE: this is the point where all model files should be required
22
+ Preloader.require_models
23
+ ModeMapper.execute(modes).freeze
24
+ end
21
25
  end
22
26
 
23
- # TODO: remove this method
24
- # @return [Array] [ model classes ]
27
+ # @deprecated
25
28
  def model_classes
26
- ModelClassCollector.new(configuration, mode_map.keys).collect
29
+ Deprecator.alert method(__callee__), from: '0.3.0'
27
30
  end
28
31
 
29
32
  # { model => resources name }
@@ -34,7 +37,7 @@ module Wallaby
34
37
  # @return [String] resources name
35
38
  def resources_name_map(model_class, value = nil)
36
39
  @resources_name_map ||= ClassHash.new
37
- @resources_name_map[model_class] ||= value || ModelUtils.to_resources_name(model_class)
40
+ @resources_name_map[model_class] ||= value || Inflector.to_resources_name(model_class)
38
41
  end
39
42
 
40
43
  # { resources name => model }
@@ -44,67 +47,21 @@ module Wallaby
44
47
  # @return [Class]
45
48
  def model_class_map(resources_name, value = nil)
46
49
  @model_class_map ||= ClassHash.new
47
- @model_class_map[resources_name] ||= value || ModelUtils.to_model_class(resources_name)
50
+ @model_class_map[resources_name] ||= value || Classifier.to_class(Inflector.to_model_name(resources_name))
48
51
  end
49
52
  end
50
53
 
51
54
  class << self
52
- # Look up which controller to use for a given model class
53
- # @param model_class [Class]
54
- # @param application_controller [Class, nil]
55
- # @return [Class] controller class, default to `mapping.resources_controller`
56
- def controller_map(model_class, application_controller = nil)
57
- application_controller ||= mapping.resources_controller
58
- map_of :@controller_map, model_class, application_controller
59
- end
60
-
61
- # Look up which resource decorator to use for a given model class
62
- # @param model_class [Class]
63
- # @param application_decorator [Class, nil]
64
- # @return [Class] resource decorator class, default to `mapping.resource_decorator`
65
- def resource_decorator_map(model_class, application_decorator = nil)
66
- application_decorator ||= mapping.resource_decorator
67
- map_of :@resource_decorator_map, model_class, application_decorator
68
- end
69
-
70
55
  # { model => model decorator }
71
56
  # @param model_class [Class]
72
- # @param application_decorator [Class, nil]
73
- # @return [Wallaby::ModelDecorator] model decorator instance
74
- def model_decorator_map(model_class, application_decorator = nil)
75
- application_decorator ||= mapping.resource_decorator
57
+ # @param application_decorator [Class]
58
+ # @return [ModelDecorator] model decorator instance
59
+ def model_decorator_map(model_class, application_decorator)
76
60
  @model_decorator_map ||= ClassHash.new
77
61
  @model_decorator_map[application_decorator] ||= ClassHash.new
78
62
  @model_decorator_map[application_decorator][model_class] ||=
79
63
  mode_map[model_class].try(:model_decorator).try :new, model_class
80
64
  end
81
-
82
- # Look up which model servicer to use for a given model class
83
- # @param model_class [Class]
84
- # @param application_servicer [Class, nil]
85
- # @return [Class] model servicer class, default to `mapping.model_servicer`
86
- def servicer_map(model_class, application_servicer = nil)
87
- application_servicer ||= mapping.model_servicer
88
- map_of :@servicer_map, model_class, application_servicer
89
- end
90
-
91
- # Look up which paginator to use for a given model class
92
- # @param model_class [Class]
93
- # @param application_paginator [Class, nil]
94
- # @return [Class] resource paginator class, default to `mapping.model_paginator`
95
- def paginator_map(model_class, application_paginator = nil)
96
- application_paginator ||= mapping.model_paginator
97
- map_of :@paginator_map, model_class, application_paginator
98
- end
99
-
100
- # Look up which authorizer to use for a given model class
101
- # @param model_class [Class]
102
- # @param application_authorizer [Class, nil]
103
- # @return [Class] model authorizer class, default to `mapping.model_authorizer`
104
- def authorizer_map(model_class, application_authorizer = nil)
105
- application_authorizer ||= mapping.model_authorizer
106
- map_of :@authorizer_map, model_class, application_authorizer
107
- end
108
65
  end
109
66
 
110
67
  class << self
@@ -138,36 +95,6 @@ module Wallaby
138
95
  def clear
139
96
  instance_variables.each { |name| instance_variable_set name, nil }
140
97
  end
141
-
142
- private
143
-
144
- # shorthand method
145
- def configuration
146
- ::Wallaby.configuration
147
- end
148
-
149
- # shorthand method
150
- def mapping
151
- configuration.mapping
152
- end
153
-
154
- # Set up the hash map for given variable name
155
- # @param variable_name [Symbol] instance variable name e.g. :@decorator_map
156
- # @param model_class [Class]
157
- # @param application_class [Class]
158
- # @return [Class]
159
- def map_of(variable_name, model_class, application_class)
160
- return unless model_class
161
-
162
- unless mode_map[model_class]
163
- Logger.warn Locale.t('map.missing_mode_for_model_class', model: model_class.name), sourcing: 2..5
164
- return
165
- end
166
- instance_variable_set(variable_name, instance_variable_get(variable_name) || ClassHash.new)
167
- map = instance_variable_get variable_name
168
- map[application_class] ||= ModelClassMapper.map application_class.descendants
169
- map[application_class][model_class] ||= application_class
170
- end
171
98
  end
172
99
  end
173
100
  end
@@ -3,7 +3,7 @@
3
3
  module Wallaby
4
4
  # Preload files for eager load paths.
5
5
  #
6
- # As Wallaby is built upon the {Wallaby::Map} which will not be completed
6
+ # As Wallaby is built upon the {Map} which will not be completed
7
7
  # until all models and decorators/controllers/servicers/authorizers/paginators
8
8
  # are loaded. Therefore, when Rails app is initialized,
9
9
  # all files under eager load paths (mostly `app/*` folders),
@@ -11,26 +11,17 @@ module Wallaby
11
11
  class Preloader
12
12
  include ActiveModel::Model
13
13
 
14
- # Require all files
15
- # @see #all_file_paths
16
- def self.require_all
17
- new.all_file_paths.each(&method(:require_dependency))
14
+ class << self
15
+ # Require models under {Configuration#model_paths}
16
+ # @see #model_file_paths
17
+ def require_models
18
+ new.model_file_paths.each { |path| require_dependency(path) }
19
+ end
18
20
  end
19
21
 
20
- # Require models under {Wallaby::Configuration#model_paths}
21
- # @see #model_file_paths
22
- def self.require_models
23
- new.model_file_paths.each(&method(:require_dependency))
24
- end
25
-
26
- # @return [Array<String>] all files under **Rails.configuration.eager_load_paths**
27
- def all_file_paths
28
- sort all_eager_load_file_paths
29
- end
30
-
31
- # @return [Array<String>] model files under {Wallaby::Configuration#model_paths}
22
+ # @return [Array<String>] model files under {Configuration#model_paths}
32
23
  def model_file_paths
33
- sort(all_eager_load_file_paths).select(&method(:indexed))
24
+ sort(all_eager_load_file_paths).select { |path| indexed(path) }
34
25
  end
35
26
 
36
27
  # @!attribute [w] eager_load_paths
@@ -39,10 +30,7 @@ module Wallaby
39
30
  # @!attribute [r] eager_load_paths
40
31
  # @return [Array<String, Pathname>]
41
32
  def eager_load_paths # :nodoc:
42
- @eager_load_paths ||=
43
- Rails.configuration.paths['app'].expanded
44
- .concat(Rails.configuration.eager_load_paths)
45
- .uniq
33
+ @eager_load_paths ||= Rails.configuration.eager_load_paths
46
34
  end
47
35
 
48
36
  # @!attribute [w] model_paths
@@ -61,7 +49,7 @@ module Wallaby
61
49
  end
62
50
 
63
51
  # All files need to be sorted in the following orders:
64
- # 1. {Wallaby::Configuration#model_paths} order
52
+ # 1. {Configuration#model_paths} order
65
53
  # 2. Alphabet order
66
54
  def sort(file_paths)
67
55
  file_paths.sort { |p1, p2| conditions_for(p1) <=> conditions_for(p2) }
@@ -72,9 +60,9 @@ module Wallaby
72
60
  [indexed(path) || model_paths.length, path]
73
61
  end
74
62
 
75
- # Check if the path is in the {Wallaby::Configuration#model_paths}
63
+ # Check if the path is in the {Configuration#model_paths}
76
64
  def indexed(path)
77
- model_paths.index(&path.method(:include?))
65
+ model_paths.index { |p| path.include?(p) }
78
66
  end
79
67
  end
80
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wallaby-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tian Chen
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-19 00:00:00.000000000 Z
11
+ date: 2023-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.2.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: 7.1.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: 4.2.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 7.1.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: railties
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: 4.2.0
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: 7.1.0
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,9 @@ dependencies:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: 4.2.0
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: 7.1.0
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: parslet
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +92,34 @@ dependencies:
80
92
  - - "~>"
81
93
  - !ruby/object:Gem::Version
82
94
  version: 0.1.2
95
+ - !ruby/object:Gem::Dependency
96
+ name: github-markup
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: redcarpet
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
83
123
  - !ruby/object:Gem::Dependency
84
124
  name: rspec-rails
85
125
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +134,20 @@ dependencies:
94
134
  - - ">="
95
135
  - !ruby/object:Gem::Version
96
136
  version: '0'
137
+ - !ruby/object:Gem::Dependency
138
+ name: simplecov
139
+ requirement: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ type: :development
145
+ prerelease: false
146
+ version_requirements: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
97
151
  - !ruby/object:Gem::Dependency
98
152
  name: wallaby-cop
99
153
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +162,20 @@ dependencies:
108
162
  - - ">="
109
163
  - !ruby/object:Gem::Version
110
164
  version: '0'
165
+ - !ruby/object:Gem::Dependency
166
+ name: yard
167
+ requirement: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ type: :development
173
+ prerelease: false
174
+ version_requirements: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
111
179
  description: The core of Wallaby
112
180
  email:
113
181
  - me@tian.im
@@ -120,7 +188,6 @@ files:
120
188
  - app/controllers/wallaby/resources_controller.rb
121
189
  - app/security/ability.rb
122
190
  - config/locales/wallaby.en.yml
123
- - config/locales/wallaby_class.en.yml
124
191
  - config/routes.rb
125
192
  - lib/adaptors/wallaby/custom.rb
126
193
  - lib/adaptors/wallaby/custom/default_provider.rb
@@ -136,8 +203,8 @@ files:
136
203
  - lib/concerns/wallaby/authentication_concern.rb
137
204
  - lib/concerns/wallaby/authorizable.rb
138
205
  - lib/concerns/wallaby/baseable.rb
206
+ - lib/concerns/wallaby/configurable.rb
139
207
  - lib/concerns/wallaby/decoratable.rb
140
- - lib/concerns/wallaby/defaultable.rb
141
208
  - lib/concerns/wallaby/engineable.rb
142
209
  - lib/concerns/wallaby/fieldable.rb
143
210
  - lib/concerns/wallaby/paginatable.rb
@@ -145,19 +212,45 @@ files:
145
212
  - lib/concerns/wallaby/resourcable.rb
146
213
  - lib/concerns/wallaby/resources_concern.rb
147
214
  - lib/concerns/wallaby/servicable.rb
148
- - lib/concerns/wallaby/shared_helpers.rb
215
+ - lib/concerns/wallaby/urlable.rb
149
216
  - lib/decorators/wallaby/resource_decorator.rb
150
217
  - lib/errors/wallaby/class_not_found.rb
151
218
  - lib/errors/wallaby/forbidden.rb
152
219
  - lib/errors/wallaby/general_error.rb
153
220
  - lib/errors/wallaby/invalid_error.rb
221
+ - lib/errors/wallaby/method_removed.rb
154
222
  - lib/errors/wallaby/model_not_found.rb
155
223
  - lib/errors/wallaby/not_authenticated.rb
156
224
  - lib/errors/wallaby/not_found.rb
157
225
  - lib/errors/wallaby/not_implemented.rb
158
226
  - lib/errors/wallaby/resource_not_found.rb
159
227
  - lib/errors/wallaby/unprocessable_entity.rb
228
+ - lib/fields/wallaby/all_fields.rb
160
229
  - lib/forms/wallaby/form_builder.rb
230
+ - lib/generators/wallaby/engine/application_generator.rb
231
+ - lib/generators/wallaby/engine/authorizer/USAGE
232
+ - lib/generators/wallaby/engine/authorizer/authorizer_generator.rb
233
+ - lib/generators/wallaby/engine/authorizer/templates/authorizer.rb.erb
234
+ - lib/generators/wallaby/engine/controller/USAGE
235
+ - lib/generators/wallaby/engine/controller/controller_generator.rb
236
+ - lib/generators/wallaby/engine/controller/templates/controller.rb.erb
237
+ - lib/generators/wallaby/engine/decorator/USAGE
238
+ - lib/generators/wallaby/engine/decorator/decorator_generator.rb
239
+ - lib/generators/wallaby/engine/decorator/templates/decorator.rb.erb
240
+ - lib/generators/wallaby/engine/install/USAGE
241
+ - lib/generators/wallaby/engine/install/install_generator.rb
242
+ - lib/generators/wallaby/engine/install/templates/application_authorizer.rb.erb
243
+ - lib/generators/wallaby/engine/install/templates/application_controller.rb.erb
244
+ - lib/generators/wallaby/engine/install/templates/application_decorator.rb.erb
245
+ - lib/generators/wallaby/engine/install/templates/application_paginator.rb.erb
246
+ - lib/generators/wallaby/engine/install/templates/application_servicer.rb.erb
247
+ - lib/generators/wallaby/engine/install/templates/initializer.rb.erb
248
+ - lib/generators/wallaby/engine/paginator/USAGE
249
+ - lib/generators/wallaby/engine/paginator/paginator_generator.rb
250
+ - lib/generators/wallaby/engine/paginator/templates/paginator.rb.erb
251
+ - lib/generators/wallaby/engine/servicer/USAGE
252
+ - lib/generators/wallaby/engine/servicer/servicer_generator.rb
253
+ - lib/generators/wallaby/engine/servicer/templates/servicer.rb.erb
161
254
  - lib/helpers/wallaby/application_helper.rb
162
255
  - lib/helpers/wallaby/base_helper.rb
163
256
  - lib/helpers/wallaby/configuration_helper.rb
@@ -177,29 +270,38 @@ files:
177
270
  - lib/parsers/wallaby/parser.rb
178
271
  - lib/responders/wallaby/json_api_responder.rb
179
272
  - lib/responders/wallaby/resources_responder.rb
273
+ - lib/routes/wallaby/engines/base_route.rb
274
+ - lib/routes/wallaby/engines/custom_app_route.rb
275
+ - lib/routes/wallaby/engines/engine_route.rb
180
276
  - lib/routes/wallaby/resources_router.rb
181
277
  - lib/servicers/wallaby/model_servicer.rb
278
+ - lib/services/wallaby/authorizer_finder.rb
279
+ - lib/services/wallaby/class_finder.rb
280
+ - lib/services/wallaby/controller_finder.rb
281
+ - lib/services/wallaby/decorator_finder.rb
282
+ - lib/services/wallaby/default_models_excluder.rb
182
283
  - lib/services/wallaby/engine_name_finder.rb
183
284
  - lib/services/wallaby/engine_url_for.rb
285
+ - lib/services/wallaby/fields_regulator.rb
184
286
  - lib/services/wallaby/link_options_normalizer.rb
185
287
  - lib/services/wallaby/map/mode_mapper.rb
186
- - lib/services/wallaby/map/model_class_collector.rb
187
288
  - lib/services/wallaby/map/model_class_mapper.rb
289
+ - lib/services/wallaby/model_class_filter.rb
290
+ - lib/services/wallaby/paginator_finder.rb
188
291
  - lib/services/wallaby/prefixes_builder.rb
292
+ - lib/services/wallaby/servicer_finder.rb
189
293
  - lib/services/wallaby/sorting/hash_builder.rb
190
294
  - lib/services/wallaby/sorting/link_builder.rb
191
295
  - lib/services/wallaby/sorting/next_builder.rb
192
296
  - lib/services/wallaby/sorting/single_builder.rb
193
- - lib/services/wallaby/type_renderer.rb
194
297
  - lib/support/action_dispatch/routing/mapper.rb
195
298
  - lib/tree/wallaby/node.rb
196
299
  - lib/utils/wallaby/field_utils.rb
197
300
  - lib/utils/wallaby/filter_utils.rb
301
+ - lib/utils/wallaby/inflector.rb
198
302
  - lib/utils/wallaby/locale.rb
199
- - lib/utils/wallaby/model_utils.rb
200
303
  - lib/utils/wallaby/module_utils.rb
201
304
  - lib/utils/wallaby/params_utils.rb
202
- - lib/utils/wallaby/test_utils.rb
203
305
  - lib/utils/wallaby/utils.rb
204
306
  - lib/wallaby/class_array.rb
205
307
  - lib/wallaby/class_hash.rb
@@ -215,7 +317,9 @@ files:
215
317
  - lib/wallaby/constants.rb
216
318
  - lib/wallaby/core.rb
217
319
  - lib/wallaby/core/version.rb
320
+ - lib/wallaby/deprecator.rb
218
321
  - lib/wallaby/engine.rb
322
+ - lib/wallaby/guesser.rb
219
323
  - lib/wallaby/logger.rb
220
324
  - lib/wallaby/map.rb
221
325
  - lib/wallaby/preloader.rb
@@ -226,7 +330,8 @@ metadata:
226
330
  homepage_uri: https://github.com/wallaby-rails/wallaby-core
227
331
  source_code_uri: https://github.com/wallaby-rails/wallaby-core
228
332
  changelog_uri: https://github.com/wallaby-rails/wallaby-core/blob/master/CHANGELOG.md
229
- post_install_message:
333
+ rubygems_mfa_required: 'true'
334
+ post_install_message:
230
335
  rdoc_options: []
231
336
  require_paths:
232
337
  - lib
@@ -237,12 +342,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
237
342
  version: '0'
238
343
  required_rubygems_version: !ruby/object:Gem::Requirement
239
344
  requirements:
240
- - - ">="
345
+ - - ">"
241
346
  - !ruby/object:Gem::Version
242
- version: '0'
347
+ version: 1.3.1
243
348
  requirements: []
244
- rubygems_version: 3.1.6
245
- signing_key:
349
+ rubygems_version: 3.3.25
350
+ signing_key:
246
351
  specification_version: 4
247
352
  summary: The core of Wallaby
248
353
  test_files: []
@@ -1,9 +0,0 @@
1
- en:
2
- wallaby:
3
- map:
4
- missing_mode_for_model_class: "Don't know how to handle this model %{model}."
5
- model_class_mapper:
6
- missing_model_class: "Please define self.model_class for %{model} or set it as global.\n @see Wallaby.configuration.mapping"
7
-
8
- mode:
9
- inherit_required: '%{klass} must inherit from %{parent}.'
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Wallaby
4
- # Defaults related methods
5
- module Defaultable
6
- protected
7
-
8
- # Set default options for create action
9
- # @param options [Hash]
10
- # @return [Hash] updated options with default values
11
- def set_defaults_for(action, options)
12
- case action.try(:to_sym)
13
- when :create, :update then assign_create_and_update_defaults_with options
14
- when :destroy then assign_destroy_defaults_with options
15
- end
16
- options
17
- end
18
-
19
- # @param options [Hash]
20
- # @return [Hash] updated options with default values
21
- def assign_create_and_update_defaults_with(options)
22
- options[:params] ||= resource_params
23
- options[:location] ||= -> { helpers.show_path resource, is_resource: params[:resource] }
24
- end
25
-
26
- # @param options [Hash]
27
- # @return [Hash] updated options with default values
28
- def assign_destroy_defaults_with(options)
29
- options[:params] ||= params
30
- options[:location] ||=
31
- if params[:resource]
32
- helpers.show_path resource, is_resource: params[:resource]
33
- else
34
- helpers.index_path current_model_class
35
- end
36
- end
37
- end
38
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Wallaby
4
- # Shared helpers
5
- module SharedHelpers
6
- protected
7
-
8
- # Fetch value for given attribute.
9
- #
10
- # If it's used in controller, it will fetch it from class attribute.
11
- # If it's used in view, it will fetch it from controller.
12
- # @param attribute_name [String, Symbol] instance attribute name
13
- # @param class_attribute_name [String, Symbol] class attribute name
14
- # @return [Object] the value
15
- def controller_to_get(attribute_name, class_attribute_name = nil)
16
- class_attribute_name ||= attribute_name
17
- return ModuleUtils.try_to self.class, class_attribute_name if is_a? ::ActionController::Base # controller?
18
-
19
- ModuleUtils.try_to controller, attribute_name # view?
20
- end
21
- end
22
- end