rails_execution 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-version +1 -0
  3. data/Gemfile +8 -0
  4. data/Gemfile.lock +129 -0
  5. data/LICENSE.txt +21 -0
  6. data/README.md +35 -0
  7. data/Rakefile +3 -0
  8. data/app/assets/images/executions/approved.png +0 -0
  9. data/app/assets/images/executions/favicon.png +0 -0
  10. data/app/assets/images/executions/logo.png +0 -0
  11. data/app/assets/images/executions/rejected.png +0 -0
  12. data/app/assets/images/executions/robot.png +0 -0
  13. data/app/assets/javascripts/executions/ace.min.js +1 -0
  14. data/app/assets/javascripts/executions/ace.modes.ruby.min.js +1 -0
  15. data/app/assets/javascripts/executions/ace.theme-solarized_dark.min.js +1 -0
  16. data/app/assets/javascripts/executions/base.js +1 -0
  17. data/app/assets/javascripts/executions/bootstrap.5.2.1.min.js +6 -0
  18. data/app/assets/javascripts/executions/chart.min.js +13 -0
  19. data/app/assets/javascripts/executions/comments.js +43 -0
  20. data/app/assets/javascripts/executions/easymde.min.js +7 -0
  21. data/app/assets/javascripts/executions/events.js +8 -0
  22. data/app/assets/javascripts/executions/highlight.min.js +1198 -0
  23. data/app/assets/javascripts/executions/highlight.ruby.min.js +51 -0
  24. data/app/assets/javascripts/executions/jquery-3.6.1.min.js +2 -0
  25. data/app/assets/javascripts/executions/marked.min.js +6 -0
  26. data/app/assets/javascripts/executions/rails.js +565 -0
  27. data/app/assets/javascripts/executions/select2.min.js +2 -0
  28. data/app/assets/stylesheets/executions/base.css +3 -0
  29. data/app/assets/stylesheets/executions/bootstrap-icons.css +1869 -0
  30. data/app/assets/stylesheets/executions/comments.css +14 -0
  31. data/app/assets/stylesheets/executions/easymde.min.css +7 -0
  32. data/app/assets/stylesheets/executions/fonts.css +4 -0
  33. data/app/assets/stylesheets/executions/highlight.min.css +9 -0
  34. data/app/assets/stylesheets/executions/modify.scss +278 -0
  35. data/app/assets/stylesheets/executions/select2.min.css +1 -0
  36. data/app/controllers/rails_execution/base_controller.rb +16 -0
  37. data/app/controllers/rails_execution/comments_controller.rb +34 -0
  38. data/app/controllers/rails_execution/dashboards_controller.rb +27 -0
  39. data/app/controllers/rails_execution/tasks_controller.rb +175 -0
  40. data/app/helpers/rails_execution/base_helper.rb +14 -0
  41. data/app/helpers/rails_execution/policy_helper.rb +64 -0
  42. data/app/helpers/rails_execution/rendering_helper.rb +94 -0
  43. data/app/models/rails_execution/activity.rb +8 -0
  44. data/app/models/rails_execution/comment.rb +8 -0
  45. data/app/models/rails_execution/task.rb +71 -0
  46. data/app/models/rails_execution/task_review.rb +14 -0
  47. data/app/views/layouts/execution.html.haml +16 -0
  48. data/app/views/rails_execution/comments/_comment.html.haml +23 -0
  49. data/app/views/rails_execution/comments/create.js.haml +6 -0
  50. data/app/views/rails_execution/comments/update.js.haml +2 -0
  51. data/app/views/rails_execution/dashboards/charts/_insights.html.haml +27 -0
  52. data/app/views/rails_execution/dashboards/home.html.haml +24 -0
  53. data/app/views/rails_execution/dashboards/insights.json.jbuilder +8 -0
  54. data/app/views/rails_execution/shared/_flash.html.haml +7 -0
  55. data/app/views/rails_execution/shared/_header.html.haml +13 -0
  56. data/app/views/rails_execution/shared/_paging.html.haml +35 -0
  57. data/app/views/rails_execution/tasks/_actions.html.haml +12 -0
  58. data/app/views/rails_execution/tasks/_activities.html.haml +22 -0
  59. data/app/views/rails_execution/tasks/_attachment_file_fields.html.haml +3 -0
  60. data/app/views/rails_execution/tasks/_attachment_files.html.haml +12 -0
  61. data/app/views/rails_execution/tasks/_comments.html.haml +15 -0
  62. data/app/views/rails_execution/tasks/_form.html.haml +55 -0
  63. data/app/views/rails_execution/tasks/_form_scripts.html.haml +34 -0
  64. data/app/views/rails_execution/tasks/_new_comment.html.haml +8 -0
  65. data/app/views/rails_execution/tasks/_reviewers.html.haml +23 -0
  66. data/app/views/rails_execution/tasks/_script_content.html.haml +15 -0
  67. data/app/views/rails_execution/tasks/_show_scripts.html.haml +27 -0
  68. data/app/views/rails_execution/tasks/_status.html.haml +19 -0
  69. data/app/views/rails_execution/tasks/_task.html.haml +18 -0
  70. data/app/views/rails_execution/tasks/_tips.html.haml +18 -0
  71. data/app/views/rails_execution/tasks/closed.html.haml +12 -0
  72. data/app/views/rails_execution/tasks/completed.html.haml +12 -0
  73. data/app/views/rails_execution/tasks/edit.html.haml +3 -0
  74. data/app/views/rails_execution/tasks/index.html.haml +12 -0
  75. data/app/views/rails_execution/tasks/new.html.haml +3 -0
  76. data/app/views/rails_execution/tasks/show.html.haml +38 -0
  77. data/config/routes.rb +26 -0
  78. data/lib/generators/rails_execution/file_upload_generator.rb +18 -0
  79. data/lib/generators/rails_execution/install_generator.rb +36 -0
  80. data/lib/generators/rails_execution/templates/config.rb.tt +63 -0
  81. data/lib/generators/rails_execution/templates/file_reader.rb.tt +14 -0
  82. data/lib/generators/rails_execution/templates/file_uploader.rb.tt +11 -0
  83. data/lib/generators/rails_execution/templates/install.rb.tt +48 -0
  84. data/lib/rails_execution/app_model.rb +14 -0
  85. data/lib/rails_execution/config.rb +73 -0
  86. data/lib/rails_execution/engine.rb +24 -0
  87. data/lib/rails_execution/error.rb +6 -0
  88. data/lib/rails_execution/files/reader.rb +49 -0
  89. data/lib/rails_execution/files/uploader.rb +42 -0
  90. data/lib/rails_execution/services/approvement.rb +41 -0
  91. data/lib/rails_execution/services/execution.rb +87 -0
  92. data/lib/rails_execution/services/executor.rb +24 -0
  93. data/lib/rails_execution/services/paging.rb +35 -0
  94. data/lib/rails_execution/services/syntax_checker.rb +38 -0
  95. data/lib/rails_execution/version.rb +5 -0
  96. data/lib/rails_execution.rb +24 -0
  97. metadata +157 -0
@@ -0,0 +1,24 @@
1
+ module RailsExecution
2
+ module Services
3
+ class Executor
4
+
5
+ def initialize(task)
6
+ @task = task
7
+ @file_reader = ::RailsExecution.configuration.file_reader.new(task)
8
+ end
9
+
10
+ def call
11
+ raise NotImplementedError
12
+ end
13
+
14
+ private
15
+
16
+ attr_reader :task
17
+
18
+ def file(name)
19
+ @file_reader.get_file(name)
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,35 @@
1
+ module RailsExecution
2
+ module Services
3
+ class Paging
4
+
5
+ def initialize(per_page: nil, page: 1)
6
+ @per_page = per_page.presence || RailsExecution.configuration.per_page.to_i
7
+ @per_page = [@per_page, 1].max
8
+ @page = [page.to_i, 1].max
9
+ end
10
+
11
+ def call(relation)
12
+ total_count = relation.count
13
+ relation = relation.offset(offset_paging).limit(per_page)
14
+ inject_paging_data(relation, total_count)
15
+ return relation
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :per_page
21
+ attr_reader :page
22
+
23
+ def offset_paging
24
+ page * per_page - per_page
25
+ end
26
+
27
+ def inject_paging_data(relation, total_count)
28
+ current_page, total_pages = @page, (total_count.to_f / @per_page).ceil
29
+ relation.define_singleton_method(:re_current_page) { current_page }
30
+ relation.define_singleton_method(:re_total_pages) { total_pages }
31
+ end
32
+
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ module RailsExecution
2
+ module Services
3
+ class SyntaxChecker
4
+ OK_MESSAGE = 'Syntax OK'
5
+
6
+ def initialize(code)
7
+ @code = code
8
+ end
9
+
10
+ def call
11
+ return false if code.blank?
12
+
13
+ init_tempfile
14
+ return is_ok?
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :code
20
+
21
+ def init_tempfile
22
+ @file = ::Tempfile.new('syntax_checker')
23
+ @file.binmode
24
+ @file.write(code)
25
+ @file.flush
26
+ @file
27
+ end
28
+
29
+ def is_ok?
30
+ result = `cat #{@file.path} | ruby -c`
31
+ result.strip == OK_MESSAGE
32
+ rescue SyntaxError
33
+ return false
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsExecution
4
+ VERSION = '0.1.1'
5
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_execution/error'
4
+ require 'rails_execution/config'
5
+ require 'rails_execution/engine'
6
+ require 'rails_execution/version'
7
+ require 'rails_execution/app_model'
8
+ require 'rails_execution/files/reader'
9
+ require 'rails_execution/files/uploader'
10
+ require 'rails_execution/services/paging'
11
+ require 'rails_execution/services/executor'
12
+ require 'rails_execution/services/execution'
13
+ require 'rails_execution/services/approvement'
14
+ require 'rails_execution/services/syntax_checker'
15
+
16
+ module RailsExecution
17
+
18
+ def self.configuration
19
+ @configuration ||= ::RailsExecution::Config.new
20
+ yield @configuration if block_given?
21
+ @configuration
22
+ end
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_execution
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Khoa Nguyen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-11-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: haml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: 'Rails Engine: Execute the script for migration, cleanup data and specially
28
+ case'
29
+ email:
30
+ - thanhkhoait@gmail.com
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".ruby-version"
36
+ - Gemfile
37
+ - Gemfile.lock
38
+ - LICENSE.txt
39
+ - README.md
40
+ - Rakefile
41
+ - app/assets/images/executions/approved.png
42
+ - app/assets/images/executions/favicon.png
43
+ - app/assets/images/executions/logo.png
44
+ - app/assets/images/executions/rejected.png
45
+ - app/assets/images/executions/robot.png
46
+ - app/assets/javascripts/executions/ace.min.js
47
+ - app/assets/javascripts/executions/ace.modes.ruby.min.js
48
+ - app/assets/javascripts/executions/ace.theme-solarized_dark.min.js
49
+ - app/assets/javascripts/executions/base.js
50
+ - app/assets/javascripts/executions/bootstrap.5.2.1.min.js
51
+ - app/assets/javascripts/executions/chart.min.js
52
+ - app/assets/javascripts/executions/comments.js
53
+ - app/assets/javascripts/executions/easymde.min.js
54
+ - app/assets/javascripts/executions/events.js
55
+ - app/assets/javascripts/executions/highlight.min.js
56
+ - app/assets/javascripts/executions/highlight.ruby.min.js
57
+ - app/assets/javascripts/executions/jquery-3.6.1.min.js
58
+ - app/assets/javascripts/executions/marked.min.js
59
+ - app/assets/javascripts/executions/rails.js
60
+ - app/assets/javascripts/executions/select2.min.js
61
+ - app/assets/stylesheets/executions/base.css
62
+ - app/assets/stylesheets/executions/bootstrap-icons.css
63
+ - app/assets/stylesheets/executions/comments.css
64
+ - app/assets/stylesheets/executions/easymde.min.css
65
+ - app/assets/stylesheets/executions/fonts.css
66
+ - app/assets/stylesheets/executions/highlight.min.css
67
+ - app/assets/stylesheets/executions/modify.scss
68
+ - app/assets/stylesheets/executions/select2.min.css
69
+ - app/controllers/rails_execution/base_controller.rb
70
+ - app/controllers/rails_execution/comments_controller.rb
71
+ - app/controllers/rails_execution/dashboards_controller.rb
72
+ - app/controllers/rails_execution/tasks_controller.rb
73
+ - app/helpers/rails_execution/base_helper.rb
74
+ - app/helpers/rails_execution/policy_helper.rb
75
+ - app/helpers/rails_execution/rendering_helper.rb
76
+ - app/models/rails_execution/activity.rb
77
+ - app/models/rails_execution/comment.rb
78
+ - app/models/rails_execution/task.rb
79
+ - app/models/rails_execution/task_review.rb
80
+ - app/views/layouts/execution.html.haml
81
+ - app/views/rails_execution/comments/_comment.html.haml
82
+ - app/views/rails_execution/comments/create.js.haml
83
+ - app/views/rails_execution/comments/update.js.haml
84
+ - app/views/rails_execution/dashboards/charts/_insights.html.haml
85
+ - app/views/rails_execution/dashboards/home.html.haml
86
+ - app/views/rails_execution/dashboards/insights.json.jbuilder
87
+ - app/views/rails_execution/shared/_flash.html.haml
88
+ - app/views/rails_execution/shared/_header.html.haml
89
+ - app/views/rails_execution/shared/_paging.html.haml
90
+ - app/views/rails_execution/tasks/_actions.html.haml
91
+ - app/views/rails_execution/tasks/_activities.html.haml
92
+ - app/views/rails_execution/tasks/_attachment_file_fields.html.haml
93
+ - app/views/rails_execution/tasks/_attachment_files.html.haml
94
+ - app/views/rails_execution/tasks/_comments.html.haml
95
+ - app/views/rails_execution/tasks/_form.html.haml
96
+ - app/views/rails_execution/tasks/_form_scripts.html.haml
97
+ - app/views/rails_execution/tasks/_new_comment.html.haml
98
+ - app/views/rails_execution/tasks/_reviewers.html.haml
99
+ - app/views/rails_execution/tasks/_script_content.html.haml
100
+ - app/views/rails_execution/tasks/_show_scripts.html.haml
101
+ - app/views/rails_execution/tasks/_status.html.haml
102
+ - app/views/rails_execution/tasks/_task.html.haml
103
+ - app/views/rails_execution/tasks/_tips.html.haml
104
+ - app/views/rails_execution/tasks/closed.html.haml
105
+ - app/views/rails_execution/tasks/completed.html.haml
106
+ - app/views/rails_execution/tasks/edit.html.haml
107
+ - app/views/rails_execution/tasks/index.html.haml
108
+ - app/views/rails_execution/tasks/new.html.haml
109
+ - app/views/rails_execution/tasks/show.html.haml
110
+ - config/routes.rb
111
+ - lib/generators/rails_execution/file_upload_generator.rb
112
+ - lib/generators/rails_execution/install_generator.rb
113
+ - lib/generators/rails_execution/templates/config.rb.tt
114
+ - lib/generators/rails_execution/templates/file_reader.rb.tt
115
+ - lib/generators/rails_execution/templates/file_uploader.rb.tt
116
+ - lib/generators/rails_execution/templates/install.rb.tt
117
+ - lib/rails_execution.rb
118
+ - lib/rails_execution/app_model.rb
119
+ - lib/rails_execution/config.rb
120
+ - lib/rails_execution/engine.rb
121
+ - lib/rails_execution/error.rb
122
+ - lib/rails_execution/files/reader.rb
123
+ - lib/rails_execution/files/uploader.rb
124
+ - lib/rails_execution/services/approvement.rb
125
+ - lib/rails_execution/services/execution.rb
126
+ - lib/rails_execution/services/executor.rb
127
+ - lib/rails_execution/services/paging.rb
128
+ - lib/rails_execution/services/syntax_checker.rb
129
+ - lib/rails_execution/version.rb
130
+ homepage: https://github.com/ThanhKhoaIT/rails_execution
131
+ licenses:
132
+ - MIT
133
+ metadata:
134
+ homepage_uri: https://github.com/ThanhKhoaIT/rails_execution
135
+ source_code_uri: https://github.com/ThanhKhoaIT/rails_execution
136
+ changelog_uri: https://github.com/ThanhKhoaIT/rails_execution
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.3.0
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubygems_version: 3.1.2
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: 'Rails Engine: Execute the script for migration, cleanup data and specially
156
+ case'
157
+ test_files: []