bacon_ipsum 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 +7 -0
 - data/lib/bacon_ipsum/http_client.rb +34 -0
 - data/lib/bacon_ipsum/parser.rb +13 -0
 - data/lib/bacon_ipsum/version.rb +5 -0
 - data/lib/bacon_ipsum.rb +11 -0
 - metadata +62 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c6fabf28bbf3b31a3203013432093b09163189352d3d92aebe303b316411651d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9a8bb4ce50d945947d2fb7043e849135a7ec3c48c35e8b3e8a0257f05d59b4a2
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d1f3e1e259cb6b2807fd484d8467089d71d9de04e8b64d4bee26b5ff9a0b8ee3f256509810f24f85a5a9022233ec699dc2ffe008fce4f7da8f5128b0b25b6b99
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: cce29d1d3fcee854bc4ab6dc933388c8c2571bb86385df982b84d2205a4fa405960771ac68d6ee905efd0986dbc84a73907d11c44c060d1286cd5b9488760205
         
     | 
| 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'typhoeus'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module BaconIpsum
         
     | 
| 
      
 6 
     | 
    
         
            +
              class HttpClient
         
     | 
| 
      
 7 
     | 
    
         
            +
                BASE_ENDPOINT = 'https://baconipsum.com/api/'
         
     | 
| 
      
 8 
     | 
    
         
            +
                REQUEST_TIMEOUT = 30
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                attr_accessor :paras, :sentences
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def initialize(paras, sentences)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @paras = paras
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @sentences = sentences
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def get
         
     | 
| 
      
 18 
     | 
    
         
            +
                  response = Typhoeus.get(
         
     | 
| 
      
 19 
     | 
    
         
            +
                    endpoint,
         
     | 
| 
      
 20 
     | 
    
         
            +
                    headers: {},
         
     | 
| 
      
 21 
     | 
    
         
            +
                    timeout: REQUEST_TIMEOUT
         
     | 
| 
      
 22 
     | 
    
         
            +
                  )
         
     | 
| 
      
 23 
     | 
    
         
            +
                  return false unless response.success?
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  response.body
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                private
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                def endpoint
         
     | 
| 
      
 31 
     | 
    
         
            +
                  "#{BASE_ENDPOINT}?type=all-meat?paras=#{paras}?sentences=#{sentences}"
         
     | 
| 
      
 32 
     | 
    
         
            +
                end
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/bacon_ipsum.rb
    ADDED
    
    | 
         @@ -0,0 +1,11 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative 'bacon_ipsum/http_client'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'bacon_ipsum/parser'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module BaconIpsum
         
     | 
| 
      
 7 
     | 
    
         
            +
              def self.generate(paras: 5, sentences: 2)
         
     | 
| 
      
 8 
     | 
    
         
            +
                response = HttpClient.new(paras, sentences)
         
     | 
| 
      
 9 
     | 
    
         
            +
                Parser.parse(response.get)
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: bacon_ipsum
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Kirill Leonov
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-07-20 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: typhoeus
         
     | 
| 
      
 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: Allows you to generate random text using Bacon Ipsum API
         
     | 
| 
      
 28 
     | 
    
         
            +
            email: leonov835@yandex.ru
         
     | 
| 
      
 29 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 30 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            files:
         
     | 
| 
      
 33 
     | 
    
         
            +
            - lib/bacon_ipsum.rb
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/bacon_ipsum/http_client.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/bacon_ipsum/parser.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/bacon_ipsum/version.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            homepage: https://github.com/leonovk/bacon_ipsum
         
     | 
| 
      
 38 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 39 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 40 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 41 
     | 
    
         
            +
              homepage_uri: https://github.com/leonovk/bacon_ipsum
         
     | 
| 
      
 42 
     | 
    
         
            +
              source_code_uri: https://github.com/leonovk/bacon_ipsum
         
     | 
| 
      
 43 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
      
 44 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 45 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 47 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 49 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 50 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 51 
     | 
    
         
            +
                  version: 2.7.0
         
     | 
| 
      
 52 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 53 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 54 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 55 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 56 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 57 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 58 
     | 
    
         
            +
            rubygems_version: 3.4.15
         
     | 
| 
      
 59 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 60 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 61 
     | 
    
         
            +
            summary: SDK for JSON API - Bacon Ipsum
         
     | 
| 
      
 62 
     | 
    
         
            +
            test_files: []
         
     |