aga-beacon 0.0.0 → 0.0.1
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/README.md +9 -14
- data/lib/beacon/resources/service.rb +13 -30
- data/lib/beacon/version.rb +1 -1
- data/lib/beacon.rb +0 -5
- metadata +12 -12
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: '091dfa684983dd036dc7f11dfb3255ef60e68168e454864d16b43f59d1581c02'
         | 
| 4 | 
            +
              data.tar.gz: a4d145db691b0236e634d80a47b34508d7107b9e0a1bb6fd341cbff08b08cd9e
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 934b556de9b6c1d7c01e89c4a0886f559423c3d0094300d8d6901ad3dbad4ceef28789cdc38cce7c43ec7f1d8905c23682f4c9c58a8fd1324cec38d4a1f72a31
         | 
| 7 | 
            +
              data.tar.gz: 5c4287531b35dc4998501f92146a22dfb588adb38d69b9fe66e9e7601f35d4b7a8027433651f6223f7ed0c36129511a837e4e6d0bab41417e7205c55195cc89f
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,13 +1,14 @@ | |
| 1 1 | 
             
            # Aga-beacon
         | 
| 2 2 |  | 
| 3 | 
            -
            Aga- | 
| 3 | 
            +
            Aga-beacon is a Ruby gem that provides a convenient way to handle log files. It allows you to write log messages, read log files, clean up log files, and calculate the size of log files in bytes. With this gem, you can efficiently manage log files and extract valuable information from them.
         | 
| 4 4 |  | 
| 5 5 |  | 
| 6 6 | 
             
            ## Features
         | 
| 7 7 |  | 
| 8 | 
            -
            -  | 
| 9 | 
            -
            -  | 
| 10 | 
            -
            -  | 
| 8 | 
            +
            - Write log messages to a log file, including timestamps and customizable log levels.
         | 
| 9 | 
            +
            - Read log files and extract log entries based on specific criteria, such as date range or log level.
         | 
| 10 | 
            +
            - Clean up log files by removing old or unnecessary log entries to optimize file size.
         | 
| 11 | 
            +
            - Calculate the size of log files in bytes, providing insights into the log file's storage requirements.
         | 
| 11 12 |  | 
| 12 13 | 
             
            ## Installation
         | 
| 13 14 |  | 
| @@ -24,19 +25,13 @@ If bundler is not being used to manage dependencies, install the gem by executin | |
| 24 25 | 
             
            To use Aga-beacon in your application, require the gem and start making requests. Here's a basic example:
         | 
| 25 26 |  | 
| 26 27 | 
             
            ```
         | 
| 27 | 
            -
             | 
| 28 | 
            +
            irb
         | 
| 28 29 |  | 
| 29 30 | 
             
            require 'beacon'
         | 
| 30 31 |  | 
| 31 | 
            -
            Beacon. | 
| 32 | 
            -
             | 
| 33 | 
            -
            b | 
| 34 | 
            -
            b.log('Hello') # Output: { status: 200 }
         | 
| 35 | 
            -
            b.read('.log/development_new.log') # Output: 'Hello'
         | 
| 36 | 
            -
            b.clear # Output: 0
         | 
| 37 | 
            -
             | 
| 38 | 
            -
            b.log('Hello')
         | 
| 39 | 
            -
            b.size('.log/development_new.log') # Output: 56
         | 
| 32 | 
            +
            b = Beacon::Service.instance
         | 
| 33 | 
            +
            b.info('Info') # Output:  [2023-07-25T21:10:47.656630 #65059]  INFO -- : Info
         | 
| 34 | 
            +
            b.error('Error') # Output: [2023-07-25T21:11:39.089020 #65059] ERROR -- : Error
         | 
| 40 35 |  | 
| 41 36 | 
             
            ```
         | 
| 42 37 |  | 
| @@ -1,45 +1,28 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require ' | 
| 3 | 
            +
            require 'logger'
         | 
| 4 4 |  | 
| 5 5 | 
             
            module Beacon
         | 
| 6 6 | 
             
              class Service
         | 
| 7 | 
            -
                 | 
| 8 | 
            -
                  @environment = ENV['ENVIRONMENT'] || 'production'
         | 
| 9 | 
            -
                  @service = service.to_s
         | 
| 7 | 
            +
                @@instance = nil
         | 
| 10 8 |  | 
| 11 | 
            -
             | 
| 12 | 
            -
                   | 
| 9 | 
            +
                def self.instance
         | 
| 10 | 
            +
                  @@instance ||= new
         | 
| 13 11 | 
             
                end
         | 
| 14 12 |  | 
| 15 | 
            -
                 | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
                   | 
| 19 | 
            -
             | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                  response
         | 
| 23 | 
            -
                end
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                def clear
         | 
| 26 | 
            -
                  File.truncate(@log_file, 0) if File.exist?(@log_file)
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                  response
         | 
| 29 | 
            -
                end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                def read(name)
         | 
| 32 | 
            -
                  file_content = ''
         | 
| 33 | 
            -
                  File.open(name, 'r') { |file| file_content = file.read } if File.exist?(name)
         | 
| 34 | 
            -
                  file_content
         | 
| 13 | 
            +
                private_class_method :new
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                def initialize
         | 
| 16 | 
            +
                  @log = Logger.new($stdout)
         | 
| 17 | 
            +
                  @log.level = Logger::INFO
         | 
| 35 18 | 
             
                end
         | 
| 36 19 |  | 
| 37 | 
            -
                def  | 
| 38 | 
            -
                   | 
| 20 | 
            +
                def error(message)
         | 
| 21 | 
            +
                  @log.error(message.capitalize)
         | 
| 39 22 | 
             
                end
         | 
| 40 23 |  | 
| 41 | 
            -
                def  | 
| 42 | 
            -
                   | 
| 24 | 
            +
                def info(message)
         | 
| 25 | 
            +
                  @log.info(message.capitalize)
         | 
| 43 26 | 
             
                end
         | 
| 44 27 | 
             
              end
         | 
| 45 28 | 
             
            end
         | 
    
        data/lib/beacon/version.rb
    CHANGED
    
    
    
        data/lib/beacon.rb
    CHANGED
    
    | @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            require 'tzinfo'
         | 
| 4 3 | 
             
            require_relative './beacon/autoloader'
         | 
| 5 4 |  | 
| 6 5 | 
             
            module Beacon
         | 
| @@ -13,10 +12,6 @@ module Beacon | |
| 13 12 | 
             
                  ::Beacon::Base.app_info = value
         | 
| 14 13 | 
             
                end
         | 
| 15 14 |  | 
| 16 | 
            -
                def configuration
         | 
| 17 | 
            -
                  TZInfo::Timezone.get('Europe/Rome')
         | 
| 18 | 
            -
                end
         | 
| 19 | 
            -
             | 
| 20 15 | 
             
                def ping
         | 
| 21 16 | 
             
                  { status: 200 }
         | 
| 22 17 | 
             
                end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: aga-beacon
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Stefano Baldazzi
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-07-25 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: zeitwerk
         | 
| @@ -123,47 +123,47 @@ dependencies: | |
| 123 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 124 | 
             
                    version: '3.0'
         | 
| 125 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            -
              name:  | 
| 126 | 
            +
              name: logger
         | 
| 127 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 128 | 
             
                requirements:
         | 
| 129 129 | 
             
                - - "~>"
         | 
| 130 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            -
                    version:  | 
| 131 | 
            +
                    version: 1.5.3
         | 
| 132 132 | 
             
              type: :development
         | 
| 133 133 | 
             
              prerelease: false
         | 
| 134 134 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 135 | 
             
                requirements:
         | 
| 136 136 | 
             
                - - "~>"
         | 
| 137 137 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            -
                    version:  | 
| 138 | 
            +
                    version: 1.5.3
         | 
| 139 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            -
              name:  | 
| 140 | 
            +
              name: nokogiri
         | 
| 141 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 142 | 
             
                requirements:
         | 
| 143 143 | 
             
                - - "~>"
         | 
| 144 144 | 
             
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            -
                    version: ' | 
| 145 | 
            +
                    version: '1.15'
         | 
| 146 146 | 
             
              type: :development
         | 
| 147 147 | 
             
              prerelease: false
         | 
| 148 148 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 149 | 
             
                requirements:
         | 
| 150 150 | 
             
                - - "~>"
         | 
| 151 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            -
                    version: ' | 
| 152 | 
            +
                    version: '1.15'
         | 
| 153 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            -
              name:  | 
| 154 | 
            +
              name: pry
         | 
| 155 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 156 | 
             
                requirements:
         | 
| 157 157 | 
             
                - - "~>"
         | 
| 158 158 | 
             
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            -
                    version:  | 
| 159 | 
            +
                    version: '0.14'
         | 
| 160 160 | 
             
              type: :development
         | 
| 161 161 | 
             
              prerelease: false
         | 
| 162 162 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 163 | 
             
                requirements:
         | 
| 164 164 | 
             
                - - "~>"
         | 
| 165 165 | 
             
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            -
                    version:  | 
| 166 | 
            +
                    version: '0.14'
         | 
| 167 167 | 
             
            description: Beacon Ruby is a lightweight gem for write, read & take size of log files.
         | 
| 168 168 | 
             
            email:
         | 
| 169 169 | 
             
            - stefanobaldazzi40@gmail.com
         | 
| @@ -199,5 +199,5 @@ requirements: [] | |
| 199 199 | 
             
            rubygems_version: 3.3.24
         | 
| 200 200 | 
             
            signing_key: 
         | 
| 201 201 | 
             
            specification_version: 4
         | 
| 202 | 
            -
            summary: aga-beacon0.0. | 
| 202 | 
            +
            summary: aga-beacon0.0.1
         | 
| 203 203 | 
             
            test_files: []
         |