alexa_generator 0.3.1 → 0.3.2

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: 99ce7ef9324a3916c4bcb74eeec1b951d08b9528
4
- data.tar.gz: c90ada13a698c92ccb4d1b2d0b550de43ca15ce2
3
+ metadata.gz: aee459489effcc7826675de4ba5dc8b8f4565014
4
+ data.tar.gz: 27c1e1164ccc8a245323f3fe66e50526a92febd5
5
5
  SHA512:
6
- metadata.gz: 871ce5c20db59cb50c4e585c04810f12ca56770fbebc60e91b93e72b01b1305c7b00b998538081e17114e0fa9fa8b8c22840064100c923dcca6c9676bfd3cfa9
7
- data.tar.gz: b9c3c54b1c190e8616be539cfbd81cf7413ca61e0cfff925afaf58c7c9e08429ceff119e4f979235f6c00e68ead3a2ea2b6fc1e02387befb460937c67a9fc6e9
6
+ metadata.gz: 183ea342f89c463192ea44e39d677474a17b55458ca173aa1c30c9c7a6fa4d29277b815bb1d60f6281b7c25ec6ef3f67f25b8da276ac5d749ac7628a42e89610
7
+ data.tar.gz: fa998af973a54ae82761f5c82564a4a2a740b7a029d8448327595c8256863d73958c934a20397f486bf7188c033e24820e5bb690c18a42717e3c96aaed426dab
@@ -46,17 +46,21 @@ module AlexaGenerator
46
46
 
47
47
  def intent_schema
48
48
  intents = []
49
-
49
+
50
50
  @intents.values.each do |intent|
51
- slots = []
52
-
53
- intent.slots.each do |slot|
54
- slots << {name: slot.name, type: slot.type}
51
+ if intent.slots.any?
52
+ slots = []
53
+
54
+ intent.slots.each do |slot|
55
+ slots << {name: slot.name, type: slot.type}
56
+ end
57
+
58
+ intents << {intent: intent.name, slots: slots}
59
+ else
60
+ intents << {intent: intent.name}
55
61
  end
56
-
57
- intents << {intent: intent.name, slots: slots}
58
62
  end
59
-
63
+
60
64
  { intents: intents }
61
65
  end
62
66
 
@@ -70,8 +74,8 @@ module AlexaGenerator
70
74
  relevant_slots = template.referenced_slots
71
75
 
72
76
  # Amazon wants only the LITERAL ones
73
- relevant_slots.select! do |s|
74
- AlexaGenerator::Slot::SlotType.literal?(slot_types[s.to_sym])
77
+ relevant_slots.select! do |s|
78
+ AlexaGenerator::Slot::SlotType.literal?(slot_types[s.to_sym])
75
79
  end
76
80
 
77
81
  # Compute all possible value bindings for the relevant slots
@@ -108,7 +112,7 @@ module AlexaGenerator
108
112
  "#{intent_name} #{utterance}"
109
113
  end
110
114
  end
111
-
115
+
112
116
  def slot_type_values(slot_type)
113
117
  bindings = Set.new
114
118
  @intents.values.each do |intent|
@@ -120,7 +124,7 @@ module AlexaGenerator
120
124
  end
121
125
  bindings.to_a
122
126
  end
123
-
127
+
124
128
  def custom_slot_types
125
129
  slots = collect_slot_types
126
130
  custom_types = slots.values.select do |x|
@@ -145,4 +149,4 @@ module AlexaGenerator
145
149
  builder.create
146
150
  end
147
151
  end
148
- end
152
+ end
@@ -1,3 +1,3 @@
1
1
  module AlexaGenerator
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -53,8 +53,7 @@ describe AlexaGenerator::InteractionModel do
53
53
  {
54
54
  intents: [
55
55
  {
56
- intent: :"AMAZON.CancelIntent",
57
- slots: []
56
+ intent: :"AMAZON.CancelIntent"
58
57
  }
59
58
  ]
60
59
  })
@@ -77,8 +76,7 @@ describe AlexaGenerator::InteractionModel do
77
76
  {
78
77
  intents: [
79
78
  {
80
- intent: :"AMAZON.CancelIntent",
81
- slots: []
79
+ intent: :"AMAZON.CancelIntent"
82
80
  },
83
81
  {
84
82
  intent: :IntentOne,
@@ -175,7 +173,7 @@ describe AlexaGenerator::InteractionModel do
175
173
  AlexaGenerator::SlotBinding.new( :SlotThree, '6 a.m.' ),
176
174
  AlexaGenerator::SlotBinding.new( :SlotThree, 'noon' ),
177
175
  ]
178
-
176
+
179
177
  intents = [
180
178
  AlexaGenerator::Intent.new(
181
179
  :MyIntent, [
@@ -199,7 +197,7 @@ describe AlexaGenerator::InteractionModel do
199
197
  expect(actual).to include('MyIntent Alexa, please {make me a sandwich|SlotOne} {SlotTwo} at {SlotThree}')
200
198
  end
201
199
  end
202
-
200
+
203
201
  context 'with custom slot types' do
204
202
  model = AlexaGenerator::InteractionModel.build do |iface|
205
203
  iface.add_intent(:IntentOne) do |intent|
@@ -207,31 +205,31 @@ describe AlexaGenerator::InteractionModel do
207
205
  slot.add_bindings(*%w(value1 value2 value3))
208
206
  end
209
207
  end
210
-
208
+
211
209
  iface.add_intent(:IntentTwo) do |intent|
212
210
  intent.add_slot(:SlotA, 'SlotType1') do |slot|
213
211
  slot.add_binding('value4')
214
212
  end
215
-
213
+
216
214
  intent.add_slot(:SlotB, :SlotType2) do |slot|
217
215
  slot.add_binding('valueA')
218
216
  end
219
-
217
+
220
218
  intent.add_slot(:SlabC, AlexaGenerator::Slot::SlotType::NUMBER)
221
219
  end
222
220
  end
223
-
221
+
224
222
  it 'should map slot bindings appropriately' do
225
223
  expect(model.custom_slot_types).to contain_exactly(*%w(SlotType1 SlotType2))
226
-
224
+
227
225
  type1_bindings = model.slot_type_values('SlotType1')
228
226
  expect(type1_bindings).to contain_exactly(*%w(value1 value2 value3 value4))
229
-
227
+
230
228
  type2_bindings = model.slot_type_values('SlotType2')
231
229
  expect(type2_bindings).to contain_exactly(*%w(valueA))
232
230
  end
233
231
  end
234
-
232
+
235
233
  context 'with slots not having bindings' do
236
234
  it 'should work' do
237
235
  model = AlexaGenerator::InteractionModel.build do |iface|
@@ -242,4 +240,22 @@ describe AlexaGenerator::InteractionModel do
242
240
  end
243
241
  end
244
242
  end
245
- end
243
+
244
+ context 'with no slots' do
245
+ it 'should not show the slots field' do
246
+ iface = AlexaGenerator::InteractionModel.build do |iface|
247
+ iface.add_intent(AlexaGenerator::Intent::AmazonIntentType::CANCEL)
248
+ end
249
+
250
+ expect(iface).to be_an_instance_of(AlexaGenerator::InteractionModel)
251
+ expect(iface.intent_schema).to eq(
252
+ {
253
+ intents: [
254
+ {
255
+ intent: :"AMAZON.CancelIntent"
256
+ }
257
+ ]
258
+ })
259
+ end
260
+ end
261
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alexa_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mullins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec