zenlish 0.2.05 → 0.2.07

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.
Files changed (173) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +228 -0
  3. data/CHANGELOG.md +19 -0
  4. data/Gemfile +5 -3
  5. data/LICENSE.txt +1 -1
  6. data/Rakefile +5 -3
  7. data/lib/zenlish/feature/boolean_domain.rb +6 -4
  8. data/lib/zenlish/feature/boolean_value.rb +3 -2
  9. data/lib/zenlish/feature/enumeration_domain.rb +5 -2
  10. data/lib/zenlish/feature/feature.rb +9 -7
  11. data/lib/zenlish/feature/feature_def.rb +9 -6
  12. data/lib/zenlish/feature/feature_domain.rb +4 -2
  13. data/lib/zenlish/feature/feature_struct.rb +3 -1
  14. data/lib/zenlish/feature/feature_struct_def.rb +5 -3
  15. data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
  16. data/lib/zenlish/feature/feature_value.rb +4 -2
  17. data/lib/zenlish/feature/identifier_domain.rb +5 -3
  18. data/lib/zenlish/feature/identifier_value.rb +3 -2
  19. data/lib/zenlish/feature/symbol_value.rb +3 -1
  20. data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
  21. data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
  22. data/lib/zenlish/inflect/concatenation.rb +3 -2
  23. data/lib/zenlish/inflect/equals_literal.rb +3 -1
  24. data/lib/zenlish/inflect/feature_heading.rb +2 -5
  25. data/lib/zenlish/inflect/formal_argument.rb +3 -1
  26. data/lib/zenlish/inflect/function_call.rb +4 -1
  27. data/lib/zenlish/inflect/heading.rb +2 -0
  28. data/lib/zenlish/inflect/inflection_rule.rb +2 -0
  29. data/lib/zenlish/inflect/inflection_table.rb +6 -4
  30. data/lib/zenlish/inflect/inflection_table_builder.rb +21 -18
  31. data/lib/zenlish/inflect/input_asis.rb +3 -0
  32. data/lib/zenlish/inflect/input_expression.rb +4 -2
  33. data/lib/zenlish/inflect/literal_asis.rb +4 -1
  34. data/lib/zenlish/inflect/matches_pattern.rb +2 -0
  35. data/lib/zenlish/inflect/membership.rb +2 -0
  36. data/lib/zenlish/inflect/method_heading.rb +3 -6
  37. data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
  38. data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
  39. data/lib/zenlish/inflect/output_expression.rb +6 -0
  40. data/lib/zenlish/inflect/substitution.rb +3 -1
  41. data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
  42. data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
  43. data/lib/zenlish/lang/dictionary.rb +19 -16
  44. data/lib/zenlish/lang/lemmatizer.rb +40 -0
  45. data/lib/zenlish/lang/zenlish_grammar.rb +6 -4
  46. data/lib/zenlish/lex/empty_lexicon_factory.rb +3 -2
  47. data/lib/zenlish/lex/lexeme.rb +6 -4
  48. data/lib/zenlish/lex/lexical_entry.rb +6 -4
  49. data/lib/zenlish/lex/lexicon.rb +4 -3
  50. data/lib/zenlish/lex/literal.rb +3 -1
  51. data/lib/zenlish/lexer/lexer.rb +144 -0
  52. data/lib/zenlish/trie/base_trie_node.rb +27 -0
  53. data/lib/zenlish/trie/trie.rb +132 -0
  54. data/lib/zenlish/trie/trie_node.rb +21 -0
  55. data/lib/zenlish/trie/trie_root.rb +10 -0
  56. data/lib/zenlish/version.rb +3 -1
  57. data/lib/zenlish/wclasses/adjective.rb +4 -2
  58. data/lib/zenlish/wclasses/adverb.rb +3 -1
  59. data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
  60. data/lib/zenlish/wclasses/adverb_not.rb +2 -0
  61. data/lib/zenlish/wclasses/all_word_classes.rb +3 -1
  62. data/lib/zenlish/wclasses/article.rb +2 -0
  63. data/lib/zenlish/wclasses/auxiliary.rb +2 -0
  64. data/lib/zenlish/wclasses/auxiliary_be.rb +7 -6
  65. data/lib/zenlish/wclasses/auxiliary_do.rb +6 -5
  66. data/lib/zenlish/wclasses/cardinal.rb +3 -1
  67. data/lib/zenlish/wclasses/common_noun.rb +2 -0
  68. data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
  69. data/lib/zenlish/wclasses/conjunction.rb +2 -0
  70. data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
  71. data/lib/zenlish/wclasses/coordinator.rb +4 -2
  72. data/lib/zenlish/wclasses/definite_article.rb +2 -0
  73. data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
  74. data/lib/zenlish/wclasses/demonstrative_determiner.rb +6 -4
  75. data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
  76. data/lib/zenlish/wclasses/determiner.rb +3 -1
  77. data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
  78. data/lib/zenlish/wclasses/existential_there.rb +2 -0
  79. data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
  80. data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
  81. data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
  82. data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
  83. data/lib/zenlish/wclasses/irregular_verb.rb +13 -15
  84. data/lib/zenlish/wclasses/irregular_verb_be.rb +8 -7
  85. data/lib/zenlish/wclasses/irregular_verb_can.rb +8 -7
  86. data/lib/zenlish/wclasses/irregular_verb_do.rb +7 -6
  87. data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -7
  88. data/lib/zenlish/wclasses/irregular_verb_have.rb +12 -11
  89. data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
  90. data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
  91. data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
  92. data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
  93. data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
  94. data/lib/zenlish/wclasses/modal_verb_can.rb +7 -5
  95. data/lib/zenlish/wclasses/noun.rb +4 -2
  96. data/lib/zenlish/wclasses/numeral.rb +2 -0
  97. data/lib/zenlish/wclasses/personal_pronoun.rb +8 -6
  98. data/lib/zenlish/wclasses/possessive_determiner.rb +13 -12
  99. data/lib/zenlish/wclasses/preposition.rb +3 -1
  100. data/lib/zenlish/wclasses/preposition_of.rb +2 -0
  101. data/lib/zenlish/wclasses/preposition_than.rb +2 -0
  102. data/lib/zenlish/wclasses/pronoun.rb +3 -1
  103. data/lib/zenlish/wclasses/proper_noun.rb +10 -8
  104. data/lib/zenlish/wclasses/quantifier.rb +3 -1
  105. data/lib/zenlish/wclasses/regular_verb.rb +9 -9
  106. data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
  107. data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
  108. data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
  109. data/lib/zenlish/wclasses/verb.rb +5 -3
  110. data/lib/zenlish/wclasses/word_class.rb +7 -5
  111. data/lib/zenlish.rb +3 -3
  112. data/spec/spec_helper.rb +3 -1
  113. data/spec/zenlish/feature/boolean_domain_spec.rb +16 -16
  114. data/spec/zenlish/feature/boolean_value_spec.rb +7 -6
  115. data/spec/zenlish/feature/enumeration_domain_spec.rb +21 -21
  116. data/spec/zenlish/feature/feature_def_spec.rb +15 -14
  117. data/spec/zenlish/feature/feature_spec.rb +17 -17
  118. data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +23 -21
  119. data/spec/zenlish/feature/feature_struct_def_spec.rb +26 -25
  120. data/spec/zenlish/feature/identifier_domain_spec.rb +15 -15
  121. data/spec/zenlish/feature/identifier_value_spec.rb +10 -9
  122. data/spec/zenlish/feature/symbol_value_spec.rb +9 -8
  123. data/spec/zenlish/inflect/concatenation_spec.rb +14 -14
  124. data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
  125. data/spec/zenlish/inflect/feature_heading_spec.rb +22 -21
  126. data/spec/zenlish/inflect/formal_argument_spec.rb +7 -7
  127. data/spec/zenlish/inflect/function_call_spec.rb +11 -12
  128. data/spec/zenlish/inflect/inflection_rule_spec.rb +28 -24
  129. data/spec/zenlish/inflect/inflection_table_builder_spec.rb +62 -57
  130. data/spec/zenlish/inflect/inflection_table_spec.rb +49 -46
  131. data/spec/zenlish/inflect/input_asis_spec.rb +12 -15
  132. data/spec/zenlish/inflect/literal_asis_spec.rb +10 -10
  133. data/spec/zenlish/inflect/matches_pattern_spec.rb +16 -15
  134. data/spec/zenlish/inflect/membership_spec.rb +17 -16
  135. data/spec/zenlish/inflect/method_heading_spec.rb +15 -14
  136. data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
  137. data/spec/zenlish/inflect/substitution_spec.rb +10 -11
  138. data/spec/zenlish/inflect/unconditionally_true_spec.rb +8 -6
  139. data/spec/zenlish/lang/dictionary_spec.rb +28 -31
  140. data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
  141. data/spec/zenlish/lang/zenlish_grammar_spec.rb +5 -5
  142. data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
  143. data/spec/zenlish/lex/lexeme_spec.rb +27 -28
  144. data/spec/zenlish/lex/lexical_entry_spec.rb +15 -15
  145. data/spec/zenlish/lex/lexicon_spec.rb +52 -50
  146. data/spec/zenlish/lex/literal_spec.rb +8 -8
  147. data/spec/zenlish/lexer/lexer_spec.rb +52 -0
  148. data/spec/zenlish/parser/lesson1_spec.rb +81 -81
  149. data/spec/zenlish/parser/lesson2_spec.rb +133 -138
  150. data/spec/zenlish/parser/lesson3_spec.rb +186 -226
  151. data/spec/zenlish/parser/zparser_spec.rb +8 -7
  152. data/spec/zenlish/support/minimal_lexicon.rb +2 -0
  153. data/spec/zenlish/support/var2word.rb +16 -9
  154. data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
  155. data/spec/zenlish/trie/trie_spec.rb +108 -0
  156. data/spec/zenlish/wclasses/common_noun_spec.rb +15 -19
  157. data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +12 -12
  158. data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +18 -18
  159. data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
  160. data/spec/zenlish/wclasses/irregular_verb_spec.rb +28 -28
  161. data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -9
  162. data/spec/zenlish/wclasses/modal_verb_can_spec.rb +12 -12
  163. data/spec/zenlish/wclasses/noun_spec.rb +7 -7
  164. data/spec/zenlish/wclasses/personal_pronoun_spec.rb +20 -23
  165. data/spec/zenlish/wclasses/possessive_determiner_spec.rb +28 -31
  166. data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
  167. data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
  168. data/spec/zenlish/wclasses/regular_verb_spec.rb +30 -30
  169. data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
  170. data/spec/zenlish/wclasses/verb_spec.rb +9 -9
  171. data/spec/zenlish_spec.rb +4 -2
  172. data/zenlish.gemspec +18 -14
  173. metadata +49 -16
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'regular_verb'
2
4
 
3
5
  module Zenlish
4
6
  module WClasses
5
7
  # The `want` verb like `need` allow the construct:
6
8
  # want + to + infinitive or progressive.
7
- class RegularVerbWant < IrregularVerb
9
+ class RegularVerbWant < RegularVerb
8
10
  end # class
9
11
  end # module
10
- end # module
12
+ end # module
@@ -1,12 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'pronoun'
2
4
 
3
5
  module Zenlish
4
6
  module WClasses
5
7
  # A relative pronoun refers to a noun that has already been mentionned,
6
- # and gives more information about that noun: who, whom, whose
8
+ # and gives more information about that noun: who, whom, whose
7
9
  # (for people) and which, what, that for things (and animals).
8
10
  # A relative pronoun introduces a relative clause.
9
11
  class RelativePronoun < Pronoun
10
12
  end # class
11
13
  end # module
12
- end # module
14
+ end # module
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'conjunction'
2
4
 
3
5
  module Zenlish
@@ -5,12 +7,12 @@ module Zenlish
5
7
  # A subordinating conjunction is a word or phrase that connects a dependent
6
8
  # clause to a main clause. The subordinating conjunction indicates how the
7
9
  # dependent clause adds informative value to the main clause. For instance,
8
- # by signaling a cause-and-effect relation, a shift in time or place between
9
- # the two clauses.
10
- # Common subordinating conjunctions: after, although, as, because, before,
11
- # how, if, once, since, than, that, though, till, until, when, where,
10
+ # by signaling a cause-and-effect relation, a shift in time or place between
11
+ # the two clauses.
12
+ # Common subordinating conjunctions: after, although, as, because, before,
13
+ # how, if, once, since, than, that, though, till, until, when, where,
12
14
  # whether, while
13
- class SubordinatingConjunction < WordClass
15
+ class SubordinatingConjunction < WordClass
14
16
  end # class
15
17
  end # module
16
18
  end # module
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'word_class'
2
4
  require_relative '../inflect/inflection_table_builder'
3
5
 
@@ -24,12 +26,12 @@ module Zenlish
24
26
 
25
27
  def init_feature_defs
26
28
  # Create standard feature definitions for lexical verbs.
27
- feature_def_dsl {
29
+ feature_def_dsl do
28
30
  feature_def 'NUMBER' => enumeration(:singular, :plural)
29
31
  feature_def 'PERSON' => enumeration(:first, :second, :third)
30
32
  feature_def 'TIME' => enumeration(:present, :progressive, :past_simple, :past_participle)
31
33
  feature_def 'PARADIGM' => [identifier, 'Regular_inflection'] # 2nd item is default value
32
- }
34
+ end
33
35
  end
34
36
 
35
37
  def init_paradigms
@@ -37,4 +39,4 @@ module Zenlish
37
39
  end
38
40
  end # class
39
41
  end # module
40
- end # module
42
+ end # module
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rley'
2
4
  require_relative '../feature/feature_struct_def_bearer'
3
5
 
@@ -29,19 +31,19 @@ module Zenlish
29
31
  # form.
30
32
  # @return [FalseClass, TrueClass] true iff the words in the class are invariable.
31
33
  def invariable?
32
- return true
34
+ true
33
35
  end
34
-
36
+
35
37
  # @return [Module, NilClass]
36
38
  def extension
37
39
  nil
38
40
  end
39
-
41
+
40
42
  protected
41
43
 
42
44
  def add_paradigm(anInflectionTable)
43
45
  @paradigms[anInflectionTable.name] = anInflectionTable
44
- end
46
+ end
45
47
  end # class
46
48
  end # module
47
- end # module
49
+ end # module
data/lib/zenlish.rb CHANGED
@@ -3,8 +3,8 @@
3
3
  # This file acts as a jumping-off point for loading dependencies expected
4
4
  # for a Zenlish client.
5
5
 
6
- require_relative './zenlish/version'
7
- require_relative './zenlish/lang/dictionary'
8
- require_relative './zenlish/parser/zparser'
6
+ require_relative 'zenlish/version'
7
+ require_relative 'zenlish/lang/dictionary'
8
+ require_relative 'zenlish/parser/zparser'
9
9
 
10
10
  # End of file
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/setup'
2
4
  require 'rspec' # Use the RSpec framework
3
5
 
4
6
  RSpec.configure do |config|
5
7
  # Enable flags like --only-failures and --next-failure
6
- config.example_status_persistence_file_path = ".rspec_status"
8
+ config.example_status_persistence_file_path = '.rspec_status'
7
9
 
8
10
  config.expect_with :rspec do |c|
9
11
  # Disable the `should` syntax
@@ -5,34 +5,34 @@ require_relative '../../../lib/zenlish/feature/boolean_domain' # Load the class
5
5
  module Zenlish
6
6
  module Feature
7
7
  describe BooleanDomain do
8
- subject { BooleanDomain.instance }
8
+ subject(:bool_dom) { described_class.instance }
9
9
 
10
10
  context 'Initialization:' do
11
- it 'should be initialized without argument' do
12
- expect { BooleanDomain.instance }.not_to raise_error
11
+ it 'is initialized without argument' do
12
+ expect { described_class.instance }.not_to raise_error
13
13
  end
14
14
  end # context
15
15
 
16
16
  context 'Provided services:' do
17
- it 'should know whether a value is in domain' do
18
- expect(subject.include?('invalid')).to be_falsey
19
- expect(subject.include?(true)).to be_truthy
20
- expect(subject.include?(false)).to be_truthy
17
+ it 'knows whether a value is in domain' do
18
+ expect(bool_dom).not_to include('invalid')
19
+ expect(bool_dom).to include(true)
20
+ expect(bool_dom).to include(false)
21
21
  end
22
22
 
23
- it 'should provide a factory method for boolean values' do
24
- expect(subject.build_value(true)).to be_kind_of(BooleanValue)
25
- expect(subject.build_value(false)).to be_kind_of(BooleanValue)
23
+ it 'provides a factory method for boolean values' do
24
+ expect(bool_dom.build_value(true)).to be_a(BooleanValue)
25
+ expect(bool_dom.build_value(false)).to be_a(BooleanValue)
26
26
  end
27
-
28
- it 'should return all valid values in domain when requested' do
29
- expect(subject.to_a).to eq([false, true])
30
- end
31
27
 
32
- it 'should complain when asked to build a non-boolean value' do
28
+ it 'returns all valid values in domain when requested' do
29
+ expect(bool_dom.to_a).to eq([false, true])
30
+ end
31
+
32
+ it 'complains when asked to build a non-boolean value' do
33
33
  err = StandardError
34
34
  err_msg = 'Expected a boolean instead of String.'
35
- expect { subject.build_value('?') }.to raise_error(err, err_msg)
35
+ expect { bool_dom.build_value('?') }.to raise_error(err, err_msg)
36
36
  end
37
37
  end # context
38
38
  end # describe
@@ -7,15 +7,16 @@ module Zenlish
7
7
  module Feature
8
8
  describe BooleanValue do
9
9
  let(:its_value) { false }
10
- subject { BooleanValue.new(its_value) }
10
+
11
+ subject(:boolean) { described_class.new(its_value) }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized with a value argument' do
14
- expect { BooleanValue.new(its_value) }.not_to raise_error
14
+ it 'is initialized with a value argument' do
15
+ expect { described_class.new(its_value) }.not_to raise_error
15
16
  end
16
-
17
- it 'should know its internal value' do
18
- expect(subject.val.class).to eq(FalseClass)
17
+
18
+ it 'knows its internal value' do
19
+ expect(boolean.val.class).to eq(FalseClass)
19
20
  end
20
21
  end # context
21
22
 
@@ -1,44 +1,44 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Load the class under test
4
- require_relative '../../../lib/zenlish/feature/enumeration_domain'
4
+ require_relative '../../../lib/zenlish/feature/enumeration_domain'
5
5
 
6
6
  module Zenlish
7
7
  module Feature
8
8
  describe EnumerationDomain do
9
- subject { EnumerationDomain.new(:singular, :plural) }
9
+ subject(:enumeration) { described_class.new(:singular, :plural) }
10
10
 
11
11
  context 'Initialization:' do
12
- it 'should be initialized with arguments' do
13
- expect { EnumerationDomain.new(:singular, :plural) }.not_to raise_error
12
+ it 'is initialized with arguments' do
13
+ expect { described_class.new(:singular, :plural) }.not_to raise_error
14
14
  end
15
-
16
- it 'should know the values of enumeration' do
17
- expect(subject.enum).to eq([:singular, :plural])
15
+
16
+ it 'knows the values of enumeration' do
17
+ expect(enumeration.enum).to eq(%i[singular plural])
18
18
  end
19
19
  end # context
20
20
 
21
21
  context 'Provided services:' do
22
- it 'should know whether a value is in domain' do
23
- expect(subject.include?(:dual)).to be_falsey
24
- expect(subject.include?(:singular)).to be_truthy
25
- expect(subject.include?(:plural)).to be_truthy
22
+ it 'knows whether a value is in domain' do
23
+ expect(enumeration).not_to include(:dual)
24
+ expect(enumeration).to include(:singular)
25
+ expect(enumeration).to include(:plural)
26
26
  end
27
-
28
- it 'should provide a factory method for enumerated value' do
29
- expect(subject.build_value(:plural)).to be_kind_of(SymbolValue)
30
- value = subject.build_value(:plural)
27
+
28
+ it 'provides a factory method for enumerated value' do
29
+ expect(enumeration.build_value(:plural)).to be_a(SymbolValue)
30
+ value = enumeration.build_value(:plural)
31
31
  expect(value.val).to eq(:plural)
32
32
  end
33
-
34
- it 'should return all valid values in domain when requested' do
35
- expect(subject.to_a).to eq([:singular, :plural])
36
- end
37
33
 
38
- it 'should complain when asked to build a non-member value' do
34
+ it 'returns all valid values in domain when requested' do
35
+ expect(enumeration.to_a).to eq(%i[singular plural])
36
+ end
37
+
38
+ it 'complains when asked to build a non-member value' do
39
39
  err = StandardError
40
40
  err_msg = "dual isn't part of enumeration [singular, plural]."
41
- expect { subject.build_value(:dual) }.to raise_error(err, err_msg)
41
+ expect { enumeration.build_value(:dual) }.to raise_error(err, err_msg)
42
42
  end
43
43
  end # context
44
44
  end # describe
@@ -9,36 +9,37 @@ module Zenlish
9
9
  describe FeatureDef do
10
10
  let(:a_name) { 'NUMBER' }
11
11
  let(:a_domain) { EnumerationDomain.new(:singular, :plural) }
12
- subject { FeatureDef.new(a_name, a_domain) }
12
+
13
+ subject(:ft_def) { described_class.new(a_name, a_domain) }
13
14
 
14
15
  context 'Initialization:' do
15
- it 'should be initialized with at least two arguments' do
16
- expect { FeatureDef.new(a_name, a_domain) }.not_to raise_error
16
+ it 'is initialized with at least two arguments' do
17
+ expect { described_class.new(a_name, a_domain) }.not_to raise_error
17
18
  end
18
19
 
19
- it 'could be initialized with a default value argument' do
20
+ it 'can be initialized with a default value argument' do
20
21
  deflt = double('dummy')
21
- expect { FeatureDef.new(a_name, a_domain, deflt) }.not_to raise_error
22
+ expect { described_class.new(a_name, a_domain, deflt) }.not_to raise_error
22
23
  end
23
24
 
24
- it 'should know its name' do
25
- expect(subject.name).to eq(a_name)
25
+ it 'knows its name' do
26
+ expect(ft_def.name).to eq(a_name)
26
27
  end
27
28
 
28
- it 'should know the domain of its values' do
29
- expect(subject.domain).to eq(a_domain)
29
+ it 'knows the domain of its values' do
30
+ expect(ft_def.domain).to eq(a_domain)
30
31
  end
31
32
 
32
- it 'should know the domain of its default value' do
33
- expect(subject.default).to be_nil
33
+ it 'knows the domain of its default value' do
34
+ expect(ft_def.default).to be_nil
34
35
  deflt = double('dummy')
35
- instance = FeatureDef.new(a_name, a_domain, deflt)
36
+ instance = described_class.new(a_name, a_domain, deflt)
36
37
  expect(instance.default).to eq(deflt)
37
38
  end
38
39
 
39
- it 'should guess its default if enumeration has a single member' do
40
+ it 'guesses its default if enumeration has a single member' do
40
41
  basic_domain = EnumerationDomain.new(:plural)
41
- instance = FeatureDef.new(a_name, basic_domain)
42
+ instance = described_class.new(a_name, basic_domain)
42
43
  expect(instance.default.val).to eq(:plural)
43
44
  end
44
45
  end # context
@@ -14,38 +14,38 @@ module Zenlish
14
14
  let(:feat_def) { FeatureDef.new(a_name, a_domain) }
15
15
  let(:plural_value) { a_domain.build_value(:plural) }
16
16
 
17
- subject { Feature.new(feat_def) }
17
+ subject(:a_feature) { described_class.new(feat_def) }
18
18
 
19
19
  context 'Initialization:' do
20
- it 'should be initialized with one definition argument' do
21
- expect { Feature.new(feat_def) }.not_to raise_error
20
+ it 'is initialized with one definition argument' do
21
+ expect { described_class.new(feat_def) }.not_to raise_error
22
22
  end
23
23
 
24
- it 'should know its definition' do
25
- expect(subject.definition).to eq(feat_def)
24
+ it 'knows its definition' do
25
+ expect(a_feature.definition).to eq(feat_def)
26
26
  end
27
27
 
28
- it "should'nt be bound yet to a value" do
29
- expect(subject.binding).to be_nil
30
- expect(subject).not_to be_bound
28
+ it "isn't bound yet to a value" do
29
+ expect(a_feature.binding).to be_nil
30
+ expect(a_feature).not_to be_bound
31
31
  end
32
32
  end # context
33
33
 
34
34
  context 'Provided services:' do
35
- it "should know the definition's name" do
36
- expect(subject.name).to eq(feat_def.name)
35
+ it "knows the definition's name" do
36
+ expect(a_feature.name).to eq(feat_def.name)
37
37
  end
38
38
 
39
- it "should know the domain of its values" do
40
- expect(subject.domain).to eq(a_domain)
39
+ it 'knows the domain of its values' do
40
+ expect(a_feature.domain).to eq(a_domain)
41
41
  end
42
42
 
43
- it 'should accept a value binding' do
44
- expect { subject.bind_to(plural_value) }.not_to raise_error
45
- expect(subject).to be_bound
46
- expect(subject.binding).to eq(plural_value)
43
+ it 'accepts a value binding' do
44
+ expect { a_feature.bind_to(plural_value) }.not_to raise_error
45
+ expect(a_feature).to be_bound
46
+ expect(a_feature.binding).to eq(plural_value)
47
47
  end
48
48
  end # context
49
49
  end # describe
50
50
  end # module
51
- end # module
51
+ end # module
@@ -7,6 +7,7 @@ module Zenlish
7
7
  module Feature
8
8
  describe FeatureStructDefBearer do
9
9
  # @nodoc Class created just for testing purposes.
10
+ # rubocop: disable Lint/ConstantDefinitionInBlock
10
11
  class Dummy
11
12
  include FeatureStructDefBearer
12
13
 
@@ -20,35 +21,36 @@ module Zenlish
20
21
  init_struct_def(aParent, feature_hash)
21
22
  end
22
23
  end # class
24
+ # rubocop: enable Lint/ConstantDefinitionInBlock
23
25
 
24
- subject { Dummy.new (nil) }
26
+ subject(:bearer) { Dummy.new(nil) }
25
27
 
26
28
  context 'Mix-in initialization' do
27
- it 'should have initialized properly the injected data' do
29
+ it 'has initialized properly the injected data' do
28
30
  expect { Dummy.new(nil) }.not_to raise_error
29
- expect(subject.struct).to be_kind_of(FeatureStructDef)
31
+ expect(bearer.struct).to be_a(FeatureStructDef)
30
32
  end
31
33
 
32
- it 'should have the feature definitions created' do
33
- expect(subject['NUMBER']).not_to be_nil
34
- expect(subject['NUMBER']).to be_kind_of(FeatureDef)
35
- ft = subject['NUMBER']
36
- expect(ft.domain.enum).to eq([:singular, :plural])
37
-
38
- expect(subject['COUNTABILITY']).to be_kind_of(FeatureDef)
39
- expect(subject['COUNTABILITY'].domain).to be_kind_of(BooleanDomain)
40
- expect(subject['PARADIGM']).to be_kind_of(FeatureDef)
41
- expect(subject['PARADIGM'].domain).to be_kind_of(IdentifierDomain)
42
- expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)
34
+ it 'has the feature definitions created' do
35
+ expect(bearer['NUMBER']).not_to be_nil
36
+ expect(bearer['NUMBER']).to be_a(FeatureDef)
37
+ ft = bearer['NUMBER']
38
+ expect(ft.domain.enum).to eq(%i[singular plural])
39
+
40
+ expect(bearer['COUNTABILITY']).to be_a(FeatureDef)
41
+ expect(bearer['COUNTABILITY'].domain).to be_a(BooleanDomain)
42
+ expect(bearer['PARADIGM']).to be_a(FeatureDef)
43
+ expect(bearer['PARADIGM'].domain).to be_a(IdentifierDomain)
44
+ expect(bearer['PARADIGM'].default).to be_a(IdentifierValue)
43
45
  end
44
-
45
- it 'should support the addition of feature def' do
46
- subject.feature_def_dsl { feature_def 'CASE' => boolean }
47
-
48
- expect(subject['CASE']).to be_kind_of(FeatureDef)
49
- expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)
46
+
47
+ it 'supports the addition of feature def' do
48
+ bearer.feature_def_dsl { feature_def 'CASE' => boolean }
49
+
50
+ expect(bearer['CASE']).to be_a(FeatureDef)
51
+ expect(bearer['CASE'].domain).to be_a(BooleanDomain)
50
52
  end
51
53
  end # context
52
54
  end # describe
53
55
  end # module
54
- end # module
56
+ end # module
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '../../../lib/zenlish/feature/boolean_domain'
3
4
  require_relative '../../../lib/zenlish/feature/enumeration_domain'
4
5
  require_relative '../../../lib/zenlish/feature/feature_def'
@@ -13,55 +14,55 @@ module Zenlish
13
14
  let(:ft_number) { FeatureDef.new('NUMBER', enum_number) }
14
15
  let(:countable_domain) { BooleanDomain.instance }
15
16
  let(:ft_countability) { FeatureDef.new('COUNTABILITY', countable_domain) }
16
- let(:sample_parent) { FeatureStructDef.new }
17
+ let(:sample_parent) { described_class.new }
17
18
  let(:case_domain) { EnumerationDomain.new(:common, :genitive) }
18
19
  let(:ft_case) { FeatureDef.new('CASE', case_domain) }
19
20
 
20
- subject { FeatureStructDef.new(sample_parent) }
21
+ subject(:struct_def) { described_class.new(sample_parent) }
21
22
 
22
23
  context 'Initialization:' do
23
- it 'could be initialized without argument' do
24
- expect { FeatureStructDef.new }.not_to raise_error
24
+ it 'can be initialized without argument' do
25
+ expect { described_class.new }.not_to raise_error
25
26
  end
26
27
 
27
- it 'could be initialized with a parent struct' do
28
- expect { FeatureStructDef.new(sample_parent) }.not_to raise_error
28
+ it 'can be initialized with a parent struct' do
29
+ expect { described_class.new(sample_parent) }.not_to raise_error
29
30
  end
30
31
 
31
- it 'should have an empty structure at initialization' do
32
- expect(subject.struct).to be_empty
32
+ it 'has an empty structure at initialization' do
33
+ expect(struct_def.struct).to be_empty
33
34
  end
34
35
 
35
- it 'should know its parent (if any)' do
36
- expect(subject.parent).to eq(sample_parent)
37
- instance = FeatureStructDef.new
36
+ it 'knows its parent (if any)' do
37
+ expect(struct_def.parent).to eq(sample_parent)
38
+ instance = described_class.new
38
39
  expect(instance.parent).to be_nil
39
40
  end
40
41
  end # context
41
42
 
42
43
  context 'Provided services:' do
43
- it 'should accept the addition of a feature definition' do
44
- expect { subject.add_feature_def(ft_number) }.not_to raise_error
45
- expect(subject.struct.size).to eq(1)
46
- expect(subject['NUMBER']).to eq(ft_number)
44
+ it 'accepts the addition of a feature definition' do
45
+ expect { struct_def.add_feature_def(ft_number) }.not_to raise_error
46
+ expect(struct_def.struct.size).to eq(1)
47
+ expect(struct_def['NUMBER']).to eq(ft_number)
47
48
 
48
- expect { subject.add_feature_def(ft_countability) }.not_to raise_error
49
- expect(subject.struct.size).to eq(2)
50
- expect(subject['COUNTABILITY']).to eq(ft_countability)
49
+ expect { struct_def.add_feature_def(ft_countability) }.not_to raise_error
50
+ expect(struct_def.struct.size).to eq(2)
51
+ expect(struct_def['COUNTABILITY']).to eq(ft_countability)
51
52
  end
52
53
 
53
- it 'should inherit the feature definition of its parent' do
54
+ it 'inherits the feature definition of its parent' do
54
55
  sample_parent.add_feature_def(ft_case)
55
- expect(subject['CASE']).to eq(ft_case)
56
+ expect(struct_def['CASE']).to eq(ft_case)
56
57
  end
57
-
58
- it "should be able to override parent's feature def" do
58
+
59
+ it "is able to override parent's feature def" do
59
60
  sample_parent.add_feature_def(ft_case)
60
-
61
+
61
62
  other_case_domain = BooleanDomain.instance
62
63
  other_ft_case = FeatureDef.new('CASE', other_case_domain)
63
- subject.add_feature_def(other_ft_case)
64
- expect(subject['CASE']).to eq(other_ft_case)
64
+ struct_def.add_feature_def(other_ft_case)
65
+ expect(struct_def['CASE']).to eq(other_ft_case)
65
66
  end
66
67
  end # context
67
68
  end # describe
@@ -5,32 +5,32 @@ require_relative '../../../lib/zenlish/feature/identifier_domain' # Load the cla
5
5
  module Zenlish
6
6
  module Feature
7
7
  describe IdentifierDomain do
8
- subject { IdentifierDomain.instance }
8
+ subject(:domain) { described_class.instance }
9
9
 
10
10
  context 'Initialization:' do
11
- it 'should be instantiated without argument' do
12
- expect { IdentifierDomain.instance }.not_to raise_error
11
+ it 'is instantiated without argument' do
12
+ expect { described_class.instance }.not_to raise_error
13
13
  end
14
14
  end # context
15
15
 
16
16
  context 'Provided services:' do
17
- it 'should know whether a value is in domain' do
18
- expect(subject.include?('CommonForm')).to be_truthy
19
- expect(subject.include?('Common Form')).to be_falsey
20
- expect(subject.include?('+123')).to be_falsey
21
- end
22
-
23
- it 'should provide a factory method for identifier values' do
24
- expect(subject.build_value('CommonForm')).to be_kind_of(IdentifierValue)
25
- expect(subject.build_value('Common_Form')).to be_kind_of(IdentifierValue)
17
+ it 'knows whether a value is in domain' do
18
+ expect(domain).to include('CommonForm')
19
+ expect(domain).not_to include('Common Form')
20
+ expect(domain).not_to include('+123')
26
21
  end
27
22
 
28
- it 'should complain when asked to build an invalid identifier' do
23
+ it 'provides a factory method for identifier values' do
24
+ expect(domain.build_value('CommonForm')).to be_a(IdentifierValue)
25
+ expect(domain.build_value('Common_Form')).to be_a(IdentifierValue)
26
+ end
27
+
28
+ it 'complains when asked to build an invalid identifier' do
29
29
  err = StandardError
30
30
  err_msg = "?1234 isn't a valid identifier."
31
- expect { subject.build_value('?1234') }.to raise_error(err, err_msg)
31
+ expect { domain.build_value('?1234') }.to raise_error(err, err_msg)
32
32
  end
33
33
  end # context
34
34
  end # describe
35
35
  end # module
36
- end # module
36
+ end # module
@@ -1,26 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Load the class under test
4
- require_relative '../../../lib/zenlish/feature/identifier_value'
4
+ require_relative '../../../lib/zenlish/feature/identifier_value'
5
5
 
6
6
  module Zenlish
7
7
  module Feature
8
8
  describe IdentifierValue do
9
9
  let(:its_value) { 'CommonForm' }
10
- subject { IdentifierValue.new(its_value) }
10
+
11
+ subject(:identifier) { described_class.new(its_value) }
11
12
 
12
13
  context 'Initialization:' do
13
- it 'should be initialized with a value argument' do
14
- expect { IdentifierValue.new(its_value) }.not_to raise_error
14
+ it 'is initialized with a value argument' do
15
+ expect { described_class.new(its_value) }.not_to raise_error
16
+ end
17
+
18
+ it 'knows its internal value' do
19
+ expect(identifier.val).to eq(its_value)
15
20
  end
16
-
17
- it 'should know its internal value' do
18
- expect(subject.val).to eq(its_value)
19
- end
20
21
  end # context
21
22
 
22
23
  context 'Provided services:' do
23
24
  end # context
24
25
  end # describe
25
26
  end # module
26
- end # module
27
+ end # module