ruby_blogger 1.0.7 → 1.0.8
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 +4 -4
 - data/bin/blog +0 -0
 - data/lib/read_exceptions.rb +29 -11
 - data/lib/ruby_blogger.rb +12 -1
 - metadata +5 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 822a5f173f0f3744fd21a745c7bc97c4846bbfc7c4d133cd39c7ad5cdf3908e8
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7669e3e7b58e1ddd2b493cc850f83bf9551a0a66006a3454b1e62afc663977a1
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 567a616b2336d35180e5e29d0e685dffbd82b9955a8ab94affb91c99e8d2a5d9a99b4ecd7f4cdf2558fc65007ae99edd99d42709da4e55a13ca2d192317ffd66
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: eb8a1732fd754fcdffc8d51d500c42ec765c9716a5675669326fa169a5b910e967df549d63d1c4f2180dede5f44738b54b711b6aeb9d8aef1e5769748ab25b83
         
     | 
    
        data/bin/blog
    CHANGED
    
    | 
         
            File without changes
         
     | 
    
        data/lib/read_exceptions.rb
    CHANGED
    
    | 
         @@ -13,8 +13,10 @@ end 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            #The following grouping of methods parse and display exception data for the whole project folder
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            def  
     | 
| 
       17 
     | 
    
         
            -
              exceptions.length
         
     | 
| 
      
 16 
     | 
    
         
            +
            def get_total_project_exceptions_and_filenames(exceptions)
         
     | 
| 
      
 17 
     | 
    
         
            +
              count = exceptions.length
         
     | 
| 
      
 18 
     | 
    
         
            +
              filenames = get_all_filenames(exceptions)
         
     | 
| 
      
 19 
     | 
    
         
            +
              "#{count} in #{filenames}"
         
     | 
| 
       18 
20 
     | 
    
         
             
            end
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
            def get_count_of_each_exception_class(exceptions)
         
     | 
| 
         @@ -24,6 +26,11 @@ def get_count_of_each_exception_class(exceptions) 
     | 
|
| 
       24 
26 
     | 
    
         
             
                counts[type] ? counts[type] += 1 : counts[type] = 1
         
     | 
| 
       25 
27 
     | 
    
         
             
              end 
         
     | 
| 
       26 
28 
     | 
    
         
             
              counts
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            #captures all filenames that require ruby_blogger that have raised exceptions
         
     | 
| 
      
 32 
     | 
    
         
            +
            def get_all_filenames(exceptions)
         
     | 
| 
      
 33 
     | 
    
         
            +
              exceptions.map { |exc| exc[:filename]}.uniq.join(', ')
         
     | 
| 
       27 
34 
     | 
    
         
             
            end 
         
     | 
| 
       28 
35 
     | 
    
         | 
| 
       29 
36 
     | 
    
         
             
            #display count of total exceptions and each exception class and its count
         
     | 
| 
         @@ -34,14 +41,14 @@ def display_total_and_counts(total, counts) 
     | 
|
| 
       34 
41 
     | 
    
         
             
                puts  "\n"
         
     | 
| 
       35 
42 
     | 
    
         
             
                puts "Exception Class: #{type}"
         
     | 
| 
       36 
43 
     | 
    
         
             
                puts "Total: #{count}"
         
     | 
| 
       37 
     | 
    
         
            -
                puts "-" *  
     | 
| 
      
 44 
     | 
    
         
            +
                puts "-" * 15
         
     | 
| 
       38 
45 
     | 
    
         
             
              end
         
     | 
| 
       39 
46 
     | 
    
         
             
            end
         
     | 
| 
       40 
47 
     | 
    
         | 
| 
       41 
48 
     | 
    
         
             
            #combines all get methods to display all exceptions and counts raised by all files in the project folder
         
     | 
| 
       42 
49 
     | 
    
         
             
            def display_summary
         
     | 
| 
       43 
50 
     | 
    
         
             
              exceptions = read_all_exceptions
         
     | 
| 
       44 
     | 
    
         
            -
              total =  
     | 
| 
      
 51 
     | 
    
         
            +
              total = get_total_project_exceptions_and_filenames(exceptions)
         
     | 
| 
       45 
52 
     | 
    
         
             
              counts = get_count_of_each_exception_class(exceptions)
         
     | 
| 
       46 
53 
     | 
    
         
             
              display_total_and_counts(total, counts)
         
     | 
| 
       47 
54 
     | 
    
         
             
            end 
         
     | 
| 
         @@ -68,6 +75,7 @@ def display_each_exception(filename) 
     | 
|
| 
       68 
75 
     | 
    
         
             
            exceptions = read_exceptions_for_file(filename)
         
     | 
| 
       69 
76 
     | 
    
         
             
              lines = exceptions.map do |exc|
         
     | 
| 
       70 
77 
     | 
    
         
             
                format_exception_line(exc[:type], 
         
     | 
| 
      
 78 
     | 
    
         
            +
                                      exc[:description],
         
     | 
| 
       71 
79 
     | 
    
         
             
                                      exc[:line_number],
         
     | 
| 
       72 
80 
     | 
    
         
             
                                      exc[:time])
         
     | 
| 
       73 
81 
     | 
    
         
             
              end 
         
     | 
| 
         @@ -75,10 +83,14 @@ exceptions = read_exceptions_for_file(filename) 
     | 
|
| 
       75 
83 
     | 
    
         
             
            end 
         
     | 
| 
       76 
84 
     | 
    
         | 
| 
       77 
85 
     | 
    
         
             
            #provide simple formatting for each exception class and line number
         
     | 
| 
       78 
     | 
    
         
            -
            def format_exception_line(type, line, time)
         
     | 
| 
      
 86 
     | 
    
         
            +
            def format_exception_line(type, description, line, time)
         
     | 
| 
       79 
87 
     | 
    
         
             
              date, time, tz = separate_date_and_time(time)
         
     | 
| 
       80 
     | 
    
         
            -
               
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
              line_hash = { class: type,
         
     | 
| 
      
 89 
     | 
    
         
            +
                            description: description,
         
     | 
| 
      
 90 
     | 
    
         
            +
                            Line: line,
         
     | 
| 
      
 91 
     | 
    
         
            +
                            Time: time,
         
     | 
| 
      
 92 
     | 
    
         
            +
                            Date: date }
         
     | 
| 
      
 93 
     | 
    
         
            +
              line_hash.map { |pair| pair.join(': ') }.join("\n   ")
         
     | 
| 
       82 
94 
     | 
    
         
             
            end 
         
     | 
| 
       83 
95 
     | 
    
         | 
| 
       84 
96 
     | 
    
         
             
            #separates date, time, and tz
         
     | 
| 
         @@ -90,12 +102,12 @@ end 
     | 
|
| 
       90 
102 
     | 
    
         
             
            def display_header_info(filename)
         
     | 
| 
       91 
103 
     | 
    
         
             
              puts "\n"
         
     | 
| 
       92 
104 
     | 
    
         
             
              puts "File: #{filename}"
         
     | 
| 
       93 
     | 
    
         
            -
              puts '-' *  
     | 
| 
      
 105 
     | 
    
         
            +
              puts '-' * 15
         
     | 
| 
       94 
106 
     | 
    
         
             
            end 
         
     | 
| 
       95 
107 
     | 
    
         | 
| 
       96 
108 
     | 
    
         
             
            #display simple trailer in CL
         
     | 
| 
       97 
109 
     | 
    
         
             
            def display_trailer
         
     | 
| 
       98 
     | 
    
         
            -
              puts '-' *  
     | 
| 
      
 110 
     | 
    
         
            +
              puts '-' * 15
         
     | 
| 
       99 
111 
     | 
    
         
             
            end
         
     | 
| 
       100 
112 
     | 
    
         | 
| 
       101 
113 
     | 
    
         
             
            #displays error message if user specifies non-existent file
         
     | 
| 
         @@ -103,13 +115,19 @@ def display_file_does_not_exist(file) 
     | 
|
| 
       103 
115 
     | 
    
         
             
              puts "Sorry, #{file} is not a file in this folder."
         
     | 
| 
       104 
116 
     | 
    
         
             
            end 
         
     | 
| 
       105 
117 
     | 
    
         | 
| 
      
 118 
     | 
    
         
            +
            def display_no_exceptions 
         
     | 
| 
      
 119 
     | 
    
         
            +
              puts "No exceptions have been raised by files that require 'ruby_blogger'"
         
     | 
| 
      
 120 
     | 
    
         
            +
            end 
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
       106 
122 
     | 
    
         
             
            #functional logic to capture command line input and either display information for the file specified in the command line or display data for the entire folder if no file is specified.
         
     | 
| 
       107 
123 
     | 
    
         
             
            specified_file = ARGV[0]
         
     | 
| 
       108 
124 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
            if  
     | 
| 
      
 125 
     | 
    
         
            +
            if !File.exist?('structured_exceptions.yml') 
         
     | 
| 
      
 126 
     | 
    
         
            +
              display_no_exceptions
         
     | 
| 
      
 127 
     | 
    
         
            +
            elsif specified_file && File.exist?(specified_file)
         
     | 
| 
       110 
128 
     | 
    
         
             
              display_exceptions_for_file(specified_file) 
         
     | 
| 
       111 
129 
     | 
    
         
             
            elsif specified_file && !File.exist?(specified_file)
         
     | 
| 
       112 
130 
     | 
    
         
             
              display_file_does_not_exist(specified_file)
         
     | 
| 
       113 
131 
     | 
    
         
             
            else 
         
     | 
| 
       114 
132 
     | 
    
         
             
              display_summary
         
     | 
| 
       115 
     | 
    
         
            -
            end 
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/ruby_blogger.rb
    CHANGED
    
    | 
         @@ -8,6 +8,16 @@ at_exit do 
     | 
|
| 
       8 
8 
     | 
    
         
             
              end
         
     | 
| 
       9 
9 
     | 
    
         
             
            end
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
      
 11 
     | 
    
         
            +
            def get_error_description(type)
         
     | 
| 
      
 12 
     | 
    
         
            +
              errors = {
         
     | 
| 
      
 13 
     | 
    
         
            +
                ZeroDivisionError: "Attempting to divide an Integer by 0.", 
         
     | 
| 
      
 14 
     | 
    
         
            +
                NoMethodError: "A method is called on a receiver that does not have that method defined."
         
     | 
| 
      
 15 
     | 
    
         
            +
              }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              return errors[type] if errors.key?(type)
         
     | 
| 
      
 18 
     | 
    
         
            +
              return 'Check out https://ruby-doc.org/core-2.7.0/Exception.html for more information.' if !errors.key?(type)
         
     | 
| 
      
 19 
     | 
    
         
            +
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
       11 
21 
     | 
    
         
             
            def create_instance(exception)
         
     | 
| 
       12 
22 
     | 
    
         
             
              blogger_entry = {}
         
     | 
| 
       13 
23 
     | 
    
         
             
              blogger_entry[:filename] = $0
         
     | 
| 
         @@ -15,9 +25,9 @@ def create_instance(exception) 
     | 
|
| 
       15 
25 
     | 
    
         
             
              blogger_entry[:cause] = $!.backtrace[0].split('`')[-1]
         
     | 
| 
       16 
26 
     | 
    
         
             
              blogger_entry[:message] = $!.message
         
     | 
| 
       17 
27 
     | 
    
         
             
              blogger_entry[:type] = $!.class.to_s
         
     | 
| 
      
 28 
     | 
    
         
            +
              blogger_entry[:description] = get_error_description($!.class.to_s.to_sym)
         
     | 
| 
       18 
29 
     | 
    
         
             
              blogger_entry[:scope] = self.to_s
         
     | 
| 
       19 
30 
     | 
    
         
             
              blogger_entry[:time] = Time.now
         
     | 
| 
       20 
     | 
    
         
            -
              puts 'Entry logged successfully'
         
     | 
| 
       21 
31 
     | 
    
         
             
              blogger_entry
         
     | 
| 
       22 
32 
     | 
    
         
             
            end
         
     | 
| 
       23 
33 
     | 
    
         | 
| 
         @@ -25,4 +35,5 @@ def logging(structured) 
     | 
|
| 
       25 
35 
     | 
    
         
             
              File.open('structured_exceptions.yml', 'a+') do |file|
         
     | 
| 
       26 
36 
     | 
    
         
             
                file.write (structured.to_yaml)
         
     | 
| 
       27 
37 
     | 
    
         
             
              end 
         
     | 
| 
      
 38 
     | 
    
         
            +
              puts 'Bug Logged Successfully:'
         
     | 
| 
       28 
39 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,16 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ruby_blogger
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.8
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Leena Lallmon
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Austin Miller
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Mandy Cheang
         
     | 
| 
       10 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2021-02- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2021-02-07 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       15 
15 
     | 
    
         
             
            description: A command line developer tool to track exceptions
         
     | 
| 
       16 
16 
     | 
    
         
             
            email:
         
     | 
| 
         @@ -28,7 +28,7 @@ homepage: https://github.com/aumi9292/blogger 
     | 
|
| 
       28 
28 
     | 
    
         
             
            licenses:
         
     | 
| 
       29 
29 
     | 
    
         
             
            - MIT
         
     | 
| 
       30 
30 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       31 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 31 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       32 
32 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       33 
33 
     | 
    
         
             
            require_paths:
         
     | 
| 
       34 
34 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       44 
44 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       45 
45 
     | 
    
         
             
            requirements: []
         
     | 
| 
       46 
46 
     | 
    
         
             
            rubygems_version: 3.1.2
         
     | 
| 
       47 
     | 
    
         
            -
            signing_key: 
     | 
| 
      
 47 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       48 
48 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       49 
49 
     | 
    
         
             
            summary: Capture and display data about exceptions your .rb file raises
         
     | 
| 
       50 
50 
     | 
    
         
             
            test_files: []
         
     |