abide_dev_utils 0.14.0 → 0.14.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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/abide_dev_utils/markdown.rb +19 -2
- data/lib/abide_dev_utils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 54b60da7a8a67908351bf5e2687c39e8ac76aad00cb71ad798ac0c0a195e07fe
|
|
4
|
+
data.tar.gz: 400a2593d83b24a0f970a52f4b6ae0434ff41975260b351c5dd5d0e52387f282
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3857661d49e0fd254fda83c58ac0363cad5df50342aa55eca44f05f8e1dd47214200ef8586bbec6c1f46767cd7d0528be8f089507e0a6699896971ffceaca2da
|
|
7
|
+
data.tar.gz: edaa3a7dc991292d51feba476cd49cf343e570ac87e0310957f4d55d43932fd3dc4ed6d72aa6f78fbc686063416e65ed0bbed03bf550fffcf63a135c3175d4af
|
data/Gemfile.lock
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'tempfile'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
|
|
3
6
|
module AbideDevUtils
|
|
4
7
|
# Formats text for output in markdown
|
|
5
8
|
class Markdown
|
|
@@ -14,11 +17,17 @@ module AbideDevUtils
|
|
|
14
17
|
def to_markdown
|
|
15
18
|
toc = @toc.join("\n")
|
|
16
19
|
body = @body.join("\n")
|
|
17
|
-
"#{@title}\n#{toc}\n\n#{body}"
|
|
20
|
+
"#{@title}\n#{toc}\n\n#{body}".encode(universal_newline: true)
|
|
18
21
|
end
|
|
22
|
+
alias to_s to_markdown
|
|
19
23
|
|
|
20
24
|
def to_file
|
|
21
|
-
|
|
25
|
+
this_markdown = to_markdown
|
|
26
|
+
Tempfile.create('markdown') do |f|
|
|
27
|
+
f.write(this_markdown)
|
|
28
|
+
check_file_content(f.path, this_markdown)
|
|
29
|
+
FileUtils.mv(f.path, @file)
|
|
30
|
+
end
|
|
22
31
|
end
|
|
23
32
|
|
|
24
33
|
def method_missing(name, *args, &block)
|
|
@@ -88,6 +97,14 @@ module AbideDevUtils
|
|
|
88
97
|
|
|
89
98
|
private
|
|
90
99
|
|
|
100
|
+
def check_file_content(file, content)
|
|
101
|
+
raise "File #{file} not found! Not saving to #{@file}" unless File.exist?(file)
|
|
102
|
+
raise "File #{file} is empty! Not saving to #{@file}" if File.zero?(file)
|
|
103
|
+
return if File.read(file).include?(content)
|
|
104
|
+
|
|
105
|
+
raise "File #{file} does not contain correct content! Not saving to #{@file}"
|
|
106
|
+
end
|
|
107
|
+
|
|
91
108
|
def add(type, text, *args, **kwargs)
|
|
92
109
|
@toc << ul(link(text, text, anchor: true), indent: 0) if @with_toc && type == :h1
|
|
93
110
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: abide_dev_utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.14.
|
|
4
|
+
version: 0.14.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- abide-team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-03-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|