jat 0.0.5 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jat/attribute.rb +5 -16
  3. data/lib/jat/config.rb +4 -7
  4. data/lib/jat/plugins/activerecord/activerecord.rb +23 -0
  5. data/lib/jat/plugins/{_activerecord_preloads/_activerecord_preloads.rb → base/base_activerecord_preloads/base_activerecord_preloads.rb} +7 -2
  6. data/lib/jat/plugins/{_activerecord_preloads → base/base_activerecord_preloads}/lib/preloader.rb +16 -4
  7. data/lib/jat/plugins/{_lower_camel_case/_lower_camel_case.rb → base/base_lower_camel_case/base_lower_camel_case.rb} +6 -2
  8. data/lib/jat/plugins/{_preloads/_preloads.rb → base/base_preloads/base_preloads.rb} +6 -2
  9. data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/format_user_preloads.rb +1 -1
  10. data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/preloads_with_path.rb +1 -1
  11. data/lib/jat/plugins/cache/cache.rb +5 -1
  12. data/lib/jat/plugins/json_api/json_api.rb +7 -3
  13. data/lib/jat/plugins/json_api/lib/map.rb +4 -5
  14. data/lib/jat/plugins/json_api/lib/response.rb +1 -5
  15. data/lib/jat/plugins/json_api/lib/response_piece.rb +19 -10
  16. data/lib/jat/plugins/json_api/plugins/json_api_activerecord/json_api_activerecord.rb +23 -0
  17. data/lib/jat/plugins/{json_api_lower_camel_case → json_api/plugins/json_api_lower_camel_case}/json_api_lower_camel_case.rb +6 -2
  18. data/lib/jat/plugins/{json_api_maps_cache → json_api/plugins/json_api_maps_cache}/json_api_maps_cache.rb +5 -1
  19. data/lib/jat/plugins/json_api/plugins/json_api_preloads/json_api_preloads.rb +38 -0
  20. data/lib/jat/plugins/{json_api_activerecord → json_api/plugins/json_api_preloads}/lib/preloads.rb +1 -1
  21. data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/json_api_validate_params.rb +5 -1
  22. data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/params_error.rb +0 -0
  23. data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/validate_fields_param.rb +0 -0
  24. data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/validate_include_param.rb +1 -3
  25. data/lib/jat/plugins/lower_camel_case/lower_camel_case.rb +23 -0
  26. data/lib/jat/plugins/maps_cache/maps_cache.rb +23 -0
  27. data/lib/jat/plugins/preloads/preloads.rb +23 -0
  28. data/lib/jat/plugins/simple_api/lib/fields_param_parser.rb +20 -36
  29. data/lib/jat/plugins/simple_api/lib/map.rb +4 -5
  30. data/lib/jat/plugins/simple_api/lib/response.rb +1 -5
  31. data/lib/jat/plugins/simple_api/lib/response_piece.rb +1 -5
  32. data/lib/jat/plugins/simple_api/plugins/simple_api_activerecord/simple_api_activerecord.rb +23 -0
  33. data/lib/jat/plugins/{simple_api_lower_camel_case → simple_api/plugins/simple_api_lower_camel_case}/simple_api_lower_camel_case.rb +6 -2
  34. data/lib/jat/plugins/{simple_api_maps_cache → simple_api/plugins/simple_api_maps_cache}/simple_api_maps_cache.rb +6 -4
  35. data/lib/jat/plugins/{simple_api_activerecord → simple_api/plugins/simple_api_preloads}/lib/preloads.rb +1 -1
  36. data/lib/jat/plugins/simple_api/plugins/simple_api_preloads/simple_api_preloads.rb +38 -0
  37. data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/lib/fields_error.rb +0 -0
  38. data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/lib/validate_fields_param.rb +0 -0
  39. data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/simple_api_validate_params.rb +6 -2
  40. data/lib/jat/plugins/simple_api/simple_api.rb +8 -7
  41. data/lib/jat/plugins/to_str/to_str.rb +5 -1
  42. data/lib/jat/plugins/types/types.rb +55 -0
  43. data/lib/jat/plugins/validate_params/validate_params.rb +23 -0
  44. data/lib/jat/plugins.rb +41 -15
  45. data/lib/jat.rb +24 -17
  46. data/test/lib/jat/attribute_test.rb +8 -0
  47. data/test/lib/jat/plugins/activerecord/activerecord_test.rb +27 -0
  48. data/test/lib/jat/plugins/{_activerecord_preloads/_activerecord_preloads_test.rb → base_activerecord_preloads/base_activerecord_preloads_test.rb} +3 -3
  49. data/test/lib/jat/plugins/{_activerecord_preloads → base_activerecord_preloads}/lib/preloader_test.rb +2 -2
  50. data/test/lib/jat/plugins/{_camel_lower/_camel_lower_test.rb → base_lower_camel_case/base_lower_camel_case_test.rb} +2 -2
  51. data/test/lib/jat/plugins/{_preloads/_preloads_test.rb → base_preloads/base_preloads_test.rb} +2 -2
  52. data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/format_user_preloads_test.rb +3 -3
  53. data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/preloads_with_path_test.rb +2 -2
  54. data/test/lib/jat/plugins/json_api/json_api_test.rb +1 -9
  55. data/test/lib/jat/plugins/json_api/lib/fields_param_parser_test.rb +20 -12
  56. data/test/lib/jat/plugins/json_api/lib/include_param_parser_test.rb +25 -11
  57. data/test/lib/jat/plugins/json_api/lib/map_test.rb +132 -124
  58. data/test/lib/jat/plugins/json_api/lib/response_piece_test.rb +13 -0
  59. data/test/lib/jat/plugins/json_api/lib/response_test.rb +6 -1
  60. data/test/lib/jat/plugins/json_api_activerecord/json_api_activerecord_test.rb +4 -18
  61. data/test/lib/jat/plugins/{json_api_camel_lower/json_api_camel_lower_test.rb → json_api_lower_camel_case/json_api_lower_camel_case_test.rb} +6 -0
  62. data/test/lib/jat/plugins/json_api_preloads/json_api_preloads_test.rb +51 -0
  63. data/test/lib/jat/plugins/{json_api_activerecord → json_api_preloads}/lib/preloads_test.rb +8 -6
  64. data/test/lib/jat/plugins/json_api_validate_params/json_api_validate_params_test.rb +30 -6
  65. data/test/lib/jat/plugins/lower_camel_case/lower_camel_case_test.rb +27 -0
  66. data/test/lib/jat/plugins/maps_cache/maps_cache_test.rb +27 -0
  67. data/test/lib/jat/plugins/preloads/preloads_test.rb +27 -0
  68. data/test/lib/jat/plugins/simple_api/lib/fields_param_parser_test.rb +57 -43
  69. data/test/lib/jat/plugins/simple_api/lib/map_test.rb +90 -82
  70. data/test/lib/jat/plugins/simple_api/lib/response_piece_test.rb +13 -0
  71. data/test/lib/jat/plugins/simple_api/lib/response_test.rb +18 -12
  72. data/test/lib/jat/plugins/simple_api/simple_api_test.rb +33 -6
  73. data/test/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord_test.rb +4 -18
  74. data/test/lib/jat/plugins/{simple_api_camel_lower/simple_api_camel_lower_test.rb → simple_api_lower_camel_case/simple_api_lower_camel_case_test.rb} +7 -1
  75. data/test/lib/jat/plugins/{simple_api_activerecord → simple_api_preloads}/lib/preloads_test.rb +8 -8
  76. data/test/lib/jat/plugins/simple_api_preloads/simple_api_preloads_test.rb +51 -0
  77. data/test/lib/jat/plugins/simple_api_validate_params/simple_api_validate_params_test.rb +12 -0
  78. data/test/lib/jat/plugins/types/types_test.rb +83 -0
  79. data/test/lib/jat/plugins/validate_params/validate_params_test.rb +27 -0
  80. data/test/lib/jat/plugins_test.rb +88 -0
  81. data/test/test_helper.rb +8 -4
  82. metadata +98 -82
  83. data/lib/jat/plugins/json_api_activerecord/json_api_activerecord.rb +0 -31
  84. data/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord.rb +0 -31
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./lib/preloads"
4
-
5
- class Jat
6
- module Plugins
7
- module JsonApiActiverecord
8
- def self.before_load(jat_class, **opts)
9
- return if jat_class.plugin_used?(:json_api)
10
- raise Error, "Please load :json_api plugin first"
11
- end
12
-
13
- def self.load(jat_class, **_opts)
14
- jat_class.include(InstanceMethods)
15
- end
16
-
17
- def self.after_load(jat_class, **opts)
18
- jat_class.plugin :_preloads, **opts
19
- jat_class.plugin :_activerecord_preloads, **opts
20
- end
21
-
22
- module InstanceMethods
23
- def preloads
24
- @preloads ||= Preloads.call(self)
25
- end
26
- end
27
- end
28
-
29
- register_plugin(:json_api_activerecord, JsonApiActiverecord)
30
- end
31
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "./lib/preloads"
4
-
5
- class Jat
6
- module Plugins
7
- module SimpleApiActiverecord
8
- def self.before_load(jat_class, **_opts)
9
- return if jat_class.plugin_used?(:simple_api)
10
- raise Error, "Please load :simple_api plugin first"
11
- end
12
-
13
- def self.load(jat_class, **_opts)
14
- jat_class.include(InstanceMethods)
15
- end
16
-
17
- def self.after_load(jat_class, **opts)
18
- jat_class.plugin :_preloads, **opts
19
- jat_class.plugin :_activerecord_preloads, **opts
20
- end
21
-
22
- module InstanceMethods
23
- def preloads
24
- @preloads ||= Preloads.call(self)
25
- end
26
- end
27
- end
28
-
29
- register_plugin(:simple_api_activerecord, SimpleApiActiverecord)
30
- end
31
- end