Class: Dudity
- Inherits:
-
Object
- Object
- Dudity
- Defined in:
- lib/dudity.rb
Class Method Summary collapse
- .visualise(path, opt = {}) ⇒ Object
- .visualise_diff(path_to_diff, opt = {}) ⇒ Object
- .visualise_pr(public_pr_link, opt = {}) ⇒ Object
Class Method Details
.visualise(path, opt = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dudity.rb', line 8 def visualise(path, opt = {}) @path = path opt.key?(:except) ? except = opt[:except] : except = nil opt.key?(:only) ? only = opt[:only] : only = nil opt.key?(:ignore_classes) ? ignore_classes = opt[:ignore_classes] : ignore_classes = nil opt.key?(:only_classes) ? only_classes = opt[:only_classes] : only_classes = nil opt.key?(:filename_suffix) ? filename_suffix = opt[:filename_suffix] : filename_suffix = '' project_files = ScanApp.call(@path, except, only) app_name = @path.split('/').last @params_list = [] project_files.each { |project_file| process_item(project_file) } @params_list = @params_list.flatten.compact exclude_classes(ignore_classes) if ignore_classes include_classes(only_classes) if only_classes dudes = DudeGl.new @params_list, dudes_per_row_max: 4 dudes.render dudes.save "#{app_name}#{filename_suffix}" end |
.visualise_diff(path_to_diff, opt = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/dudity.rb', line 31 def visualise_diff(path_to_diff, opt = {}) @params1 = [] @params2 = [] # path to the dir where diff file is stored @path = path_to_diff.split('/').take(path_to_diff.split('/').size - 1).join('/') opt.key?(:as) ? file_type = opt[:as] : file_type = :svg opt.key?(:pull_branch) ? @pull_branch = opt[:pull_branch] : return diff = open(path_to_diff).readlines @diff_data = GitDiffService.call(diff) return generate_svg if file_type == :svg return generate_html_report if file_type == :html end |
.visualise_pr(public_pr_link, opt = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dudity.rb', line 48 def visualise_pr(public_pr_link, opt = {}) @params1 = [] @params2 = [] @path = public_pr_link diff_url = "#{public_pr_link}.diff" opt.key?(:as) ? file_type = opt[:as] : file_type = :svg opt.key?(:pull_branch) ? @pull_branch = opt[:pull_branch] : return diff = DownloadService.call(diff_url, :read_by_line) @diff_data = GitDiffService.call(diff) return generate_svg if file_type == :svg return generate_html_report if file_type == :html end |