eworld 2.2.2 → 2.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 879bb0b10067a69b9738caff5862c2d5b62619d6
4
- data.tar.gz: 1f4ff588328efd4eff24c665fca21a05f305b724
3
+ metadata.gz: 2011a169fec8d083f237af3e0e2addf03dae9578
4
+ data.tar.gz: 16da5f8ecc95470d7684b4f6a33828b55a582739
5
5
  SHA512:
6
- metadata.gz: 8f373fe9b24e21c171691c24a44926b17b3fb02f3ea540fda7b208de68302e81f80e0f15da252790e0dd54e268691f5a83cdf3e6c9290675104cd22319450589
7
- data.tar.gz: 6ddef15e87a5ce36200f500e706348c4a6e79435280bdafab5d5307c2c2c0bf3d94d319cb71f370fe1d6fd8ec12f017a5692c0ac4f66c940824c12496a362704
6
+ metadata.gz: cf1208be1aa917d58cdf51cc2011268f625feb3a3e14f8fd92571f69f714b30059d0d24b79dbd890ef072dfa2b95c65a8f537a25ca8a7c6ee618a35cda846322
7
+ data.tar.gz: 5c1714ad25ed5dfce2dba8707bfb8f24ffc0c5be68132730c498dad026a32133c0bac3fcf89ecb62429fef3c7b92c6b90fb724097c24ca9d7084ef06d3b25073
@@ -9,7 +9,6 @@ require 'writers/base_writer'
9
9
 
10
10
  Dir["#{File.dirname(__FILE__)}/core/**/*.rb"].each { |file| load(file) }
11
11
  Dir["#{File.dirname(__FILE__)}/routes/**/*.rb"].each { |file| load(file) }
12
- Dir["#{File.dirname(__FILE__)}/rules/**/*.rb"].each { |file| load(file) }
13
12
  Dir["#{File.dirname(__FILE__)}/scanners/**/*.rb"].each { |file| load(file) }
14
13
  Dir["#{File.dirname(__FILE__)}/writers/**/*.rb"].each { |file| load(file) unless file =~ /\/(base_writer)\.rb\z/ }
15
14
 
@@ -58,19 +57,6 @@ TEMPLATE
58
57
  end
59
58
  end
60
59
 
61
- # s - SCAN
62
- if is_albert_mac
63
- app.command :scan, :aliases => [:s] do |scan|
64
- scan.summary 'Scan the codebase'
65
- scan.options do |opts|
66
- opts.opt :project, 'Specify Project ID', :short => '-p', :long => '--project', :type => :string
67
- end
68
- scan.action do |opts, args|
69
- AppCommand::Scan.new(opts, args).execute
70
- end
71
- end
72
- end
73
-
74
60
  # U - UPDATE
75
61
  app.command :update, :aliases => [:U] do |update|
76
62
  update.summary 'Check for updates'
@@ -79,6 +65,19 @@ TEMPLATE
79
65
  end
80
66
  end
81
67
 
68
+ # v - VALIDATE
69
+ if is_albert_mac
70
+ app.command :validate, :aliases => [:v] do |validate|
71
+ validate.summary 'Valdiate the codebase'
72
+ validate.options do |opts|
73
+ opts.opt :project, 'Specify Project ID', :short => '-p', :long => '--project', :type => :string
74
+ end
75
+ validate.action do |opts, args|
76
+ AppCommand::Validate.new(opts, args).execute
77
+ end
78
+ end
79
+ end
80
+
82
81
  # x - CONFIG
83
82
  app.command :config, :aliases => [:x] do |config|
84
83
  config.summary 'Setup your configuration file'
@@ -45,17 +45,6 @@ module AppCommand
45
45
 
46
46
  puts if @verbose
47
47
 
48
- td = @ui_project[Blufin::Projects::TRANSIENT_DATA]
49
- root = Blufin::Strings::remove_surrounding_slashes(td[Blufin::Projects::CG_QUASAR_ROOT])
50
- js = Blufin::Strings::remove_surrounding_slashes(td[Blufin::Projects::CG_QUASAR_JS])
51
-
52
- Blufin::Terminal::execute_proc("Scanning: #{Blufin::Terminal::format_highlight('Javascript')}", Proc.new {
53
- eb = @errors.length
54
- @js, je = Blufin::ScannerJs::scan("#{@project_path}/#{root}/#{js}")
55
- @errors.concat(je)
56
- eb == @errors.length
57
- }, verbose: @verbose)
58
-
59
48
  Blufin::Terminal::execute_proc("Scanning: #{Blufin::Terminal::format_highlight('Routes')}", Proc.new {
60
49
  eb = @errors.length
61
50
  @routes_to_write, re = EWorld::RouteScanner::scan(@ui_project)
@@ -63,13 +52,6 @@ module AppCommand
63
52
  eb == @errors.length
64
53
  }, verbose: @verbose)
65
54
 
66
- Blufin::Terminal::execute_proc("Scanning: #{Blufin::Terminal::format_highlight('Controllers')}", Proc.new {
67
- eb = @errors.length
68
- @controllers, ce = EWorld::ControllerScanner::scan(@api_project)
69
- @errors.concat(ce)
70
- eb == @errors.length
71
- }, verbose: @verbose)
72
-
73
55
  puts if @errors.any? && @verbose
74
56
 
75
57
  Blufin::ScannerError::output_cli(@errors, false) if @errors.any?
@@ -84,31 +66,6 @@ module AppCommand
84
66
  @overwritten.concat(ro)
85
67
  }, verbose: @verbose)
86
68
 
87
- Blufin::Terminal::execute_proc("Processing: #{Blufin::Terminal::format_highlight('Controllers')}", Proc.new {
88
- cg, co = EWorld::ControllerWriter::write(@api_project, @ui_project, @controllers)
89
- @generated.concat(cg)
90
- @overwritten.concat(co)
91
-
92
- }, verbose: @verbose)
93
-
94
- Blufin::Terminal::execute_proc("Processing: #{Blufin::Terminal::format_highlight('Services')}", Proc.new {
95
- sg, so = EWorld::ServiceWriter::write(@api_project, @ui_project, @controllers)
96
- @generated.concat(sg)
97
- @overwritten.concat(so)
98
- }, verbose: @verbose)
99
-
100
- Blufin::Terminal::execute_proc("Processing: #{Blufin::Terminal::format_highlight('API Docs (JSON)')}", Proc.new {
101
- ag, ao = EWorld::ApiDocsWriter::write(@api_project, @ui_project, @controllers)
102
- @generated.concat(ag)
103
- @overwritten.concat(ao)
104
- }, verbose: @verbose)
105
-
106
- Blufin::Terminal::execute_proc("Processing: #{Blufin::Terminal::format_highlight('JS Docs (JSON)')}", Proc.new {
107
- jg, jo = EWorld::JsDocsWriter::write(@api_project, @ui_project, @js)
108
- @generated.concat(jg)
109
- @overwritten.concat(jo)
110
- }, verbose: @verbose)
111
-
112
69
  # Reformat front-end.
113
70
  Blufin::Terminal::execute_proc('Re-formatting UI codebase', Proc.new {
114
71
  Blufin::Terminal::execute('git add .', @project_path_ui, verbose: false)
@@ -1,6 +1,6 @@
1
1
  module AppCommand
2
2
 
3
- class Scan < ::Convoy::ActionCommand::Base
3
+ class Validate < ::Convoy::ActionCommand::Base
4
4
 
5
5
  def execute
6
6
 
@@ -68,23 +68,11 @@ module AppCommand
68
68
  end
69
69
  end
70
70
 
71
- run_js_rules(@js) unless @js.nil?
72
-
73
71
  # Output Errors (if any).
74
72
  Blufin::ScannerError::output_cli(@errors)
75
73
 
76
74
  end
77
75
 
78
- private
79
-
80
- # Runs all the rules for the JS files.
81
- # @return void
82
- def run_js_rules(data)
83
-
84
- @errors = EWorld::RuleJsParameters::run(data, @errors)
85
-
86
- end
87
-
88
76
  end
89
77
 
90
78
  end
@@ -165,7 +165,7 @@ module EWorld
165
165
  end
166
166
 
167
167
  # TODO - If non-tabs, must have FULLPATH, CODE, TITLE
168
- # TODO - If tabs, must have ICON, TAB_PARENT
168
+ # TODO - If tabs, must have ICON, TAB_PARENT (AND TAB PARENT MUST MATCH PARENT).
169
169
 
170
170
  expected_name = Blufin::Strings::remove_surrounding_slashes("#{parent_path}/#{child[PATH]}").gsub('/', '-')
171
171
  # Handle special case for dashboard.
@@ -1 +1 @@
1
- EWORLD_VERSION = '2.2.2'
1
+ EWORLD_VERSION = '2.3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eworld
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Albert Rannetsperger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: blufin-lib
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.2.2
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.2.2
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: columnist
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,12 +66,7 @@ files:
66
66
  - lib/core/opt.rb
67
67
  - lib/eworld.rb
68
68
  - lib/routes/generate.rb
69
- - lib/routes/scan.rb
70
- - lib/rules/js/rule_js_parameters.rb
71
- - lib/scanners/controller_scanner.rb
72
- - lib/scanners/entity_scanner.rb
73
- - lib/scanners/permission_scanner.rb
74
- - lib/scanners/queue_scanner.rb
69
+ - lib/routes/validate.rb
75
70
  - lib/scanners/route_scanner.rb
76
71
  - lib/version.rb
77
72
  - lib/writers/api_docs_writer.rb
@@ -85,8 +80,6 @@ files:
85
80
  - lib/writers/service_writer.rb
86
81
  - opt/config/schema.yml
87
82
  - opt/config/template.yml
88
- - opt/schema/controllers.yml
89
- - opt/schema/database.yml
90
83
  - opt/schema/routes.yml
91
84
  homepage: http://rubygems.org/gems/eworld
92
85
  licenses:
@@ -1,60 +0,0 @@
1
- module EWorld
2
-
3
- class RuleJsParameters
4
-
5
- # This rule validate JS method parameters.
6
- # It checks that the parameters match the actual methods and that we have a description/return type.
7
- # @return Array (of errors)
8
- def self.run(js_data, errors)
9
- raise RuntimeError, "Expected Array, instead got: #{errors.class}" unless errors.is_a?(Array)
10
- @errors = errors
11
- js_data.each { |data| handler(data[1][:file], data[1]) }
12
- @errors
13
- end
14
-
15
- private
16
-
17
- # @return void
18
- def self.handler(file, data)
19
-
20
- @file = file
21
-
22
- data[:methods].each do |method_name, method_data|
23
-
24
- begin
25
-
26
- @line = method_data[:line]
27
- @line_number = method_data[:line_number]
28
-
29
- # Skip private methods.
30
- next if method_data[:private]
31
-
32
- expected = method_data[:params].keys
33
- actual = method_data[:docs][:params].keys
34
-
35
- # Throw error if params don't match comments.
36
- raise RuntimeError, "#{method_name} \xe2\x80\x94 Param docs are missing, corrupted or incorrect." if expected.to_s != actual.to_s
37
-
38
- # Make sure we have all the comment doc stuff we need.
39
- if method_data[:docs].is_a?(Hash)
40
- missing_items = []
41
- missing_items << 'description' unless method_data[:docs].has_key?(:description)
42
- missing_items << 'return' unless method_data[:docs].has_key?(:return)
43
- if missing_items.any?
44
- @line = "\xe2\x80\x94"
45
- @line_number = @line_number + 1
46
- raise RuntimeError, "Comment docs are missing \xe2\x86\x92 #{missing_items.join(', ')}"
47
- end
48
- end
49
-
50
- rescue RuntimeError => e
51
- @errors << Blufin::ScannerError.new(@file, @line, @line_number, e.message)
52
- end
53
-
54
- end
55
-
56
- end
57
-
58
- end
59
-
60
- end
@@ -1,137 +0,0 @@
1
- module EWorld
2
-
3
- class ControllerScanner
4
-
5
- SCHEMA_FILE = "#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/schema/controllers.yml"
6
-
7
- # Responsible for scanning the .codegen/controllers/[MULTIPLE].yml file(s).
8
- # @return Array
9
- def self.scan(api_project)
10
-
11
- # TODO - Need to inject permissions.
12
- # TODO - Need to inject entities.
13
-
14
- raise RuntimeError, "Expected project type to be: #{Blufin::Projects::TYPE_API_SIMPLE}, instead got: #{api_project[Blufin::Projects::TYPE]}" unless api_project[Blufin::Projects::TYPE] == Blufin::Projects::TYPE_API_SIMPLE
15
- @errors = []
16
- @controllers = {}
17
- @classes_seen = []
18
- @paths_seen = []
19
- begin
20
- @project_path = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID])
21
- @project_path_api = Blufin::Projects::get_project_path(api_project[Blufin::Projects::PROJECT_ID], true)
22
- @project_transient_api = api_project[Blufin::Projects::TRANSIENT_DATA]
23
- @controller_path = "#{EWorld::BaseWriter::get_java_path_for(@project_path, @project_transient_api['ControllerPath'])}/#{EWorld::ControllerWriter::PACKAGE_NAME}"
24
- @service_path = "#{EWorld::BaseWriter::get_java_path_for(@project_path, @project_transient_api['ServicePath'])}/#{EWorld::ServiceWriter::PACKAGE_NAME}"
25
- controller_yml_path = "#{@project_path}/.#{Blufin::Projects::CODEGEN}/controllers"
26
- # If path not found, bomb-out immediately.
27
- unless Blufin::Files::path_exists(controller_yml_path)
28
- @errors << Blufin::ScannerError::add_error(nil, "YML Controller path not found: #{controller_yml_path}")
29
- return @errors, {}
30
- end
31
- # If the parent path where controllers/services should live doesn't exists -- bomb-out!
32
- [@controller_path, @service_path].each do |path|
33
- unless Blufin::Files::path_exists(path)
34
- @errors << Blufin::ScannerError::add_error(nil, "Path not found: #{path}")
35
- return {}, @errors
36
- end
37
- end
38
- # Loop all the YML files. Each file = 1 controller.
39
- Blufin::Files::get_files_in_dir(controller_yml_path).each do |controller_file|
40
- @file = controller_file
41
- # Get extension + controller root path.
42
- fs = @file.split('.')
43
- @root_path = fs[fs.length - 2].split('/')
44
- @root_path = @root_path[@root_path.length - 1]
45
- @class_name = "#{Blufin::Strings::snake_case_to_camel_case(@root_path.gsub('-', '_'))}"
46
- ext = fs[fs.length - 1]
47
- # Make sure we don't have duplicate class names.
48
- @errors << Blufin::ScannerError::add_error(@file, "Duplicate class: #{@class_name}") if @classes_seen.include?(@class_name.upcase)
49
- @classes_seen << @class_name.upcase
50
- # Make sure we have validly named YML file(s).
51
- @errors << Blufin::ScannerError::add_error(@file, "Expected extension to be lowercase 'yml', instead got: #{ext}") if ext.downcase != 'yml'
52
- unless ext.downcase == 'yml'
53
- @errors << Blufin::ScannerError::add_error(@file, "Expected extension to be 'yml', instead got: #{ext}")
54
- next
55
- end
56
- controller_yml = Blufin::Yml::read_file(@file, SCHEMA_FILE)
57
- # Validate file. If errors, go to next file.
58
- next unless validate_file(controller_yml)
59
- controller_yml['RootPath'] = Blufin::Strings::remove_surrounding_slashes(@root_path)
60
- @controllers[@class_name] = controller_yml
61
- end
62
- rescue => e
63
- Blufin::Terminal::print_exception(e)
64
- end
65
- return @controllers, @errors
66
- end
67
-
68
- private
69
-
70
- # Put all validation here. If any errors get added, this method returns FALSE and the loop at the top skips processing.
71
- # @return bool
72
- def self.validate_file(data)
73
- error_count_before = @errors.length
74
- if data.has_key?('EndPoints') && data['EndPoints'].is_a?(Array)
75
- data['EndPoints'].each do |resource|
76
- path = resource['Path']
77
- path_full = "/#{Blufin::Strings::remove_surrounding_slashes(@root_path)}/#{Blufin::Strings::remove_surrounding_slashes(resource['Path'])}"
78
- path_downcase = path_full.downcase
79
- method = resource['Method']
80
- path_method = "#{method} #{path_downcase}"
81
- prefix = "#{path_full} \xe2\x80\x94 "
82
- # Make sure path does not have trailing/preceding slashes.
83
- @errors << Blufin::ScannerError::add_error(@file, "#{prefix}Path should not have trailing/preceding slash(es): #{path}") if path =~ /^\// || path =~ /\/$/
84
- # Make sure paths are always lowercase.
85
- @errors << Blufin::ScannerError::add_error(@file, "#{prefix}Path(s) must be lowercase, found: #{path_full}") if path_full != path_downcase
86
- path_full.downcase!
87
- # Make sure there are no duplicate permissions.
88
- if resource.has_key?('Permissions')
89
- perms = []
90
- resource['Permissions'].each do |perm|
91
- if perms.include?(perm)
92
- @errors << Blufin::ScannerError::add_error(@file, "#{prefix}Duplicate permission(s): #{perm}")
93
- next
94
- end
95
- perms << perm
96
- end
97
- end
98
- # Make sure we don't have duplicate paths.
99
- @errors << Blufin::ScannerError::add_error(@file, "Duplicate end-point: #{path_method}") if @paths_seen.include?(path_method)
100
- @paths_seen << path_method
101
-
102
- if %w(POST PUT).include?(method)
103
-
104
- # TODO NOW - Validate POST/PUT stuff.
105
-
106
- end
107
-
108
- # TODO NOW - Validate Service/Method exists.
109
- # TODO NOW - Validate Request Params match service method.
110
- # TODO NOW - What about abstract controller calls for entities?
111
-
112
- end
113
- end
114
-
115
- service_file = "#{@service_path}/#{@class_name}Service.java"
116
- if Blufin::Files::file_exists(service_file)
117
-
118
- # TODO - Must scan file here ...
119
-
120
- java_data, errors = Blufin::ScannerJava::scan_file(service_file)
121
-
122
- # TODO - REMOVE
123
- # puts
124
- # puts java_data.to_yaml
125
- # puts errors.to_yaml
126
-
127
- @errors.concat(errors)
128
-
129
- end
130
-
131
- # If errors have been added, return FALSE.
132
- @errors.length == error_count_before
133
- end
134
-
135
- end
136
-
137
- end
@@ -1,15 +0,0 @@
1
- module EWorld
2
-
3
- class EntityScanner
4
-
5
- # Responsible for scanning the .codegen/entities/[MULTIPLE].yml file.
6
- # @return Array
7
- def self.scan(project)
8
-
9
- # TODO - Need to inject permissions.
10
-
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module EWorld
2
-
3
- class PermissionScanner
4
-
5
- # Responsible for scanning the .codegen/permissions/permissions.yml file.
6
- # @return Array
7
- def self.scan(project)
8
-
9
- # TODO NOW - FINISH THIS!
10
-
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,15 +0,0 @@
1
- module EWorld
2
-
3
- class QueueScanner
4
-
5
- # Responsible for scanning the .codegen/queue/queue.yml file.
6
- # @return Array
7
- def self.scan(project)
8
-
9
- # TODO NOW - FINISH THIS!
10
-
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,32 +0,0 @@
1
- type: map
2
- mapping:
3
- EndPoints:
4
- type: seq
5
- sequence:
6
- - type: map
7
- mapping:
8
- Path:
9
- required: true
10
- pattern: /^[a-z0-9\-\/]+$/
11
- Method:
12
- required: true
13
- enum: [GET, POST, PUT, PATCH, DELETE]
14
- RequestParams:
15
- type: seq
16
- sequence:
17
- - type: map
18
- mapping:
19
- Name:
20
- required: true
21
- pattern: /^[A-Za-z0-9]+$/
22
- Type:
23
- required: true
24
- enum: [String]
25
- Required:
26
- required: true
27
- type: bool
28
- Permissions:
29
- type: seq
30
- sequence:
31
- - type: str
32
- pattern: /^[A-Z0-9_]+$/
File without changes