alexa_modelbuilder 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a547500e95eeeadcec607967625ad47db8e74ae7
4
- data.tar.gz: b83dd6487e2774444abbdb2df0594eccd939a872
3
+ metadata.gz: 8c5c978765d3aa5439483ae534a87d4b37424b09
4
+ data.tar.gz: 2e70d2a03514580b93fd33a816dcbb790f4059e4
5
5
  SHA512:
6
- metadata.gz: a61d11aee196ce8c44ef060395d77db5add8c9f270cb9d17650188228f0828b80ee39ea66dad5f9d94519131cda3b968875e8c0ffcd9240bf388dc12883ae8d6
7
- data.tar.gz: cd26e6b949d90941f6f36feefcba5178a69fdee3a7ec7bdc61fd5d444414a78710e5f140b24dacccfa5214eb13a0f841d4e79555df9346fc11b88346ecc6b3c0
6
+ metadata.gz: 56434970f521ff0a790dcf9eda19daf899237a3d50a8a2db29171e731c757e68bed895f7d68fe742e83a1a9f323d039c3cb99339c415e08ba77172766297838a
7
+ data.tar.gz: 708e299b5b3be0894fcaa4d9d9eb25330064509147ea196212f373923ed74894aeb6faab2e10155a0396f7d4bb8deb0a8e52527a1800900d2f3f22976e3c68fe
Binary file
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- m4�؍$sr���1��x��3�e���_0���Xk8Je��A���>�]�ֲ�T����a������g$Zy l }��}9��f�d5r��>�!�]]=i m Jː�Ĝ�y�&��0&��=���
2
- � �&5'"�������%�m�����h�G��P�噞^���9�������$/�gZHŒ���027����Sr���1V�g��I!s{�U�X��(�7���D�`�M�U2��
1
+ (>�e�����vƃ��`���y{v>������o%-�^6��ߘ“n7�.% ��l���c�TBهi��yA-��2��9��e��u�U����P�M������.���0E�U���;�epԣ3�pOy��92iV��<묧�!t(��բmQ������th��ۺ�=����~�F_qO�����f٢S4�� ����s���d��4(ʂH�##+�"uͶv����<�!!��p ��I
@@ -9,9 +9,9 @@ require 'lineparser'
9
9
 
10
10
  class AlexaModelBuilder
11
11
 
12
- def initialize(s=nil, debug: false)
12
+ def initialize(s=nil, debug: false, locale: 'en-GB')
13
13
 
14
- @debug = debug
14
+ @debug, @locale = debug, locale
15
15
  parse(s) if s
16
16
 
17
17
  end
@@ -80,7 +80,106 @@ class AlexaModelBuilder
80
80
  end
81
81
 
82
82
  def to_h()
83
- @interact_model
83
+ @h
84
+ end
85
+
86
+ def to_manifest()
87
+ JSON.pretty_generate(@manifest)
88
+ end
89
+
90
+ ## A guideline of fields to include within the raw document
91
+
92
+ =begin
93
+ manifest
94
+
95
+ vendorId: [generate from vendors.first]
96
+ locale: input (default)
97
+ name: input
98
+ summary: input (default)
99
+ description: input (default)
100
+ keywords: input (default)
101
+ examplePhrases: [generate from intent utterances]
102
+ testingInstructions: input [generate from intent utterances]
103
+ endpoint: input
104
+ =end
105
+
106
+ def build_manifest(h)
107
+
108
+ manifest = {
109
+ "vendorId" => 'YOUR_VENDOR_ID',
110
+ "manifest" => {
111
+ "publishingInformation" => {
112
+ "locales" => {
113
+ },
114
+ "isAvailableWorldwide" => false,
115
+ "testingInstructions" => "1) Say 'Alexa, say something'",
116
+ "category" => "SMART_HOME",
117
+ "distributionCountries" => [
118
+ ]
119
+ },
120
+ "apis" => {
121
+ "custom" => {
122
+ "endpoint" => {
123
+ "uri" => "https://someserver.com/alexaskills"
124
+ }
125
+ }
126
+ },
127
+ "manifestVersion" => "1.0",
128
+ "privacyAndCompliance" => {
129
+ "allowsPurchases" => false,
130
+ "locales" => {
131
+ },
132
+ "isExportCompliant" => true,
133
+ "isChildDirected" => false,
134
+ "usesPersonalInfo" => false
135
+ }
136
+ }
137
+ }
138
+
139
+ manifest['vendorId'] = h[:vendor_id] if h[:vendor_id]
140
+ m = manifest['manifest']
141
+
142
+ h[:locale] ||= @locale
143
+
144
+
145
+ info = {}
146
+ info['summary'] = h[:summary] || h[:name]
147
+
148
+ examples = ["Alexa, open %s." % h[:invocation]]
149
+ examples += h[:intent].select{|x| x.is_a? Array}.take(2).map do |x|
150
+ "Alexa, %s." % x.first[-1][:utterance].first
151
+ end
152
+
153
+ info['examplePhrases'] = examples
154
+ info['keywords'] = h[:keywords] ? h[:keywords] : \
155
+ h[:name].split.map(&:downcase)
156
+
157
+ info['name'] = h[:name] if h[:name]
158
+ info['description'] = h[:description] || info['summary']
159
+
160
+ m['publishingInformation']['locales'] = {h[:locale] => info}
161
+ countries = {gb: %w(GB US), us: %w(US GB)}
162
+ m['publishingInformation']['distributionCountries'] = \
163
+ countries[h[:locale][/[A-Z]+/].downcase.to_sym]
164
+ m['apis']['custom']['endpoint']['uri'] = h[:endpoint] if h[:endpoint]
165
+
166
+ toc = {
167
+ 'termsOfUseUrl' => 'http://www.termsofuse.sampleskill.com',
168
+ 'privacyPolicyUrl' => 'http://www.myprivacypolicy.sampleskill.com'
169
+ }
170
+ m['privacyAndCompliance']['locales'] = {h[:locale] => toc}
171
+
172
+
173
+ instruct = ["open %s" % h[:invocation]]
174
+ tests = instruct.map.with_index {|x, i| "%s) Say 'Alexa, %s'" % [i+1, x]}
175
+ m['publishingInformation']['testingInstructions'] = tests.join(' ')
176
+
177
+ manifest
178
+ end
179
+
180
+
181
+ def to_model()
182
+ JSON.pretty_generate(@interact_model)
84
183
  end
85
184
 
86
185
  def to_json(pretty: true)
@@ -130,7 +229,7 @@ class AlexaModelBuilder
130
229
  puts 'a2: ' + a2.inspect if @debug
131
230
  lp = LineParser.new a2, debug: @debug
132
231
  lp.parse lines
133
- h = lp.to_h
232
+ @h = h = lp.to_h
134
233
  puts 'h: ' + h.inspect if @debug
135
234
 
136
235
  model = {
@@ -200,6 +299,7 @@ class AlexaModelBuilder
200
299
 
201
300
  end
202
301
 
302
+ @manifest = build_manifest h
203
303
  @interact_model = model
204
304
 
205
305
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_modelbuilder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: '0.1'
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 0.1.16
44
+ version: 0.1.19
45
45
  type: :runtime
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  version: '0.1'
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.16
54
+ version: 0.1.19
55
55
  description:
56
56
  email: james@jamesrobertson.eu
57
57
  executables: []
@@ -82,5 +82,6 @@ rubyforge_project:
82
82
  rubygems_version: 2.6.13
83
83
  signing_key:
84
84
  specification_version: 4
85
- summary: Builds an Alexa Interaction Model in JSON format from plain text
85
+ summary: Builds an Alexa Skills Interaction Model and optionally an Alexa Skills manigest
86
+ in JSON format from plain text
86
87
  test_files: []
metadata.gz.sig CHANGED
Binary file