ae_easy-router 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CODE_OF_CONDUCT.md +1 -1
  3. data/Gemfile +1 -1
  4. data/LICENSE +1 -1
  5. data/README.md +8 -4
  6. data/Rakefile +0 -10
  7. data/ae_easy-router.gemspec +10 -13
  8. data/lib/ae_easy/router.rb +3 -10
  9. metadata +30 -89
  10. data/doc/AeEasy.html +0 -117
  11. data/doc/AeEasy/Core.html +0 -117
  12. data/doc/AeEasy/Core/Plugin.html +0 -117
  13. data/doc/AeEasy/Core/Plugin/ParserBehavior.html +0 -196
  14. data/doc/AeEasy/Core/Plugin/SeederBehavior.html +0 -196
  15. data/doc/AeEasy/Router.html +0 -146
  16. data/doc/AeEasy/Router/Parser.html +0 -366
  17. data/doc/AeEasy/Router/Plugin.html +0 -117
  18. data/doc/AeEasy/Router/Plugin/Router.html +0 -778
  19. data/doc/AeEasy/Router/Seeder.html +0 -345
  20. data/doc/_index.html +0 -202
  21. data/doc/class_list.html +0 -51
  22. data/doc/css/common.css +0 -1
  23. data/doc/css/full_list.css +0 -58
  24. data/doc/css/style.css +0 -496
  25. data/doc/file.README.html +0 -92
  26. data/doc/file_list.html +0 -56
  27. data/doc/frames.html +0 -17
  28. data/doc/index.html +0 -92
  29. data/doc/js/app.js +0 -292
  30. data/doc/js/full_list.js +0 -216
  31. data/doc/js/jquery.js +0 -4
  32. data/doc/method_list.html +0 -131
  33. data/doc/top-level-namespace.html +0 -110
  34. data/lib/ae_easy/router/parser.rb +0 -48
  35. data/lib/ae_easy/router/plugin.rb +0 -8
  36. data/lib/ae_easy/router/plugin/router.rb +0 -74
  37. data/lib/ae_easy/router/seeder.rb +0 -38
  38. data/lib/ae_easy/router/version.rb +0 -6
  39. data/lib/ae_easy_override/core.rb +0 -6
  40. data/lib/ae_easy_override/core/plugin.rb +0 -9
  41. data/lib/ae_easy_override/core/plugin/parser_behavior.rb +0 -11
  42. data/lib/ae_easy_override/core/plugin/seeder_behavior.rb +0 -11
@@ -1,48 +0,0 @@
1
- module AeEasy
2
- module Router
3
- # Parser router designed to look over page_type for route to the right
4
- # parser class.
5
- class Parser
6
- include AeEasy::Router::Plugin::Router
7
-
8
- # Execute the parser class with options as described by router
9
- # configuration filtering by `page_type` and calling class's instance
10
- # `parse` method.
11
- #
12
- # @param [Hash] opts ({}) Parser initializer options (see
13
- # AeEasy::Core::Plugin::Parser).
14
- #
15
- # @raise [ArgumentError] `opts[:context]` is `nil`.
16
- # @raise [ArgumentError] `page_type` doesn't exists within routes.
17
- # @raise [NameError] A class with name equal to route's `class` attribute
18
- # doesn't exists.
19
- #
20
- # @note Requires the route class to implement `parse` instance method.
21
- def route opts = {}
22
- context = opts[:context]
23
- if context.nil?
24
- raise ArgumentError.new('Must send a context to the parser.')
25
- end
26
-
27
- page_type = context.page['page_type'].strip.downcase
28
- class_name = nil
29
- config['parser']['routes'].each do |item|
30
- # Look for page type
31
- next if item['page_type'].strip.downcase != page_type
32
-
33
- # Validate class name
34
- executor_class = get_class item['class']
35
- if executor_class.nil?
36
- raise NameError.new("Class \"#{item['class']}\" doesn't exists, check your ae_easy config file.")
37
- end
38
-
39
- executor_class.new(opts).parse
40
- return
41
- end
42
-
43
- # Page type is not routed, raise an error.
44
- raise ArgumentError.new("Page type \"#{page_type}\" is not routed, check your ae_easy config file.")
45
- end
46
- end
47
- end
48
- end
@@ -1,8 +0,0 @@
1
- require 'ae_easy/router/plugin/router'
2
-
3
- module AeEasy
4
- module Router
5
- module Plugin
6
- end
7
- end
8
- end
@@ -1,74 +0,0 @@
1
- module AeEasy
2
- module Router
3
- module Plugin
4
- # Base router providing the basic functionalities from a router.
5
- module Router
6
- include AeEasy::Core::Plugin::InitializeHook
7
-
8
- # Local configuration (see AeEasy::Core::Config).
9
- attr_reader :local_config
10
-
11
- # Hook to initialize router configuration.
12
- #
13
- # @param [Hash] opts ({}) Configuration options.
14
- # @option opts [AeEasy::Config::Local,nil] :config (nil) Configuration to
15
- # use.
16
- # @option opts [String] :config_file_path (nil) Configuration file to
17
- # load when no +:config+ was provided (see
18
- # AeEasy::Core::Config#file_path for default file).
19
- # @option opts [Boolean] :force (false) Will reload configuration file
20
- # when `true`.
21
- #
22
- # @note `opts[:config]` will be prioritize over
23
- # `opts[:config_file_path]` and `opts[:force]`.
24
- def initialize_hook_router_plugin_router opts = {}
25
- opts = {
26
- config: nil,
27
- config_file_path: nil,
28
- force: false
29
- }.merge opts
30
- @local_config = opts[:config]
31
- @local_config ||= AeEasy::Config::Local.new(
32
- file_path: opts[:config_file_path],
33
- force: opts[:force]
34
- )
35
- end
36
-
37
- # Initialize router and hooks.
38
- #
39
- # @param [Hash] opts ({}) Configuration options.
40
- #
41
- # @see #initialize_hook_router_plugin_router
42
- def initialize opts = {}
43
- initialize_hooks opts
44
- end
45
-
46
- # Router configuration.
47
- #
48
- # @return [Hash]
49
- def config
50
- local_config['router']
51
- end
52
-
53
- # Validates when a class name exists
54
- #
55
- # @param [String] name Class name to validate.
56
- #
57
- # @return [Boolean] `true` when exists, else `false`.
58
- def class_defined? name
59
- Object.const_defined? name
60
- end
61
-
62
- # Get a class from a class name.
63
- #
64
- # @param [String] name Class name to validate.
65
- #
66
- # @return [Class,nil] `nil` when class doesn't exists.
67
- def get_class name
68
- return nil unless class_defined? name
69
- Object.const_get name
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,38 +0,0 @@
1
- module AeEasy
2
- module Router
3
- # Seeder router designed to execute all seeders classes.
4
- class Seeder
5
- include AeEasy::Router::Plugin::Router
6
-
7
- # Execute the seeder class with options as described by router
8
- # configuration and calling class's instance `seed` method.
9
- #
10
- # @param [Hash] opts ({}) Seeder initializer options (see
11
- # AeEasy::Core::Plugin::Seeder).
12
- #
13
- # @raise [ArgumentError] `opts[:context]` is `nil`.
14
- # @raise [ArgumentError] `page_type` doesn't exists within routes.
15
- # @raise [NameError] A class with name equal to route's `class` attribute
16
- # doesn't exists.
17
- #
18
- # @note Requires the route class to implement `seed` instance method.
19
- def route opts = {}
20
- context = opts[:context]
21
- if opts[:context].nil?
22
- raise ArgumentError.new('Must send a context to the seeder.')
23
- end
24
-
25
- class_name = nil
26
- config['seeder']['routes'].each do |item|
27
- # Validate class name
28
- executor_class = get_class item['class']
29
- if executor_class.nil?
30
- raise NameError.new("Class \"#{item['class']}\" doesn't exists, check your ae_easy config file.")
31
- end
32
-
33
- executor_class.new(opts).seed
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,6 +0,0 @@
1
- module AeEasy
2
- module Router
3
- # Gem version
4
- VERSION = "0.0.2"
5
- end
6
- end
@@ -1,6 +0,0 @@
1
- require 'ae_easy/core/plugin'
2
-
3
- module AeEasy
4
- module Core
5
- end
6
- end
@@ -1,9 +0,0 @@
1
- require 'ae_easy/core/plugin/seeder_behavior'
2
- require 'ae_easy/core/plugin/parser_behavior'
3
-
4
- module AeEasy
5
- module Core
6
- module Plugin
7
- end
8
- end
9
- end
@@ -1,11 +0,0 @@
1
- module AeEasy
2
- module Core
3
- module Plugin
4
- module ParserBehavior
5
- def parse
6
- raise NotImplementedError.new('Must implement "parse" method.')
7
- end
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- module AeEasy
2
- module Core
3
- module Plugin
4
- module SeederBehavior
5
- def seed
6
- raise NotImplementedError.new('Must implement "seed" method.')
7
- end
8
- end
9
- end
10
- end
11
- end