issue-db 1.1.0 → 1.3.0

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.
@@ -1,45 +1,47 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class GenerateError < StandardError; end
3
+ module IssueDB
4
+ class GenerateError < StandardError; end
4
5
 
5
- module Generate
6
- # Generates the issue body with embedded data
7
- # :param data [Hash] the data to embed in the issue body
8
- # :param body_before [String] the body of the issue before the data (optional)
9
- # :param body_after [String] the body of the issue after the data (optional)
10
- # :param guard_start [String] the guard start string which is used to identify the start of the data
11
- # :param guard_end [String] the guard end string which is used to identify the end of the data
12
- # :return [String] the issue body with the embedded data
13
- def generate(
14
- data,
15
- body_before: nil,
16
- body_after: nil,
17
- guard_start: "<!--- issue-db-start -->",
18
- guard_end: "<!--- issue-db-end -->"
19
- )
6
+ module Generate
7
+ # Generates the issue body with embedded data
8
+ # :param data [Hash] the data to embed in the issue body
9
+ # :param body_before [String] the body of the issue before the data (optional)
10
+ # :param body_after [String] the body of the issue after the data (optional)
11
+ # :param guard_start [String] the guard start string which is used to identify the start of the data
12
+ # :param guard_end [String] the guard end string which is used to identify the end of the data
13
+ # :return [String] the issue body with the embedded data
14
+ def generate(
15
+ data,
16
+ body_before: nil,
17
+ body_after: nil,
18
+ guard_start: "<!--- issue-db-start -->",
19
+ guard_end: "<!--- issue-db-end -->"
20
+ )
20
21
 
21
- # json formatting options
22
- opts = {
23
- indent: " ",
24
- space: " ",
25
- object_nl: "\n",
26
- array_nl: "\n",
27
- allow_nan: true,
28
- max_nesting: false
29
- }
22
+ # json formatting options
23
+ opts = {
24
+ indent: " ",
25
+ space: " ",
26
+ object_nl: "\n",
27
+ array_nl: "\n",
28
+ allow_nan: true,
29
+ max_nesting: false
30
+ }
30
31
 
31
- json_data = JSON.pretty_generate(data, opts)
32
+ json_data = JSON.pretty_generate(data, opts)
32
33
 
33
- # construct the body
34
- body = ""
35
- body += "#{body_before}\n" unless body_before.nil? # the first part of the body
36
- body += "#{guard_start}\n" # the start of the data
37
- body += "```json\n" # the start of the json codeblock
38
- body += "#{json_data}\n" # the data
39
- body += "```\n" # the end of the json codeblock
40
- body += "#{guard_end}\n" # the end of the data
41
- body += body_after unless body_after.nil? # the last part of the body
34
+ # construct the body
35
+ body = ""
36
+ body += "#{body_before}\n" unless body_before.nil? # the first part of the body
37
+ body += "#{guard_start}\n" # the start of the data
38
+ body += "```json\n" # the start of the json codeblock
39
+ body += "#{json_data}\n" # the data
40
+ body += "```\n" # the end of the json codeblock
41
+ body += "#{guard_end}\n" # the end of the data
42
+ body += body_after unless body_after.nil? # the last part of the body
42
43
 
43
- return body
44
+ return body
45
+ end
44
46
  end
45
47
  end