qb101 0.1.0 → 0.2.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/qb101.rb +21 -5
- data.tar.gz.sig +0 -0
- metadata +21 -1
- 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: 6b2005b433458222ad7b9a661d2192441b12bb13523f5b965e49856cc08ca9f2
|
4
|
+
data.tar.gz: 3964fbed3a74638293d9cd715addd70d96a139bafafc24bf6253d8fddb98f1b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4be36da8feac7cf9e982504189d9ffe18dd2542e5f5918cd206702a7eed1aa6302bf7ce6d0fc0c09e228d7ef9675a0a61bc8b992f5d9f09bc772658b8e911d04
|
7
|
+
data.tar.gz: 667ae1300ba19b874e79b0b84e31bc631a17b89ab4f98bde85000c316d0cc43af410ea842a2a6a2c76a3fdb09985c42701257b95bd4750256bacd4c3d2f780dc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/qb101.rb
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
|
10
10
|
require 'yatoc'
|
11
11
|
require 'polyrex-headings'
|
12
|
+
require 'kramdown'
|
12
13
|
|
13
14
|
|
14
15
|
# This file contains 2 classes, the question book class and
|
@@ -84,11 +85,15 @@ class Ab101
|
|
84
85
|
|
85
86
|
# note: the ab_xml file can be in CGRecorder log XML format
|
86
87
|
|
87
|
-
def initialize(
|
88
|
+
def initialize(qb, ab_xml=nil, filepath: '.', debug: false)
|
88
89
|
|
89
90
|
@debug = debug
|
90
91
|
|
91
|
-
@qb =
|
92
|
+
@qb = if qb.is_a?(String) and qb.lines.length < 2 then
|
93
|
+
Qb101.new(qb)
|
94
|
+
elsif qb.kind_of?(Qb101)
|
95
|
+
qb
|
96
|
+
end
|
92
97
|
|
93
98
|
@dx = Dynarex.new('book[title, tags]/item(question, answer)')
|
94
99
|
@dx.title = @qb.title
|
@@ -153,9 +158,21 @@ class Ab101
|
|
153
158
|
puts 'answers: ' + answers.inspect if @debug
|
154
159
|
|
155
160
|
doc.root.xpath('//p').each.with_index do |para, i|
|
161
|
+
|
162
|
+
|
163
|
+
s = answers[i].strip
|
156
164
|
|
157
|
-
e =
|
158
|
-
|
165
|
+
e = if s.lines.length > 1 then
|
166
|
+
|
167
|
+
html = "<span>%s</span>" % Kramdown::Document.new(s).to_html
|
168
|
+
Rexle.new(html).root
|
169
|
+
|
170
|
+
else
|
171
|
+
|
172
|
+
Rexle::Element.new('p', attributes: {class: 'answer'})\
|
173
|
+
.add_text s
|
174
|
+
|
175
|
+
end
|
159
176
|
para.insert_after e
|
160
177
|
|
161
178
|
end
|
@@ -168,4 +185,3 @@ class Ab101
|
|
168
185
|
end
|
169
186
|
|
170
187
|
end
|
171
|
-
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qb101
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -58,6 +58,26 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 0.3.5
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: kramdown
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '2.4'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.4.0
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.4'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.4.0
|
61
81
|
description:
|
62
82
|
email: digital.robertson@gmail.com
|
63
83
|
executables: []
|
metadata.gz.sig
CHANGED
Binary file
|