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 +4 -4
- data/lib/bacon_ipsum/http_client.rb +13 -5
- data/lib/bacon_ipsum/parser.rb +9 -1
- data/lib/bacon_ipsum/version.rb +1 -1
- data/lib/bacon_ipsum.rb +8 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee8522fe474ed65a935bbc45961293d1c33ea5dc6f9e1c38ed9fd5ee3b2080b4
|
4
|
+
data.tar.gz: eed76e43cacd8d2f9aa054f8a6c4b67a3c278da7daf97908b21e8602e03ae538
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
34
|
+
data = {
|
35
|
+
type: type,
|
33
36
|
paras: paras,
|
34
|
-
|
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
|
data/lib/bacon_ipsum/parser.rb
CHANGED
@@ -4,8 +4,16 @@ require 'json'
|
|
4
4
|
|
5
5
|
module BaconIpsum
|
6
6
|
class Parser
|
7
|
-
|
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
|
data/lib/bacon_ipsum/version.rb
CHANGED
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,
|
8
|
-
|
9
|
-
|
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.
|
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-
|
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.
|
58
|
+
rubygems_version: 3.4.17
|
59
59
|
signing_key:
|
60
60
|
specification_version: 4
|
61
61
|
summary: SDK for JSON API - Bacon Ipsum
|