alexa_modelmd 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 499eae5acbf043e53bdd1e62cfd624bb57ffcebad1e4e23df34cf96711ae657d
4
- data.tar.gz: 1ce53b8fa1435ea666cb4f73521b84d28f418cd7a8874df38d2bc693c8dd19a7
3
+ metadata.gz: 931dd4f95568c38f4b72be68187e58c4eaaa67837addb03821b4decd6f361b1c
4
+ data.tar.gz: dafda91844eee179508f633bd1a7508dc90cb05a62edc6e6a9ba06701c455020
5
5
  SHA512:
6
- metadata.gz: a2778c94dde9a5228261b7122b4ef49d9afd0670e5158e6da34f224501d863299aae47b23dfc055a309a4eaef1e47720899ef9d87117e81bb0ab900860c417ef
7
- data.tar.gz: 422c9b8a4fb55e1dd27a0074ea5bbd31a70f2d6ee45bd421416b4b1fe09e22e276bc816a1afec3a65ce723aa1666134a2095a39ce77dbc9a3d80e61f87b0455d
6
+ metadata.gz: 9b8b9d99558922e18aa30981d8a18a387f215db6a980e9afc9eadaf8add3fa835525221b165d24c57d3eedc05b9fc9849c95ac813beaedb1ee9dde7f3f7bc49c
7
+ data.tar.gz: 24b45dbc8e4c055db1478ce76792527ccc7164962cca39319388fdb3d08cfc9990e44c31e269f5c76889085d0bc3231abcf140e128af108396426adc5bbd14e3
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/alexa_modelmd.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # file: alexa_modelmd.rb
4
4
 
5
5
  # description: Using a WikiMd foramtted document, generates a basic Amazon
6
- # Alexa model in XML format, as well as other formats ... soon.
6
+ # Alexa model in XML format, as well as other formats.
7
7
 
8
8
 
9
9
  require 'wiki_md'
@@ -12,15 +12,19 @@ require 'wiki_md'
12
12
  class AlexaModelMd < WikiMd
13
13
 
14
14
  class Intent
15
+ using ColouredText
15
16
 
16
17
  attr_reader :name, :utterances, :code
17
18
 
18
- def initialize(s)
19
-
19
+ def initialize(s, debug: false)
20
+
21
+ @debug = debug
22
+ puts ('Intent | s: ' + s.inspect).debug if @debug
20
23
  doc = Rexle.new("<root9>%s</root9>" % \
21
24
  Kramdown::Document.new(Martile.new(s).to_s).to_html)
22
25
  @name = doc.root.element('h2/text()').to_s
23
26
  @utterances = doc.root.xpath('ul/li/text()').map(&:to_s)
27
+ puts ('doc: ' + doc.root.xml.inspect).debug if @debug
24
28
  @code = doc.root.element('//code/text()').to_s
25
29
 
26
30
  end
@@ -34,7 +38,8 @@ class AlexaModelMd < WikiMd
34
38
  r.map do |entry|
35
39
 
36
40
  def entry.intents()
37
- self.body().split(/(?=^## )/).map {|x| Intent.new(x)}
41
+ puts 'entries | x: ' + x.inspect if @debug
42
+ self.body().split(/(?=^## )/).map {|x| Intent.new(x, debug: @debug)}
38
43
  end
39
44
 
40
45
  entry
@@ -43,6 +48,12 @@ class AlexaModelMd < WikiMd
43
48
 
44
49
  end
45
50
 
51
+ # Transforms the document into an Alexa_modelmd formatted document
52
+ #
53
+ def to_md
54
+ Rexslt.new(md_xslt(), to_xml(), debug: @debug).to_s
55
+ end
56
+
46
57
  # This generates a plain text file representing the Alexa Model to be
47
58
  # built using the alexa_modelbuilder gem
48
59
  #
@@ -50,8 +61,10 @@ class AlexaModelMd < WikiMd
50
61
  Rexslt.new(modelbuilder_xslt(), to_xml()).to_s
51
62
  end
52
63
 
64
+ alias to_txt to_modelb
65
+
53
66
  def to_rsf
54
- Rexslt.new(rsf_xslt(), to_xml(), debug: @debug).to_xml
67
+ Rexslt.new(rsf_xslt(), to_xml(), debug: @debug).to_s
55
68
  end
56
69
 
57
70
  def to_xml()
@@ -70,7 +83,7 @@ class AlexaModelMd < WikiMd
70
83
  entries.each do |entry|
71
84
 
72
85
  xml.entry do
73
- xml.topic entry.heading
86
+ xml.topic entry.heading.strip
74
87
 
75
88
  xml.intents do
76
89
  entry.intents.each do |intent|
@@ -92,6 +105,12 @@ class AlexaModelMd < WikiMd
92
105
  end
93
106
  end #/intents
94
107
 
108
+ xml.tags do
109
+ entry.tags.each do |tag|
110
+ xml.tag tag
111
+ end
112
+ end
113
+
95
114
  end
96
115
  end
97
116
  end #/entries
@@ -196,6 +215,65 @@ EOF
196
215
  </xsl:template>
197
216
 
198
217
 
218
+ </xsl:stylesheet>
219
+ EOF
220
+ end
221
+
222
+ def md_xslt()
223
+ <<EOF
224
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
225
+ <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
226
+
227
+ <xsl:template match='model'>
228
+ <xsl:text disable-output-escaping="yes">&lt;?dynarex schema="sections[title, invocation, endpoint]/section(x)" format_mask="[!x]"?&gt;</xsl:text>
229
+ title: <xsl:value-of select='summary/title'/>
230
+ invocation: <xsl:value-of select='summary/invocation'/>
231
+ endpoint: <xsl:value-of select='summary/endpoint'/>
232
+ --#
233
+ <xsl:apply-templates select='entries/entry' />
234
+ <xsl:text>
235
+ </xsl:text>
236
+
237
+ </xsl:template>
238
+
239
+ <xsl:template match='entries/entry'>
240
+ <xsl:text>
241
+ </xsl:text>
242
+ <xsl:text># </xsl:text><xsl:value-of select='topic' /><xsl:text> </xsl:text>
243
+
244
+ <xsl:apply-templates select='intents/intent' /><xsl:text>
245
+
246
+ +</xsl:text>
247
+ <xsl:apply-templates select='tags/tag' />
248
+ <xsl:text>
249
+ </xsl:text>
250
+
251
+ </xsl:template>
252
+
253
+ <xsl:template match='intents/intent'><xsl:text> </xsl:text>
254
+
255
+ <xsl:text>
256
+
257
+ ## </xsl:text><xsl:value-of select='name' /><xsl:text>
258
+ </xsl:text>
259
+
260
+ <xsl:apply-templates select='utterances/utterance' /><xsl:text>
261
+ </xsl:text>
262
+
263
+ <xsl:text>
264
+ `</xsl:text>
265
+ <xsl:value-of select='code' />
266
+ <xsl:text>`</xsl:text>
267
+
268
+ </xsl:template>
269
+
270
+ <xsl:template match='utterances/utterance'>
271
+ * <xsl:value-of select='.'/>
272
+ </xsl:template>
273
+
274
+ <xsl:template match='tags/tag'>
275
+ <xsl:text> </xsl:text><xsl:value-of select='.'/>
276
+ </xsl:template>
199
277
  </xsl:stylesheet>
200
278
  EOF
201
279
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_modelmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  RiKpAQ+I6BbdLUJTK2K+PB/nbZ6mul1+aS64XsSo/h49h7MP3lGxHFZyfX1RuE4j
36
36
  Uv6UCmrr9La+izsyIDyQli0u
37
37
  -----END CERTIFICATE-----
38
- date: 2019-02-02 00:00:00.000000000 Z
38
+ date: 2019-02-11 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: wiki_md
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0.7'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.7.5
49
+ version: 0.7.8
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,7 +56,7 @@ dependencies:
56
56
  version: '0.7'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.7.5
59
+ version: 0.7.8
60
60
  description:
61
61
  email: james@jamesrobertson.eu
62
62
  executables: []
metadata.gz.sig CHANGED
@@ -1,5 +1,3 @@
1
- ������V #�dY�|�dy;�UJ2������y��Ɵ���H0y����հ+Hc,�{ �N��AkϷA#x>p}YU37���ʥ�at�\�&�����" vM�=Q�&`u�K #�� �}l��x
2
- ^$蕃������>�
3
- ɖ����WR��u�˶��=��+7΍���``I���ƴ��"^���<�6a�|��������Sg
4
- �� ��nD�(����ā�$�Ha�SL�
5
- }lj�O6N���&�
1
+ Ci?�j�ɡJ .����ncM)��['}4>)%��+�op(QՄ���rB*8I�s��d�S�|\��ιt*u!Ob)]�ՈD����
2
+ n� � r
3
+ e�����g�����a$�5P �6�p��x)8J�*��t������j�O�3V��`Ըhg �ы���A�!o>