panini 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f83357c2359128e9f1b7c518bcda0fae457738d5
4
+ data.tar.gz: 6ab6c47b29dadda0546a2ddff40ef761c4ca3136
5
+ SHA512:
6
+ metadata.gz: ea3a9a9c3c42d2da49788a1f5427f4bd63ef8c7b9f47be40678a657808e57463e0896503192e21da63a5bbe3a6c4ca13d88b61767a5b9810569b561ed9035094
7
+ data.tar.gz: 77a9efb70b646d2838ff8e5c53160972dcd04f1576c81b55ece0bdc4b1490485859a1bf403138d3db5d7a6e2beb764fb78e7a2b3036ca51f05c41fe628e06294
data/Gemfile CHANGED
@@ -1,8 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  group :development do
4
- gem "rspec", "~> 2.3.0"
4
+ gem "rspec"
5
5
  gem "bundler", "~> 1.0"
6
- gem "jeweler", "~> 1.6.0"
7
- gem "rcov", ">= 0"
6
+ gem "jeweler"
8
7
  end
@@ -1,28 +1,77 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.6.4)
7
- bundler (~> 1.0)
4
+ addressable (2.5.0)
5
+ public_suffix (~> 2.0, >= 2.0.2)
6
+ builder (3.2.3)
7
+ descendants_tracker (0.0.4)
8
+ thread_safe (~> 0.3, >= 0.3.1)
9
+ diff-lcs (1.3)
10
+ faraday (0.9.2)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.3.0)
13
+ github_api (0.11.3)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.1)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 1.2)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.0)
20
+ oauth2
21
+ hashie (3.5.5)
22
+ highline (1.7.8)
23
+ jeweler (2.3.3)
24
+ builder
25
+ bundler (>= 1.0)
8
26
  git (>= 1.2.5)
27
+ github_api (~> 0.11.0)
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
30
+ psych (~> 2.2)
9
31
  rake
10
- rake (0.9.2)
11
- rcov (0.9.10)
12
- rspec (2.3.0)
13
- rspec-core (~> 2.3.0)
14
- rspec-expectations (~> 2.3.0)
15
- rspec-mocks (~> 2.3.0)
16
- rspec-core (2.3.1)
17
- rspec-expectations (2.3.0)
18
- diff-lcs (~> 1.1.2)
19
- rspec-mocks (2.3.0)
32
+ rdoc
33
+ semver2
34
+ jwt (1.5.6)
35
+ mini_portile2 (2.1.0)
36
+ multi_json (1.12.1)
37
+ multi_xml (0.6.0)
38
+ multipart-post (2.0.0)
39
+ nokogiri (1.6.8.1)
40
+ mini_portile2 (~> 2.1.0)
41
+ oauth2 (1.3.1)
42
+ faraday (>= 0.8, < 0.12)
43
+ jwt (~> 1.0)
44
+ multi_json (~> 1.3)
45
+ multi_xml (~> 0.5)
46
+ rack (>= 1.2, < 3)
47
+ psych (2.2.4)
48
+ public_suffix (2.0.5)
49
+ rack (2.0.1)
50
+ rake (12.0.0)
51
+ rdoc (5.1.0)
52
+ rspec (3.5.0)
53
+ rspec-core (~> 3.5.0)
54
+ rspec-expectations (~> 3.5.0)
55
+ rspec-mocks (~> 3.5.0)
56
+ rspec-core (3.5.4)
57
+ rspec-support (~> 3.5.0)
58
+ rspec-expectations (3.5.0)
59
+ diff-lcs (>= 1.2.0, < 2.0)
60
+ rspec-support (~> 3.5.0)
61
+ rspec-mocks (3.5.0)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.5.0)
64
+ rspec-support (3.5.0)
65
+ semver2 (3.4.2)
66
+ thread_safe (0.3.6)
20
67
 
21
68
  PLATFORMS
22
69
  ruby
23
70
 
24
71
  DEPENDENCIES
25
72
  bundler (~> 1.0)
26
- jeweler (~> 1.6.0)
27
- rcov
28
- rspec (~> 2.3.0)
73
+ jeweler
74
+ rspec
75
+
76
+ BUNDLED WITH
77
+ 1.14.5
data/Rakefile CHANGED
@@ -13,13 +13,13 @@ require 'rake'
13
13
 
14
14
  require 'jeweler'
15
15
  Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
17
  gem.name = "panini"
18
18
  gem.homepage = "http://github.com/mjbellantoni/panini"
19
19
  gem.license = "MIT"
20
20
  gem.summary = %Q{Create sentences from a context-free grammar (CFG)}
21
21
  gem.description = %Q{Panini allows you to generate sentences from a context-free grammar, also known as a CFG.}
22
- gem.email = "mjbellantoni@yahoo.com"
22
+ gem.email = "mjbellantoni@gmail.com"
23
23
  gem.authors = ["mjbellantoni"]
24
24
  # dependencies defined in Gemfile
25
25
  end
@@ -31,14 +31,15 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
31
31
  spec.pattern = FileList['spec/**/*_spec.rb']
32
32
  end
33
33
 
34
- RSpec::Core::RakeTask.new(:rcov) do |spec|
35
- spec.pattern = 'spec/**/*_spec.rb'
36
- spec.rcov = true
34
+ desc "Code coverage detail"
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = "true"
37
+ Rake::Task['test'].execute
37
38
  end
38
39
 
39
40
  task :default => :spec
40
41
 
41
- require 'rake/rdoctask'
42
+ require 'rdoc/task'
42
43
  Rake::RDocTask.new do |rdoc|
43
44
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
45
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.0
1
+ 1.3.0
@@ -13,7 +13,7 @@ module Panini
13
13
  end
14
14
  end
15
15
 
16
- def initialize_copy(source)
16
+ def initialize_copy(source)
17
17
  super
18
18
  @production_counts = @production_counts.map do |production_count|
19
19
  production_count
@@ -82,7 +82,7 @@ module Panini
82
82
  end
83
83
  private :build_production_proxies
84
84
 
85
- # Generates a sentence.
85
+ # Generates a sentence.
86
86
  def sentence
87
87
  substitute_nonterminal(@grammar.start, @production_proxies, 0)
88
88
  end
@@ -93,11 +93,11 @@ module Panini
93
93
  # production_proxies_copy = production_proxies.each do |key, value|
94
94
  # production_proxies_copy[key] = value.dup
95
95
  # end
96
- #
97
- production_proxies_copy = production_proxies.map do |value|
96
+ #
97
+ production_proxies_copy = production_proxies.update_values do |value|
98
98
  value.dup
99
99
  end
100
-
100
+
101
101
  production_proxies_copy[nonterminal].production.flat_map do |term|
102
102
  if (term.class == Nonterminal)
103
103
  substitute_nonterminal(term, production_proxies_copy, depth + 1)
@@ -1,6 +1,6 @@
1
1
  class Hash
2
2
 
3
- def map(&block)
3
+ def update_values(&block)
4
4
  mapped_hash = {}
5
5
  self.each do |key, value|
6
6
  mapped_hash[key] = yield value
@@ -2,16 +2,18 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: panini 1.3.0 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
- s.name = "panini"
8
- s.version = "1.2.0"
8
+ s.name = "panini".freeze
9
+ s.version = "1.3.0"
9
10
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["mjbellantoni"]
12
- s.date = "2011-09-16"
13
- s.description = "Panini allows you to generate sentences from a context-free grammar, also known as a CFG."
14
- s.email = "mjbellantoni@yahoo.com"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["mjbellantoni".freeze]
14
+ s.date = "2017-03-26"
15
+ s.description = "Panini allows you to generate sentences from a context-free grammar, also known as a CFG.".freeze
16
+ s.email = "mjbellantoni@gmail.com".freeze
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE.txt",
17
19
  "README.rdoc"
@@ -44,31 +46,27 @@ Gem::Specification.new do |s|
44
46
  "spec/spec_helper.rb",
45
47
  "spec/support/basic_derivation_strategy_shared_example.rb"
46
48
  ]
47
- s.homepage = "http://github.com/mjbellantoni/panini"
48
- s.licenses = ["MIT"]
49
- s.require_paths = ["lib"]
50
- s.rubygems_version = "1.8.10"
51
- s.summary = "Create sentences from a context-free grammar (CFG)"
49
+ s.homepage = "http://github.com/mjbellantoni/panini".freeze
50
+ s.licenses = ["MIT".freeze]
51
+ s.rubygems_version = "2.6.10".freeze
52
+ s.summary = "Create sentences from a context-free grammar (CFG)".freeze
52
53
 
53
54
  if s.respond_to? :specification_version then
54
- s.specification_version = 3
55
+ s.specification_version = 4
55
56
 
56
57
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
58
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
59
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.0"])
60
- s.add_development_dependency(%q<rcov>, [">= 0"])
58
+ s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
59
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
60
+ s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
61
61
  else
62
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
63
- s.add_dependency(%q<bundler>, ["~> 1.0"])
64
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
65
- s.add_dependency(%q<rcov>, [">= 0"])
62
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
63
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
64
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
66
65
  end
67
66
  else
68
- s.add_dependency(%q<rspec>, ["~> 2.3.0"])
69
- s.add_dependency(%q<bundler>, ["~> 1.0"])
70
- s.add_dependency(%q<jeweler>, ["~> 1.6.0"])
71
- s.add_dependency(%q<rcov>, [">= 0"])
67
+ s.add_dependency(%q<rspec>.freeze, [">= 0"])
68
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
69
+ s.add_dependency(%q<jeweler>.freeze, [">= 0"])
72
70
  end
73
71
  end
74
72
 
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
  describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy do
5
5
 
6
6
  it "responds to #production" do
7
- described_class.new(Panini::Nonterminal.new).should respond_to(:production)
7
+ expect(described_class.new(Panini::Nonterminal.new)).to respond_to(:production)
8
8
  end
9
9
 
10
10
  end
@@ -24,22 +24,22 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
24
24
  n = Panini::Nonterminal.new
25
25
  n.add_production(['a'])
26
26
  @proxy = described_class.new(n, @damping)
27
- Kernel::stub(:rand).and_return(0.25)
27
+ allow(Kernel).to receive(:rand).and_return(0.25)
28
28
  end
29
29
 
30
30
  it "returns ['a'] after one call" do
31
- @proxy.production.should == ['a']
31
+ expect(@proxy.production).to eq(['a'])
32
32
  end
33
33
 
34
34
  it "returns ['a'] after two calls" do
35
35
  @proxy.production
36
- @proxy.production.should == ['a']
36
+ expect(@proxy.production).to eq(['a'])
37
37
  end
38
38
 
39
39
  it "returns ['a'] after three calls" do
40
40
  @proxy.production
41
41
  @proxy.production
42
- @proxy.production.should == ['a']
42
+ expect(@proxy.production).to eq(['a'])
43
43
  end
44
44
 
45
45
  end
@@ -51,22 +51,22 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
51
51
  n.add_production(['a'])
52
52
  n.add_production(['b'])
53
53
  @proxy = described_class.new(n, @damping)
54
- Kernel::stub(:rand).and_return(0.25)
54
+ allow(Kernel).to receive(:rand).and_return(0.25)
55
55
  end
56
56
 
57
57
  it "returns ['a'] after one call" do
58
- @proxy.production.should == ['a']
58
+ expect(@proxy.production).to eq(['a'])
59
59
  end
60
60
 
61
61
  it "returns ['a'] after two calls" do
62
62
  @proxy.production
63
- @proxy.production.should == ['a']
63
+ expect(@proxy.production).to eq(['a'])
64
64
  end
65
65
 
66
66
  it "returns ['b'] after three calls" do
67
67
  @proxy.production
68
68
  @proxy.production
69
- @proxy.production.should == ['b']
69
+ expect(@proxy.production).to eq(['b'])
70
70
  end
71
71
 
72
72
  end
@@ -79,29 +79,29 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
79
79
  n.add_production(['b'])
80
80
  n.add_production(['c'])
81
81
  @proxy = described_class.new(n, @damping)
82
- Kernel::stub(:rand).and_return(0.3)
82
+ allow(Kernel).to receive(:rand).and_return(0.3)
83
83
  end
84
84
 
85
85
  it "returns ['a'] after one call" do
86
- @proxy.production.should == ['a']
86
+ expect(@proxy.production).to eq(['a'])
87
87
  end
88
88
 
89
89
  it "returns ['b'] after two calls" do
90
90
  @proxy.production
91
- @proxy.production.should == ['b']
91
+ expect(@proxy.production).to eq(['b'])
92
92
  end
93
93
 
94
94
  it "returns ['b'] after three calls" do
95
95
  @proxy.production
96
96
  @proxy.production
97
- @proxy.production.should == ['b']
97
+ expect(@proxy.production).to eq(['b'])
98
98
  end
99
99
 
100
100
  it "returns ['b'] after four calls" do
101
101
  @proxy.production
102
102
  @proxy.production
103
103
  @proxy.production
104
- @proxy.production.should == ['b']
104
+ expect(@proxy.production).to eq(['b'])
105
105
  end
106
106
 
107
107
  it "returns ['a'] after five calls" do
@@ -109,7 +109,7 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
109
109
  @proxy.production
110
110
  @proxy.production
111
111
  @proxy.production
112
- @proxy.production.should == ['a']
112
+ expect(@proxy.production).to eq(['a'])
113
113
  end
114
114
 
115
115
  it "returns ['c'] after six calls" do
@@ -118,7 +118,7 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
118
118
  @proxy.production
119
119
  @proxy.production
120
120
  @proxy.production
121
- @proxy.production.should == ['c']
121
+ expect(@proxy.production).to eq(['c'])
122
122
  end
123
123
 
124
124
  end
@@ -139,50 +139,50 @@ describe Panini::DerivationStrategy::DampenedProbabilityProductionChoiceProxy, "
139
139
  n.add_production(['b'])
140
140
  n.add_production(['c'])
141
141
  @proxy = described_class.new(n, 0.50)
142
- Kernel::stub(:rand).and_return(0.3)
142
+ allow(Kernel).to receive(:rand).and_return(0.3)
143
143
  end
144
144
 
145
145
  context "and a clone" do
146
146
 
147
147
  before(:each) do
148
- @clone_proxy = @proxy.clone
149
- @clone_proxy.stub(:rand).and_return(0.3)
148
+ @clone_proxy = @proxy.clone
149
+ allow(@clone_proxy).to receive(:rand).and_return(0.3)
150
150
  end
151
151
 
152
152
  context "the original" do
153
-
153
+
154
154
  it "returns ['a'] after one call" do
155
- @proxy.production.should == ['a']
155
+ expect(@proxy.production).to eq(['a'])
156
156
  end
157
157
 
158
158
  it "returns ['b'] after two calls" do
159
159
  @proxy.production
160
- @proxy.production.should == ['b']
160
+ expect(@proxy.production).to eq(['b'])
161
161
  end
162
162
 
163
163
  it "returns ['b'] after three calls" do
164
164
  @proxy.production
165
165
  @proxy.production
166
- @proxy.production.should == ['b']
166
+ expect(@proxy.production).to eq(['b'])
167
167
  end
168
168
 
169
169
  end
170
170
 
171
171
  context "the clone" do
172
-
172
+
173
173
  it "returns ['a'] after one call" do
174
- @clone_proxy.production.should == ['a']
174
+ expect(@clone_proxy.production).to eq(['a'])
175
175
  end
176
176
 
177
177
  it "returns ['b'] after two calls" do
178
178
  @clone_proxy.production
179
- @clone_proxy.production.should == ['b']
179
+ expect(@clone_proxy.production).to eq(['b'])
180
180
  end
181
181
 
182
182
  it "returns ['b'] after three calls" do
183
183
  @clone_proxy.production
184
184
  @clone_proxy.production
185
- @clone_proxy.production.should == ['b']
185
+ expect(@clone_proxy.production).to eq(['b'])
186
186
  end
187
187
 
188
188
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
 
4
4
  describe Panini::DerivationStrategy::Exhaustive do
5
- it_behaves_like "basic derivation strategy"
5
+ it_behaves_like "basic derivation strategy"
6
6
  end
7
7
 
8
8
 
@@ -21,39 +21,39 @@ describe "Grammar with the production S -> AAB, A -> 'a' | 'x', B -> 'b'" do
21
21
  @n_b.add_production(['b'])
22
22
  end
23
23
 
24
- it "generates the sentence ['a', 'a', 'b'] first" do
24
+ it "generates the sentence ['a', 'a', 'b'] first" do
25
25
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
26
- d.sentence.should == ['a', 'a', 'b']
26
+ expect(d.sentence).to eq(['a', 'a', 'b'])
27
27
  end
28
28
 
29
- it "generates the sentence ['a', 'x', 'b'] next" do
29
+ it "generates the sentence ['a', 'x', 'b'] next" do
30
30
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
31
31
  d.sentence
32
- d.sentence.should == ['a', 'x', 'b']
32
+ expect(d.sentence).to eq(['a', 'x', 'b'])
33
33
  end
34
34
 
35
- it "generates the sentence ['x', 'a', 'b'] next" do
35
+ it "generates the sentence ['x', 'a', 'b'] next" do
36
36
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
37
37
  d.sentence
38
38
  d.sentence
39
- d.sentence.should == ['x', 'a', 'b']
39
+ expect(d.sentence).to eq(['x', 'a', 'b'])
40
40
  end
41
41
 
42
- it "generates the sentence ['x', 'x', 'b'] next" do
42
+ it "generates the sentence ['x', 'x', 'b'] next" do
43
43
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
44
44
  d.sentence
45
45
  d.sentence
46
46
  d.sentence
47
- d.sentence.should == ['x', 'x', 'b']
47
+ expect(d.sentence).to eq(['x', 'x', 'b'])
48
48
  end
49
49
 
50
- it "generates nil next" do
50
+ it "generates nil next" do
51
51
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
52
52
  d.sentence
53
53
  d.sentence
54
54
  d.sentence
55
55
  d.sentence
56
- d.sentence.should be_nil
56
+ expect(d.sentence).to be_nil
57
57
  end
58
58
 
59
59
  end
@@ -68,15 +68,15 @@ describe "Grammar with the production S -> 'a' | 'b'" do
68
68
  @n.add_production(['b'])
69
69
  end
70
70
 
71
- it "generates the sentence ['a']" do
71
+ it "generates the sentence ['a']" do
72
72
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
73
- d.sentence.should == ['a']
73
+ expect(d.sentence).to eq(['a'])
74
74
  end
75
75
 
76
- it "generates the sentence ['b']" do
76
+ it "generates the sentence ['b']" do
77
77
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
78
78
  d.sentence
79
- d.sentence.should == ['b']
79
+ expect(d.sentence).to eq(['b'])
80
80
  end
81
81
 
82
82
  end
@@ -98,22 +98,22 @@ describe "Grammar with the production S -> xAyBz, A -> 'a' | 'aa', B -> 'b' | 'b
98
98
  @n_b.add_production(['bb'])
99
99
  end
100
100
 
101
- it "generates the sentence ['x', 'a', 'y', 'b', 'z'] first" do
101
+ it "generates the sentence ['x', 'a', 'y', 'b', 'z'] first" do
102
102
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
103
- d.sentence.should == ['x', 'a', 'y', 'b', 'z']
103
+ expect(d.sentence).to eq(['x', 'a', 'y', 'b', 'z'])
104
104
  end
105
105
 
106
- it "generates the sentence ['x', 'a', 'y', 'bb', 'z'] next" do
106
+ it "generates the sentence ['x', 'a', 'y', 'bb', 'z'] next" do
107
107
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
108
- d.sentence.should
109
- d.sentence.should == ['x', 'a', 'y', 'bb', 'z']
108
+ d.sentence
109
+ expect(d.sentence).to eq(['x', 'a', 'y', 'bb', 'z'])
110
110
  end
111
111
 
112
- it "generates the sentence ['x', 'aa', 'y', 'b', 'z'] next" do
112
+ it "generates the sentence ['x', 'aa', 'y', 'b', 'z'] next" do
113
113
  d = Panini::DerivationStrategy::Exhaustive.new(@g)
114
- d.sentence.should
115
- d.sentence.should
116
- d.sentence.should == ['x', 'aa', 'y', 'b', 'z']
114
+ d.sentence
115
+ d.sentence
116
+ expect(d.sentence).to eq(['x', 'aa', 'y', 'b', 'z'])
117
117
  end
118
118
 
119
119
  end
@@ -135,22 +135,22 @@ describe "Grammar with the production S -> xAyBz, A -> eps | 'a', B -> eps | 'b'
135
135
  @n_b.add_production(['b'])
136
136
  end
137
137
 
138
- it "generates the sentence ['x', 'y', 'z'] first" do
138
+ it "generates the sentence ['x', 'y', 'z'] first" do
139
139
  d = Panini::DerivationStrategy::Exhaustive.new(@g, 4)
140
- d.sentence.should == ['x', 'y', 'z']
140
+ expect(d.sentence).to eq(['x', 'y', 'z'])
141
141
  end
142
142
 
143
- it "generates the sentence ['x', 'y', 'b', 'z'] next" do
143
+ it "generates the sentence ['x', 'y', 'b', 'z'] next" do
144
144
  d = Panini::DerivationStrategy::Exhaustive.new(@g, 4)
145
- d.sentence.should
146
- d.sentence.should == ['x', 'y', 'b', 'z']
145
+ d.sentence
146
+ expect(d.sentence).to eq(['x', 'y', 'b', 'z'])
147
147
  end
148
148
 
149
- it "generates the sentence ['x', 'a', 'y', 'z'] next" do
149
+ it "generates the sentence ['x', 'a', 'y', 'z'] next" do
150
150
  d = Panini::DerivationStrategy::Exhaustive.new(@g, 4)
151
- d.sentence.should
152
- d.sentence.should
153
- d.sentence.should == ['x', 'a', 'y', 'z']
151
+ d.sentence
152
+ d.sentence
153
+ expect(d.sentence).to eq(['x', 'a', 'y', 'z'])
154
154
  end
155
155
 
156
156
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
 
4
4
  describe Panini::DerivationStrategy::Leftmost do
5
- it_behaves_like "basic derivation strategy"
5
+ it_behaves_like "basic derivation strategy"
6
6
  end
7
7
 
8
8
 
@@ -22,9 +22,9 @@ describe "Grammar with the production S -> AAB, A -> 'a' | 'x', B -> 'b'" do
22
22
  @n_b.add_production(['b'])
23
23
  end
24
24
 
25
- it "generates the sentence ['a', 'x', 'b']" do
25
+ it "generates the sentence ['a', 'x', 'b']" do
26
26
  d = Panini::DerivationStrategy::Leftmost.new(@g)
27
- d.sentence.should == ['a', 'x', 'b']
27
+ expect(d.sentence).to eq(['a', 'x', 'b'])
28
28
  end
29
29
 
30
30
  end
@@ -40,9 +40,9 @@ describe "Grammar with the production S -> 'a' | 'b'" do
40
40
  @n.add_production(['b'])
41
41
  end
42
42
 
43
- it "generates the sentence ['a']" do
43
+ it "generates the sentence ['a']" do
44
44
  d = Panini::DerivationStrategy::Leftmost.new(@g)
45
- d.sentence.should == ['a']
45
+ expect(d.sentence).to eq(['a'])
46
46
  end
47
47
 
48
48
  end
@@ -61,13 +61,13 @@ describe "Grammar with the production S -> S | 'a' | 'b'" do
61
61
  @deriver = Panini::DerivationStrategy::Leftmost.new(@g)
62
62
  end
63
63
 
64
- it "generates the sentence ['a'] first" do
65
- @deriver.sentence.should == ['a']
64
+ it "generates the sentence ['a'] first" do
65
+ expect(@deriver.sentence).to eq(['a'])
66
66
  end
67
67
 
68
- it "generates the sentence ['b'] second" do
69
- @deriver.sentence.should
70
- @deriver.sentence.should == ['b']
68
+ it "generates the sentence ['b'] second" do
69
+ @deriver.sentence
70
+ expect(@deriver.sentence).to eq(['b'])
71
71
  end
72
72
 
73
73
  end
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
 
4
4
  describe Panini::DerivationStrategy::RandomDampened do
5
- it_behaves_like "basic derivation strategy"
5
+ it_behaves_like "basic derivation strategy"
6
6
  end
7
7
 
8
8
 
@@ -15,11 +15,15 @@ describe Panini::DerivationStrategy::RandomDampened do
15
15
  end
16
16
 
17
17
  it "raises an exception if the damping factor is too small" do
18
- lambda { described_class.new(@g, 1.0) }.should raise_error(ArgumentError, "The damping factor must be greater than 0.0 and less than 1.0.")
18
+ expect do
19
+ described_class.new(@g, 1.0)
20
+ end.to raise_error(ArgumentError, "The damping factor must be greater than 0.0 and less than 1.0.")
19
21
  end
20
22
 
21
23
  it "raises an exception if the damping factor is too large" do
22
- lambda { described_class.new(@g, 0.0) }.should raise_error(ArgumentError, "The damping factor must be greater than 0.0 and less than 1.0.")
24
+ expect do
25
+ described_class.new(@g, 0.0)
26
+ end.to raise_error(ArgumentError, "The damping factor must be greater than 0.0 and less than 1.0.")
23
27
  end
24
28
 
25
29
  end
@@ -59,32 +63,33 @@ describe Panini::DerivationStrategy::RandomDampened, "sentence with an arethmeti
59
63
  number.add_production([n])
60
64
  end
61
65
 
62
- Kernel::stub(:rand).and_return(0.3)
66
+ allow(Kernel).to receive(:rand).and_return(0.3)
63
67
  end
64
68
 
65
69
  context "with very little damping" do
66
70
 
67
71
  before(:each) do
68
- @deriver = described_class.new(@grammar, 0.999999999999)
72
+ @deriver = described_class.new(@grammar, 0.999999999999)
69
73
  end
70
74
 
71
75
  it "encounters a stack error" do
72
- lambda { @deriver.sentence }.should raise_error(SystemStackError)
76
+ expect do
77
+ @deriver.sentence
78
+ end.to raise_error(SystemStackError)
73
79
  end
74
-
80
+
75
81
  end
76
82
 
77
83
  context "with damping" do
78
84
 
79
85
  before(:each) do
80
- @deriver = described_class.new(@grammar)
86
+ @deriver = described_class.new(@grammar)
81
87
  end
82
88
 
83
89
  it "returns an expected sentence" do
84
- @deriver.sentence.should == ["h", "*", "h", "/", "h", "/", "h", "+", "h", "*", "h", "/", "h", "/", "h"]
90
+ expect(@deriver.sentence).to eq(["h", "*", "h", "/", "h", "/", "h", "+", "h", "*", "h", "/", "h", "/", "h"])
85
91
  end
86
92
 
87
93
  end
88
94
 
89
-
90
95
  end
@@ -8,15 +8,15 @@ describe "Grammar" do
8
8
  end
9
9
 
10
10
  it "responds to #add_nonterminal" do
11
- @g.should respond_to(:add_nonterminal)
11
+ expect(@g).to respond_to(:add_nonterminal)
12
12
  end
13
13
 
14
14
  it "responds to #nonterminals" do
15
- @g.should respond_to(:nonterminals)
15
+ expect(@g).to respond_to(:nonterminals)
16
16
  end
17
17
 
18
18
  it "responds to #start" do
19
- @g.should respond_to(:start)
19
+ expect(@g).to respond_to(:start)
20
20
  end
21
21
 
22
22
  end
@@ -31,12 +31,12 @@ describe "Grammar#add_nonterminal" do
31
31
  end
32
32
 
33
33
  it "returns a new Panini::Nonterminal" do
34
- @n.should be_an_instance_of(Panini::Nonterminal)
34
+ expect(@n).to be_an_instance_of(Panini::Nonterminal)
35
35
  end
36
36
 
37
37
  it "stores the new Panini::Nonterminal" do
38
- @g.nonterminals.should have(1).item
39
- @g.nonterminals[0].should == @n
38
+ expect(@g.nonterminals.count).to eq(1)
39
+ expect(@g.nonterminals[0]).to eq(@n)
40
40
  end
41
41
 
42
42
  end
@@ -54,8 +54,8 @@ describe "Grammar#start" do
54
54
 
55
55
  context "when a start symbol is not specified" do
56
56
  it "returns the first nonterminal" do
57
- @g.start.should == @nonterminals[0]
58
- end
57
+ expect(@g.start).to eq(@nonterminals[0])
58
+ end
59
59
  end
60
60
 
61
61
  context "when a start symbol is specified" do
@@ -63,8 +63,8 @@ describe "Grammar#start" do
63
63
  @g.start = @nonterminals[1]
64
64
  end
65
65
  it "returns that nonterminal" do
66
- @g.start.should == @nonterminals[1]
67
- end
66
+ expect(@g.start).to eq(@nonterminals[1])
67
+ end
68
68
  end
69
69
 
70
70
  end
@@ -8,11 +8,11 @@ describe "Nonterminal" do
8
8
  end
9
9
 
10
10
  it "responds to #add_production" do
11
- @n.should respond_to(:add_production)
11
+ expect(@n).to respond_to(:add_production)
12
12
  end
13
13
 
14
14
  it "responds to #productions" do
15
- @n.should respond_to(:productions)
15
+ expect(@n).to respond_to(:productions)
16
16
  end
17
17
 
18
18
  end
@@ -25,7 +25,9 @@ describe "Nonterminal#add_production with a non-Array arument" do
25
25
  end
26
26
 
27
27
  it "throws an error" do
28
- lambda { @n.add_production('a') }.should raise_error(ArgumentError, "The production must be an Array.")
28
+ expect do
29
+ @n.add_production('a')
30
+ end.to raise_error(ArgumentError, "The production must be an Array.")
29
31
  end
30
32
 
31
33
  end
@@ -39,12 +41,12 @@ describe "Nonterminal#add_production with a single production" do
39
41
  end
40
42
 
41
43
  it "returns nil" do
42
- @p.should be_nil
44
+ expect(@p).to be_nil
43
45
  end
44
46
 
45
47
  it "stores the production" do
46
- @n.productions.should have(1).item
47
- @n.productions[0].should == ['a', 'b', 'c']
48
+ expect(@n.productions.count).to eq(1)
49
+ expect(@n.productions[0]).to eq(['a', 'b', 'c'])
48
50
  end
49
51
 
50
52
  end
@@ -60,20 +62,20 @@ describe "Nonterminal#add_production with two productions" do
60
62
  end
61
63
 
62
64
  it "returns nil" do
63
- @p1.should be_nil
64
- @p2.should be_nil
65
+ expect(@p1).to be_nil
66
+ expect(@p2).to be_nil
65
67
  end
66
68
 
67
69
  it "stores the productions" do
68
- @n.productions.should have(2).items
70
+ expect(@n.productions.count).to eq(2)
69
71
  end
70
72
 
71
73
  it "stores the first one added first" do
72
- @n.productions[0].should == ['a', 'b', 'c']
74
+ expect(@n.productions[0]).to eq(['a', 'b', 'c'])
73
75
  end
74
76
 
75
77
  it "stores the second one added last" do
76
- @n.productions[1].should == ['x', 'y', 'z']
78
+ expect(@n.productions[1]).to eq(['x', 'y', 'z'])
77
79
  end
78
80
 
79
81
  end
@@ -14,9 +14,9 @@ shared_examples_for "basic derivation strategy" do
14
14
  @n.add_production([])
15
15
  end
16
16
 
17
- it "generates an empty sentence" do
17
+ it "generates an empty sentence" do
18
18
  d = described_class.new(@g)
19
- d.sentence.should be_empty
19
+ expect(d.sentence).to be_empty
20
20
  end
21
21
 
22
22
  end
@@ -30,9 +30,9 @@ shared_examples_for "basic derivation strategy" do
30
30
  @n.add_production(['a'])
31
31
  end
32
32
 
33
- it "generates the sentence ['a']" do
33
+ it "generates the sentence ['a']" do
34
34
  d = described_class.new(@g)
35
- d.sentence.should == ['a']
35
+ expect(d.sentence).to eq(['a'])
36
36
  end
37
37
 
38
38
  end
@@ -51,9 +51,9 @@ shared_examples_for "basic derivation strategy" do
51
51
  @n_a.add_production(['a'])
52
52
  end
53
53
 
54
- it "generates the sentence ['a']" do
54
+ it "generates the sentence ['a']" do
55
55
  d = described_class.new(@g)
56
- d.sentence.should == ['a']
56
+ expect(d.sentence).to eq(['a'])
57
57
  end
58
58
 
59
59
  end
@@ -74,9 +74,9 @@ shared_examples_for "basic derivation strategy" do
74
74
  @n_b.add_production(['b'])
75
75
  end
76
76
 
77
- it "generates the sentence ['a', 'b']" do
77
+ it "generates the sentence ['a', 'b']" do
78
78
  d = described_class.new(@g)
79
- d.sentence.should == ['a', 'b']
79
+ expect(d.sentence).to eq(['a', 'b'])
80
80
  end
81
81
 
82
82
  end
metadata CHANGED
@@ -1,73 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: panini
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - mjbellantoni
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-09-16 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
11
+ date: 2017-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
16
14
  name: rspec
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ~>
21
- - !ruby/object:Gem::Version
22
- version: 2.3.0
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
23
20
  type: :development
24
21
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
27
28
  name: bundler
28
- requirement: &id002 !ruby/object:Gem::Requirement
29
- none: false
30
- requirements:
31
- - - ~>
32
- - !ruby/object:Gem::Version
33
- version: "1.0"
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
38
42
  name: jeweler
39
- requirement: &id003 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ~>
43
- - !ruby/object:Gem::Version
44
- version: 1.6.0
45
- type: :development
46
- prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: rcov
50
- requirement: &id004 !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
53
45
  - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
56
48
  type: :development
57
49
  prerelease: false
58
- version_requirements: *id004
59
- description: Panini allows you to generate sentences from a context-free grammar, also known as a CFG.
60
- email: mjbellantoni@yahoo.com
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Panini allows you to generate sentences from a context-free grammar,
56
+ also known as a CFG.
57
+ email: mjbellantoni@gmail.com
61
58
  executables: []
62
-
63
59
  extensions: []
64
-
65
- extra_rdoc_files:
60
+ extra_rdoc_files:
66
61
  - LICENSE.txt
67
62
  - README.rdoc
68
- files:
69
- - .document
70
- - .rspec
63
+ files:
64
+ - ".document"
65
+ - ".rspec"
71
66
  - Gemfile
72
67
  - Gemfile.lock
73
68
  - LICENSE.txt
@@ -93,34 +88,27 @@ files:
93
88
  - spec/spec_helper.rb
94
89
  - spec/support/basic_derivation_strategy_shared_example.rb
95
90
  homepage: http://github.com/mjbellantoni/panini
96
- licenses:
91
+ licenses:
97
92
  - MIT
93
+ metadata: {}
98
94
  post_install_message:
99
95
  rdoc_options: []
100
-
101
- require_paths:
96
+ require_paths:
102
97
  - lib
103
- required_ruby_version: !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
106
100
  - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: -174120655585110477
109
- segments:
110
- - 0
111
- version: "0"
112
- required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
115
105
  - - ">="
116
- - !ruby/object:Gem::Version
117
- version: "0"
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
118
108
  requirements: []
119
-
120
109
  rubyforge_project:
121
- rubygems_version: 1.8.10
110
+ rubygems_version: 2.6.10
122
111
  signing_key:
123
- specification_version: 3
112
+ specification_version: 4
124
113
  summary: Create sentences from a context-free grammar (CFG)
125
114
  test_files: []
126
-