mdfiller 1.0.1 → 1.0.2
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/exe/mdf +1 -1
- data/lib/mdfiller/fill.rb +34 -11
- data/lib/mdfiller/filler.rb +20 -7
- data/lib/mdfiller/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: 829fac8da21f190e3b781b09afc6c11c0490b465fd3f1002e36163c0a6e43e6b
|
4
|
+
data.tar.gz: 076afda04c3107d70a7d9481cdf2a2ce7ce41c330d8dc02741217072f5352b42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e442c66588c268590759eaa73c0928254d4e4768b981e4680f8b0d06fd2e91ca6530e52709fc27b9b0e58f5b78840237f3ab1a1eada781f3749f6de9c775de9
|
7
|
+
data.tar.gz: ee16e5723cdc6d7b05ec84cfd43d684d0135110d41b5c8e5d3034d5a7bb0e8eda336280d34ef0036ee71992f680d6a6fb8adec35dc1e151bd0c6f3a7b75723b1
|
data/exe/mdf
CHANGED
data/lib/mdfiller/fill.rb
CHANGED
@@ -18,19 +18,30 @@ module Mdfiller
|
|
18
18
|
return copy_files
|
19
19
|
end
|
20
20
|
|
21
|
+
def empty?
|
22
|
+
return self.files.empty?
|
23
|
+
end
|
24
|
+
|
21
25
|
protected
|
22
26
|
|
23
27
|
def copy_files
|
24
28
|
result = ''
|
25
29
|
self.files.each do
|
26
30
|
|fname|
|
27
|
-
result +=
|
28
|
-
result += "```#{self.soft}\n"
|
29
|
-
File.open(File.join(self.dir, fname), 'r') { |fh| result += fh.readlines.join }
|
30
|
-
result += "```\n\n"
|
31
|
+
result += copy_file(fname)
|
31
32
|
end
|
32
33
|
return result
|
33
34
|
end
|
35
|
+
|
36
|
+
def copy_file(fname)
|
37
|
+
result = ''
|
38
|
+
result += "\n[#{fname}](#{self.dir}/#{fname})\n"
|
39
|
+
result += "```#{self.soft}\n"
|
40
|
+
File.open(File.join(self.dir, fname), 'r') { |fh| result += fh.readlines.join }
|
41
|
+
result += "```\n\n"
|
42
|
+
return result
|
43
|
+
end
|
44
|
+
|
34
45
|
end
|
35
46
|
|
36
47
|
class OrcAndScoFill < Base
|
@@ -60,18 +71,30 @@ module Mdfiller
|
|
60
71
|
result = ''
|
61
72
|
self.files.each do
|
62
73
|
|fname|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
74
|
+
if has_plots?(fname)
|
75
|
+
pngname = File.basename("#{fname}", ".py") + '.png'
|
76
|
+
result += "\n[#{fname}](#{self.dir}/#{fname})\n```#{self.soft}\n"
|
77
|
+
File.open(File.join(self.dir, fname), 'r') { |fh| result += fh.readlines.join }
|
78
|
+
IO.popen("(cat #{self.dir}/#{fname} | sed -e '/^plt.show()$/d'; echo \"plt.savefig('#{self.dir}/#{pngname}')\") | python3") do
|
79
|
+
|ioh|
|
80
|
+
result += ioh.readlines.join
|
81
|
+
end
|
82
|
+
result += "```\n\nPlot prodotto:\n\n\n\n"
|
83
|
+
else
|
84
|
+
result += copy_file(fname)
|
69
85
|
end
|
70
|
-
result += "```\n\nPlot prodotto:\n\n\n\n"
|
71
86
|
end
|
72
87
|
return result
|
73
88
|
end
|
74
89
|
|
90
|
+
def has_plots?(fname)
|
91
|
+
result = false
|
92
|
+
lines = nil
|
93
|
+
File.open(File.join(self.dir, fname), 'r') { |fh| lines = fh.readlines }
|
94
|
+
result = true if !lines.grep(/plt\.show()/).empty?
|
95
|
+
return result
|
96
|
+
end
|
97
|
+
|
75
98
|
end
|
76
99
|
|
77
100
|
class PngFill < Base
|
data/lib/mdfiller/filler.rb
CHANGED
@@ -17,13 +17,17 @@ module Mdfiller
|
|
17
17
|
|
18
18
|
def generate
|
19
19
|
result = header
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
if !self.pngs.empty?
|
21
|
+
result += "\n### Lavagne\n\n"
|
22
|
+
result += self.pngs.fill
|
23
|
+
end
|
24
|
+
if self.has_code?
|
25
|
+
result += "\n### Codice\n\n"
|
26
|
+
result += self.orcs_and_scos.fill
|
27
|
+
result += self.csds.fill
|
28
|
+
result += self.pys.fill
|
29
|
+
result += self.pds.fill
|
30
|
+
end
|
27
31
|
return result
|
28
32
|
end
|
29
33
|
|
@@ -62,6 +66,15 @@ module Mdfiller
|
|
62
66
|
return Dir.glob(File.join("#{self.dir}", "*#{sfx}")).map { |f| File.basename(f) }
|
63
67
|
end
|
64
68
|
|
69
|
+
def has_code?
|
70
|
+
result = false
|
71
|
+
[ self.orcs_and_scos, self.csds, self.pys, self.pds ].each do
|
72
|
+
|code|
|
73
|
+
result |= true unless code.empty?
|
74
|
+
end
|
75
|
+
return result
|
76
|
+
end
|
77
|
+
|
65
78
|
end
|
66
79
|
|
67
80
|
end
|
data/lib/mdfiller/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mdfiller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicola Bernardini
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date: 2024-11-
|
10
|
+
date: 2024-11-21 00:00:00.000000000 Z
|
11
11
|
dependencies: []
|
12
12
|
description: mdfiller fills the README.md of each lesson with all its details
|
13
13
|
email:
|