ruby_qb101 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/ruby_qb101.rb +9 -102
- data.tar.gz.sig +0 -0
- metadata +7 -27
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1c73397fa820b39755d0b882b724f6035e1abe89ab36b073ba83affb0a9da81
|
4
|
+
data.tar.gz: c53174ec89bbe82398b7147410a5fe2a17e8d82bdb32df5c95be056ed9336ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac956d7653a2510986952d171f0cf8f490bad312eca99cd7a042ebac904b6cdf9950a97deecfe3e63a85ef240c4f909228b9cded083890770947c6d2e4fc66de
|
7
|
+
data.tar.gz: 7ab5fb75f4c9227ddd72ea4b0aaa9219c42f0c7f154abbf72e8e659ad6419b65526511dd5c65390b2fb08bd6c4ce2a12a57f9d14cd6eb81b14ee262cbaf47e9b
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/ruby_qb101.rb
CHANGED
@@ -5,128 +5,35 @@
|
|
5
5
|
# Description: Ruby related questions to ask Chat GPT. #experimental
|
6
6
|
# see https://github.com/jrobertson/ruby_qb101/blob/main/data/ruby_qb101.txt for questions used
|
7
7
|
|
8
|
-
require '
|
9
|
-
|
8
|
+
require 'qb101'
|
9
|
+
|
10
10
|
|
11
11
|
|
12
12
|
# This file contains 2 classes, the question book class and
|
13
13
|
# the answer book class.
|
14
14
|
|
15
15
|
|
16
|
-
class Ruby_Qb101
|
16
|
+
class Ruby_Qb101 < Qb101
|
17
17
|
|
18
18
|
def initialize(questions_file=nil)
|
19
19
|
|
20
20
|
questions_file ||= File.join(File.dirname(__FILE__), '..',
|
21
21
|
'data', 'ruby_qb101.txt')
|
22
22
|
|
23
|
-
|
24
|
-
@questions = s[/#.*/m]
|
25
|
-
@px = PolyrexHeadings.new(s, debug: false).to_polyrex
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def question(id)
|
30
|
-
|
31
|
-
found = @px.find_by_id(id.to_s)
|
32
|
-
found.x if found
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
alias q question
|
37
|
-
|
38
|
-
def questions()
|
39
|
-
doc = Rexle.new('<root>' + self.to_html + '</root>')
|
40
|
-
a = doc.root.xpath('//p/text()').map(&:to_s)
|
41
|
-
end
|
23
|
+
super(questions_file)
|
42
24
|
|
43
|
-
def tags()
|
44
|
-
@px.summary.tags
|
45
25
|
end
|
46
26
|
|
47
|
-
def title()
|
48
|
-
@px.summary.title
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_md()
|
52
|
-
@questions
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_html()
|
56
|
-
s = @questions.strip.gsub(/^([^\n#].[^\n]+)[\n]+/,'\1' + "\n\n")
|
57
|
-
Kramdown::Document.new(s).to_html
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_toc()
|
61
|
-
Yatoc.new(self.to_html(), min_sections: 1)
|
62
|
-
end
|
63
|
-
|
64
|
-
def to_xml()
|
65
|
-
@px.to_xml(pretty: true)
|
66
|
-
end
|
67
|
-
|
68
27
|
end
|
69
28
|
|
70
|
-
class Ruby_Ab101
|
29
|
+
class Ruby_Ab101 < Ab101
|
71
30
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
@qb = Ruby_Qb101.new(qb_txt)
|
77
|
-
|
78
|
-
@dx = Dynarex.new('book[title, tags]/item(question, answer)')
|
79
|
-
@dx.title = @qb.title
|
80
|
-
@dx.tags = @qb.tags
|
81
|
-
|
82
|
-
@qb.questions.each {|q| @dx.create({question: q}) }
|
83
|
-
|
84
|
-
if ab_xml then
|
85
|
-
|
86
|
-
dx = Dynarex.new(ab_xml)
|
87
|
-
|
88
|
-
# using each question, find the associated answer and
|
89
|
-
# add it the main record
|
90
|
-
|
91
|
-
@qb.questions.each do |q|
|
92
|
-
|
93
|
-
found = dx.find_by_question q
|
94
|
-
|
95
|
-
if found then
|
96
|
-
rx = @dx.find_by_question q
|
97
|
-
rx.answer = found.answer
|
98
|
-
end
|
31
|
+
# note: the ab_xml file can be in CGRecorder log XML format
|
32
|
+
|
33
|
+
def initialize(qb, ab_xml=nil, filepath: '.', debug: false)
|
99
34
|
|
100
|
-
|
101
|
-
|
102
|
-
@dx.save ab_xml
|
103
|
-
|
104
|
-
end
|
105
|
-
|
35
|
+
super(qb, ab_xml, filepath: filepath, debug: debug)
|
106
36
|
end
|
107
37
|
|
108
|
-
def save(filename)
|
109
|
-
@dx.save filename
|
110
|
-
end
|
111
|
-
|
112
|
-
def to_html()
|
113
|
-
|
114
|
-
doc = Rexle.new('<body>' + @qb.to_html.gsub(/<p>[^>]+>/,'<div>\0</div>') \
|
115
|
-
+ '</body>')
|
116
|
-
answers = @dx.all.map(&:answer)
|
117
|
-
|
118
|
-
puts 'answers: ' + answers.inspect if @debug
|
119
|
-
|
120
|
-
doc.root.xpath('//p').each.with_index do |para, i|
|
121
|
-
e = Rexle::Element.new('p', attributes: {class: 'answer'}).add_text answers[i]
|
122
|
-
para.insert_after e
|
123
|
-
end
|
124
|
-
|
125
|
-
doc.root.xml pretty: true
|
126
|
-
end
|
127
|
-
|
128
|
-
def to_xml()
|
129
|
-
@dx.to_xml(pretty: true)
|
130
|
-
end
|
131
38
|
|
132
39
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_qb101
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -36,48 +36,28 @@ cert_chain:
|
|
36
36
|
bGVzx0RTtnomJUcww7L+cStXvNaGrg+DX+sCtqD5OMHyGROrZb0UHBgTZixAfZGU
|
37
37
|
zfFnOLNq11nlIwZsUbPNwuNZQVZuB+GhTGc=
|
38
38
|
-----END CERTIFICATE-----
|
39
|
-
date: 2023-
|
39
|
+
date: 2023-03-15 00:00:00.000000000 Z
|
40
40
|
dependencies:
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: qb101
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0.
|
47
|
+
version: '0.2'
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0.
|
50
|
+
version: 0.2.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '0.
|
57
|
+
version: '0.2'
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: polyrex-headings
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - "~>"
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0.3'
|
68
|
-
- - ">="
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: 0.3.0
|
71
|
-
type: :runtime
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
requirements:
|
75
|
-
- - "~>"
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0.3'
|
78
|
-
- - ">="
|
79
|
-
- !ruby/object:Gem::Version
|
80
|
-
version: 0.3.0
|
60
|
+
version: 0.2.0
|
81
61
|
description:
|
82
62
|
email: digital.robertson@gmail.com
|
83
63
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|