ricojson 0.1.0 → 0.1.2
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 +7 -0
- data/bin/ricojson +0 -1
- data/lib/ricojson.rb +53 -25
- metadata +36 -35
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA256:
         | 
| 3 | 
            +
              metadata.gz: daf902da688595a645f37c40decebcac2fab0bcf2c10da87d7dae4e7e8004c6c
         | 
| 4 | 
            +
              data.tar.gz: 5261c53f1f4b1bd0a1ce503b4a4c9eb01e5c1f5f201c9508438948e77c14a261
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 73370e82bca9938863d117b843688bb2fa76bc384b3cec97ba78c22e88dedcf8a042c60f9012a3ea60c995db711eeab21f6cf9d0cdd62fb279806a35da44e5f2
         | 
| 7 | 
            +
              data.tar.gz: 7387c2951762faaf17d6012616a4daf9b89ee8799bf248d222129fd82b0c0228b67d01fb62016a7b37b6fa5bd50d0e7e29a66edd6f8f8c18204f84ed8f68f613
         | 
    
        data/bin/ricojson
    CHANGED
    
    
    
        data/lib/ricojson.rb
    CHANGED
    
    | @@ -1,37 +1,65 @@ | |
| 1 | 
            -
            # -*- coding: utf-8 -*-
         | 
| 2 1 | 
             
            require 'json'
         | 
| 3 2 | 
             
            require 'tempfile'
         | 
| 4 3 |  | 
| 4 | 
            +
            # Main RicoJSON functionality
         | 
| 5 5 | 
             
            module RicoJSON
         | 
| 6 | 
            -
               | 
| 7 | 
            -
                 | 
| 8 | 
            -
             | 
| 6 | 
            +
              class << self
         | 
| 7 | 
            +
                # Define open_in_app method for GNU/Linux or Mac OS X platforms
         | 
| 8 | 
            +
                def open_in_app(json)
         | 
| 9 | 
            +
                  if RUBY_PLATFORM =~ /linux/
         | 
| 10 | 
            +
                    `xdg-open #{json.path}`
         | 
| 11 | 
            +
                  elsif RUBY_PLATFORM =~ /macos|darwin/
         | 
| 12 | 
            +
                    `open -t #{json.path}`
         | 
| 13 | 
            +
                  end
         | 
| 9 14 | 
             
                end
         | 
| 10 | 
            -
              elsif RUBY_PLATFORM =~ /macos|darwin/
         | 
| 11 | 
            -
                def self.open(json)
         | 
| 12 | 
            -
                  `open -t #{json.path}`
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 15 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
                 | 
| 18 | 
            -
             | 
| 16 | 
            +
                # Method for reading a file as an input
         | 
| 17 | 
            +
                #
         | 
| 18 | 
            +
                # Example:
         | 
| 19 | 
            +
                #   $ ricojson -f comics.json
         | 
| 20 | 
            +
                #
         | 
| 21 | 
            +
                # Arguments:
         | 
| 22 | 
            +
                #   filename: Name of the input file
         | 
| 23 | 
            +
                #   open:     Open the file in the default app/text editor for ,json
         | 
| 24 | 
            +
                # files (optional)
         | 
| 25 | 
            +
                #
         | 
| 26 | 
            +
                # == Returns:
         | 
| 27 | 
            +
                #   JSON Rico y Suave
         | 
| 28 | 
            +
                def read_file(filename, open = false)
         | 
| 29 | 
            +
                  read_string(File.read(filename), open)
         | 
| 30 | 
            +
                end
         | 
| 19 31 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
                 | 
| 22 | 
            -
                 | 
| 23 | 
            -
             | 
| 24 | 
            -
                 | 
| 25 | 
            -
             | 
| 32 | 
            +
                # Method for reading a String as an input
         | 
| 33 | 
            +
                #
         | 
| 34 | 
            +
                # Example:
         | 
| 35 | 
            +
                #   $ cat comics.json | ricojson
         | 
| 36 | 
            +
                #
         | 
| 37 | 
            +
                # Arguments:
         | 
| 38 | 
            +
                #   json_string: Incoming String (could be piped from curl, cat,
         | 
| 39 | 
            +
                #   echo, etc)
         | 
| 40 | 
            +
                #   open:     Open the file in the default app/text editor for ,json
         | 
| 41 | 
            +
                # files (optional)
         | 
| 42 | 
            +
                #
         | 
| 43 | 
            +
                # == Returns:
         | 
| 44 | 
            +
                #   JSON Rico y Suave
         | 
| 45 | 
            +
                def read_string(json_string, open = false)
         | 
| 46 | 
            +
                  body = JSON.pretty_generate(JSON.parse(json_string))
         | 
| 47 | 
            +
                  if open
         | 
| 48 | 
            +
                    open_in_file(body)
         | 
| 49 | 
            +
                  else
         | 
| 50 | 
            +
                    puts body
         | 
| 51 | 
            +
                  end
         | 
| 26 52 | 
             
                end
         | 
| 27 | 
            -
              end
         | 
| 28 53 |  | 
| 29 | 
            -
             | 
| 30 | 
            -
                 | 
| 31 | 
            -
             | 
| 32 | 
            -
                   | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 54 | 
            +
                # Used to open the prettified JSON in a text editor or other
         | 
| 55 | 
            +
                # system's app
         | 
| 56 | 
            +
                def open_in_file(body)
         | 
| 57 | 
            +
                  fork do
         | 
| 58 | 
            +
                    json = Tempfile.new(['json', '.json'])
         | 
| 59 | 
            +
                    json.write(body)
         | 
| 60 | 
            +
                    json.close
         | 
| 61 | 
            +
                    open_in_app(json)
         | 
| 62 | 
            +
                  end
         | 
| 35 63 | 
             
                end
         | 
| 36 64 | 
             
              end
         | 
| 37 65 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,64 +1,70 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: ricojson
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.1.2
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Fernando Briano
         | 
| 9 | 
            -
            autorequire: 
         | 
| 10 8 | 
             
            bindir: bin
         | 
| 11 9 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 10 | 
            +
            date: 2025-05-16 00:00:00.000000000 Z
         | 
| 13 11 | 
             
            dependencies:
         | 
| 14 12 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 13 | 
             
              name: clap
         | 
| 16 14 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                none: false
         | 
| 18 15 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 16 | 
            +
                - - "~>"
         | 
| 20 17 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            -
                    version: ' | 
| 18 | 
            +
                    version: '1'
         | 
| 22 19 | 
             
              type: :runtime
         | 
| 23 20 | 
             
              prerelease: false
         | 
| 24 21 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                none: false
         | 
| 26 22 | 
             
                requirements:
         | 
| 27 | 
            -
                - -  | 
| 23 | 
            +
                - - "~>"
         | 
| 28 24 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            -
                    version: ' | 
| 25 | 
            +
                    version: '1'
         | 
| 30 26 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 27 | 
             
              name: minitest
         | 
| 32 28 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                none: false
         | 
| 34 29 | 
             
                requirements:
         | 
| 35 | 
            -
                - - ~>
         | 
| 30 | 
            +
                - - "~>"
         | 
| 36 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version: '5 | 
| 32 | 
            +
                    version: '5'
         | 
| 38 33 | 
             
              type: :development
         | 
| 39 34 | 
             
              prerelease: false
         | 
| 40 35 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                none: false
         | 
| 42 36 | 
             
                requirements:
         | 
| 43 | 
            -
                - - ~>
         | 
| 37 | 
            +
                - - "~>"
         | 
| 44 38 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version: '5 | 
| 39 | 
            +
                    version: '5'
         | 
| 46 40 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 41 | 
             
              name: rubocop
         | 
| 48 42 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                none: false
         | 
| 50 43 | 
             
                requirements:
         | 
| 51 | 
            -
                - - ~>
         | 
| 44 | 
            +
                - - "~>"
         | 
| 52 45 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            -
                    version: ' | 
| 46 | 
            +
                    version: '1'
         | 
| 54 47 | 
             
              type: :development
         | 
| 55 48 | 
             
              prerelease: false
         | 
| 56 49 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                none: false
         | 
| 58 50 | 
             
                requirements:
         | 
| 59 | 
            -
                - - ~>
         | 
| 51 | 
            +
                - - "~>"
         | 
| 60 52 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version: ' | 
| 53 | 
            +
                    version: '1'
         | 
| 54 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 55 | 
            +
              name: rake
         | 
| 56 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                requirements:
         | 
| 58 | 
            +
                - - "~>"
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '13'
         | 
| 61 | 
            +
              type: :development
         | 
| 62 | 
            +
              prerelease: false
         | 
| 63 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - "~>"
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '13'
         | 
| 62 68 | 
             
            description: Uses Ruby's JSON to parse and format json files, includes an option to
         | 
| 63 69 | 
             
              open them in the system's default application.
         | 
| 64 70 | 
             
            email: fernando@picandocodigo.net
         | 
| @@ -67,32 +73,27 @@ executables: | |
| 67 73 | 
             
            extensions: []
         | 
| 68 74 | 
             
            extra_rdoc_files: []
         | 
| 69 75 | 
             
            files:
         | 
| 70 | 
            -
            - lib/ricojson.rb
         | 
| 71 76 | 
             
            - bin/ricojson
         | 
| 72 | 
            -
             | 
| 77 | 
            +
            - lib/ricojson.rb
         | 
| 78 | 
            +
            homepage: https://github.com/picandocodigo/ricojson
         | 
| 73 79 | 
             
            licenses:
         | 
| 74 | 
            -
            - LGPL-3.0
         | 
| 75 | 
            -
             | 
| 80 | 
            +
            - LGPL-3.0-or-later
         | 
| 81 | 
            +
            metadata: {}
         | 
| 76 82 | 
             
            rdoc_options: []
         | 
| 77 83 | 
             
            require_paths:
         | 
| 78 84 | 
             
            - lib
         | 
| 79 85 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 80 | 
            -
              none: false
         | 
| 81 86 | 
             
              requirements:
         | 
| 82 | 
            -
              - -  | 
| 87 | 
            +
              - - ">="
         | 
| 83 88 | 
             
                - !ruby/object:Gem::Version
         | 
| 84 89 | 
             
                  version: '0'
         | 
| 85 90 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 86 | 
            -
              none: false
         | 
| 87 91 | 
             
              requirements:
         | 
| 88 | 
            -
              - -  | 
| 92 | 
            +
              - - ">="
         | 
| 89 93 | 
             
                - !ruby/object:Gem::Version
         | 
| 90 94 | 
             
                  version: '0'
         | 
| 91 95 | 
             
            requirements: []
         | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
            signing_key: 
         | 
| 95 | 
            -
            specification_version: 3
         | 
| 96 | 
            +
            rubygems_version: 3.6.3
         | 
| 97 | 
            +
            specification_version: 4
         | 
| 96 98 | 
             
            summary: A gem to prettify JSON files and (optionally) open them in default app
         | 
| 97 99 | 
             
            test_files: []
         | 
| 98 | 
            -
            has_rdoc: 
         |