natter 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: e82826a5f958086cdf0af5610b338c96485193d7
4
- data.tar.gz: abcc661c8395a04a9b6efe86ac34d97ecd94e476
3
+ metadata.gz: 5a6a81b4f77164c15d606c99eca84daf1e6480a7
4
+ data.tar.gz: b8ba3a671260c6d0af840b52735edf6e51baf5a2
5
5
  SHA512:
6
- metadata.gz: 989c2bf070947318c652f982308b36af1c54ba65f50f0ff58a7e8949bbb7c2427bcef167e572c01188ab3937a0a6a9d961686f8a7bdd90393d70060eae4caae3
7
- data.tar.gz: d3ba8862c8cc6950c41ea17bc5f3cc88febbb16eb8f03059385a79d5012ec872509d92183448a9b3f3356e7be559083d59cb6dd56226baae52f1bcddd215d624
6
+ metadata.gz: 4a90a933ea1cc37fdf54d55f11b5606ac3f6df89d146d9b016314b3265b953e501fcc0e9bf16dc40a8636d82c3cf11a04162afe19088cb1f61a7b834ec14d433
7
+ data.tar.gz: 17f4b32482cac81f39f8e5fbdb43540d91db98d58087768cd658de8d5edf9dc3ae4e69ee37a72ce4431d1111a340896254db602c7f3db5d0a066a55d8d50585f
@@ -4,14 +4,16 @@ module Natter
4
4
  # occurs within an utterance.
5
5
 
6
6
  class Rule
7
-
7
+ # Identifier for rules added without an owning skill.
8
+ NO_SKILL = "_None"
9
+
8
10
  # The string name of this rule. Defferent rules can share the same name.
9
11
  attr_accessor :name
10
12
  # The regex pattern to search for within the an utterance.
11
13
  attr_accessor :pattern
12
14
  # An array of Entity objects this rule expects. May be empty.
13
15
  attr_accessor :entities
14
- # The name of the skill that this rule belongs to. May be '' if global.
16
+ # The name of the skill that this rule belongs to.
15
17
  attr_accessor :skill
16
18
 
17
19
  # Public: Constructor.
@@ -22,15 +24,16 @@ module Natter
22
24
  # utterance. If this intent contains entities then the regex
23
25
  # must capture the entities within the utterance as named
24
26
  # capture groups. See examples below. Default: //
25
- # skill - The name of the skill that this rule belongs to. If none is
26
- # specified then we'll assume it's a global rule (default: '').
27
+ # skill - The name of the skill that this rule belongs to. The first
28
+ # letter will be capitalised (e.g. `sonos` => `Sonos`). If none
29
+ # is passed then is set to Rule::NO_SKILL
27
30
  # entities - Optional array of Entity objects in the form:
28
31
  # Each entity must have a correspondingly named capture group
29
32
  # within the regex.
30
- def initialize(name, pattern = //, skill = '', *entities)
33
+ def initialize(name, pattern = //, skill = NO_SKILL, *entities)
31
34
  @name = name
32
35
  @pattern = pattern
33
- @skill = skill
36
+ skill == NO_SKILL ? @skill = NO_SKILL : @skill = skill.capitalize
34
37
  @entities = entities || []
35
38
  end
36
39
 
@@ -50,16 +53,17 @@ module Natter
50
53
  return self
51
54
  end
52
55
 
53
- # Public: Returns this rule's identifier. An identifier is in the format:
54
- # skill.name unless skill = '' in which case we return global.name
56
+ # Public: Returns this rule's identifier.
57
+ # An identifier is in the format `skill.name`.
55
58
  #
56
- # Returns string
59
+ # Returns a string.
57
60
  def identifier
58
- "#{@skill == '' ? 'global' : @skill}.#{@name}"
61
+ "#{@skill}.#{@name}"
59
62
  end
60
63
 
61
64
  # Public: A convenience method to permit prettier building of rules.
62
65
  # Returns the Rule back to the calling method to allowing chaining.
66
+ # The skill name will be capitalised (e.g. `sonos` => `Sonos`).
63
67
  #
64
68
  # skill - The name of the skill that this this rule belongs to.
65
69
  #
@@ -67,7 +71,7 @@ module Natter
67
71
  #
68
72
  # def = Rule.new('play').belongs_to('sonos')
69
73
  def belongs_to(skill)
70
- @skill = skill
74
+ @skill = skill.capitalize
71
75
  return self
72
76
  end
73
77
 
@@ -1,3 +1,3 @@
1
1
  module Natter
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garry Pettet