bacon_ipsum 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcccef30c897d2c1470313f94c81228ed900c1da834cc01b089328b05771617d
4
- data.tar.gz: 883bfd835e32981e1ed11f2dba4c9c2dcfeedd4601b5021599ec70e81abbb503
3
+ metadata.gz: ee8522fe474ed65a935bbc45961293d1c33ea5dc6f9e1c38ed9fd5ee3b2080b4
4
+ data.tar.gz: eed76e43cacd8d2f9aa054f8a6c4b67a3c278da7daf97908b21e8602e03ae538
5
5
  SHA512:
6
- metadata.gz: 9a04b976d52a56d3631efba3d61720521810cee4f18363cd53d63c439da5607f02d04950ad22d0f3672049fc39b952d1dcfc2903901f4810fa309288ef475566
7
- data.tar.gz: c50fab243128ed6d4869462533d238cccbd1d6e4f48691a20dd0513894b6deee366e7d43efe902732ea18af4f68955426d3b037888c60f37d47170da4aa22a14
6
+ metadata.gz: f99b5fd1ed3208e85a1c811311f60686cb91eff3927e325c938fa314958ee5b0178e8e3694cb915dad8bb66ca782bafe6869ec70efcb8aac9bd2d82f149e59de
7
+ data.tar.gz: d4c5453d9a404936e00809b2b64db52c60603b33dcf8cc862e32ad4ecbf219d654851f9e4afa10afc37b382b35751afce025acd961c856d1afe7b5b92d73cf5b
@@ -7,11 +7,14 @@ module BaconIpsum
7
7
  BASE_ENDPOINT = 'https://baconipsum.com/api/'
8
8
  REQUEST_TIMEOUT = 30
9
9
 
10
- attr_accessor :paras, :sentences
10
+ attr_accessor :paras, :sentences, :type, :start_with_lorem, :format
11
11
 
12
- def initialize(paras, sentences)
12
+ def initialize(paras, sentences, type, start_with_lorem, format)
13
13
  @paras = paras
14
14
  @sentences = sentences
15
+ @type = type
16
+ @start_with_lorem = start_with_lorem
17
+ @format = format
15
18
  end
16
19
 
17
20
  def get
@@ -28,11 +31,16 @@ module BaconIpsum
28
31
  private
29
32
 
30
33
  def params
31
- {
32
- type: 'all-meat',
34
+ data = {
35
+ type: type,
33
36
  paras: paras,
34
- sentences: sentences
37
+ format: format
35
38
  }
39
+
40
+ data['sentences'] = sentences if sentences
41
+ data['start-with-lorem'] = start_with_lorem if start_with_lorem
42
+
43
+ data
36
44
  end
37
45
  end
38
46
  end
@@ -4,8 +4,16 @@ require 'json'
4
4
 
5
5
  module BaconIpsum
6
6
  class Parser
7
- def self.parse(response)
7
+ attr_reader :response, :format
8
+
9
+ def initialize(response, format)
10
+ @response = response
11
+ @format = format
12
+ end
13
+
14
+ def parse
8
15
  return unless response
16
+ return response if format != 'json'
9
17
 
10
18
  JSON.parse(response)
11
19
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BaconIpsum
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
data/lib/bacon_ipsum.rb CHANGED
@@ -4,8 +4,13 @@ require_relative 'bacon_ipsum/http_client'
4
4
  require_relative 'bacon_ipsum/parser'
5
5
 
6
6
  module BaconIpsum
7
- def self.generate(paras: 5, sentences: nil)
8
- response = HttpClient.new(paras, sentences)
9
- Parser.parse(response.get)
7
+ def self.generate(paras: 5,
8
+ sentences: nil,
9
+ type: 'meat-and-filler',
10
+ start_with_lorem: nil,
11
+ format: 'json')
12
+
13
+ response = HttpClient.new(paras, sentences, type, start_with_lorem, format)
14
+ Parser.new(response.get, format).parse
10
15
  end
11
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bacon_ipsum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Leonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-21 00:00:00.000000000 Z
11
+ date: 2023-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 3.4.15
58
+ rubygems_version: 3.4.17
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: SDK for JSON API - Bacon Ipsum