parslet-export 1.0.0 → 2.0.0
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 +4 -4
- data/lib/hash.rb +4 -4
- data/lib/parslet-export.rb +2 -3
- data/lib/{parslet → parslet-export}/atoms.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/entity.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/named.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/re.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/repetition.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/sequence.rb +0 -0
- data/lib/{parslet → parslet-export}/atoms/str.rb +0 -0
- data/lib/{parslet → parslet-export}/parser.rb +3 -0
- data/lib/parslet-export/version.rb +3 -0
- data/spec/lib/parslet-export/atoms/entity_spec.rb +19 -0
- data/spec/lib/parslet-export/atoms/named_spec.rb +15 -0
- data/spec/lib/parslet-export/atoms/re_spec.rb +12 -0
- data/spec/lib/parslet-export/atoms/repetition_spec.rb +19 -0
- data/spec/lib/parslet-export/atoms/sequence_spec.rb +13 -0
- data/spec/lib/parslet-export/atoms/str_spec.rb +11 -0
- data/spec/lib/{parslet → parslet-export}/parser_spec.rb +0 -0
- data/spec/lib/parslet-export/version_spec.rb +7 -0
- metadata +27 -32
- data/lib/parslet/export.rb +0 -7
- data/lib/parslet/export/version.rb +0 -5
- data/spec/lib/parslet/atoms/entity_spec.rb +0 -24
- data/spec/lib/parslet/atoms/named_spec.rb +0 -20
- data/spec/lib/parslet/atoms/re_spec.rb +0 -14
- data/spec/lib/parslet/atoms/repetition_spec.rb +0 -24
- data/spec/lib/parslet/atoms/sequence_spec.rb +0 -18
- data/spec/lib/parslet/atoms/str_spec.rb +0 -10
- data/spec/lib/parslet/atoms_spec.rb +0 -5
- data/spec/lib/parslet/export/version_spec.rb +0 -7
- data/spec/lib/parslet/export_spec.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0a65d3d5ae292c22a40545df2ce9ce818fa68de
|
4
|
+
data.tar.gz: 12fbc3570986216550e4e95a2468f4f0ad3480e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4700cb3794b08d7e4fe23e89bcb170338adf7f29d1456be40f16f668f294a7cb3dd38554081409de27fc7f4a181201df1151da0014fda2383622afcdaf61c7e
|
7
|
+
data.tar.gz: a2524992db48919d067c43ebf50d6decc192c137fe722ecb16224ac1461b616a66ea06b3bf618780652af9b88fb0d3f38d74981613ae0d497bfc2ba1d8caf3dd
|
data/lib/hash.rb
CHANGED
@@ -2,8 +2,8 @@ class Hash
|
|
2
2
|
def to_parslet
|
3
3
|
case fetch("atom")
|
4
4
|
when "entity"
|
5
|
-
Parslet::Atoms::Entity.new(fetch("name")).tap do |
|
6
|
-
|
5
|
+
Parslet::Atoms::Entity.new(fetch("name")).tap do |atom|
|
6
|
+
atom.instance_variable_set("@parslet", fetch("parslet").to_parslet)
|
7
7
|
end
|
8
8
|
when "named"
|
9
9
|
Parslet::Atoms::Named.new(fetch("parslet").to_parslet, fetch("name"))
|
@@ -12,8 +12,8 @@ class Hash
|
|
12
12
|
when "sequence"
|
13
13
|
Parslet::Atoms::Sequence.new(*fetch("parslets").map(&:to_parslet))
|
14
14
|
when "re"
|
15
|
-
Parslet::Atoms::Re.new(fetch("match")).tap do |
|
16
|
-
|
15
|
+
Parslet::Atoms::Re.new(fetch("match")).tap do |atom|
|
16
|
+
atom.instance_variable_set("@re", fetch("re"))
|
17
17
|
end
|
18
18
|
when "str"
|
19
19
|
Parslet::Atoms::Str.new(fetch("str"))
|
data/lib/parslet-export.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Parslet
|
2
2
|
class Parser
|
3
|
+
# This turns a Parslet::Parser into a Hash
|
3
4
|
def to_hash
|
4
5
|
{
|
5
6
|
"atom" => "root",
|
@@ -7,8 +8,10 @@ module Parslet
|
|
7
8
|
}
|
8
9
|
end
|
9
10
|
|
11
|
+
# This turns a Hash into a Parslet::Parser
|
10
12
|
def self.from_hash(hash)
|
11
13
|
new.tap do |parser|
|
14
|
+
# Parsers have to have a #root method
|
12
15
|
parser.define_singleton_method(hash["atom"]) do
|
13
16
|
hash["parslet"].to_parslet
|
14
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Parslet::Atoms::Entity do
|
4
|
+
describe "#to_hash" do
|
5
|
+
let(:dump) do
|
6
|
+
described_class.new("foo").tap do |entity|
|
7
|
+
entity.instance_variable_set("@parslet", Parslet::Atoms::Str.new("foo"))
|
8
|
+
end.to_hash
|
9
|
+
end
|
10
|
+
|
11
|
+
it "contains the name" do
|
12
|
+
expect(dump["name"]).to eq("foo")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "contains the dumped parslet" do
|
16
|
+
expect(dump["parslet"]["atom"]).to eq("str")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Parslet::Atoms::Named do
|
4
|
+
describe "#to_hash" do
|
5
|
+
let(:dump) { described_class.new(Parslet::Atoms::Str.new("foo"), "foo").to_hash }
|
6
|
+
|
7
|
+
it "contains the name" do
|
8
|
+
expect(dump["name"]).to eq("foo")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "contains the dumped parslet" do
|
12
|
+
expect(dump["parslet"]["atom"]).to eq("str")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Parslet::Atoms::Repetition do
|
4
|
+
describe "#to_hash" do
|
5
|
+
let(:dump) { described_class.new(Parslet::Atoms::Str.new("foo"), 1, 2).to_hash }
|
6
|
+
|
7
|
+
it "should contain the min" do
|
8
|
+
expect(dump["min"]).to eq(1)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should contain the max" do
|
12
|
+
expect(dump["max"]).to eq(2)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should contain a dumped parslet" do
|
16
|
+
expect(dump["parslet"]["atom"]).to eq("str")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Parslet::Atoms::Sequence do
|
4
|
+
describe "#to_hash" do
|
5
|
+
let(:dump) do
|
6
|
+
described_class.new(Parslet::Atoms::Str.new("str")).to_hash
|
7
|
+
end
|
8
|
+
|
9
|
+
it "contains at least one parslet" do
|
10
|
+
expect(dump["parslets"].first["atom"]).to eq("str")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parslet-export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kurtis Rainbolt-Greene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -158,28 +158,25 @@ extensions: []
|
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
160
|
- lib/hash.rb
|
161
|
-
- lib/parslet/atoms/entity.rb
|
162
|
-
- lib/parslet/atoms/named.rb
|
163
|
-
- lib/parslet/atoms/re.rb
|
164
|
-
- lib/parslet/atoms/repetition.rb
|
165
|
-
- lib/parslet/atoms/sequence.rb
|
166
|
-
- lib/parslet/atoms/str.rb
|
167
|
-
- lib/parslet/atoms.rb
|
168
|
-
- lib/parslet
|
169
|
-
- lib/parslet/
|
170
|
-
- lib/parslet/parser.rb
|
161
|
+
- lib/parslet-export/atoms/entity.rb
|
162
|
+
- lib/parslet-export/atoms/named.rb
|
163
|
+
- lib/parslet-export/atoms/re.rb
|
164
|
+
- lib/parslet-export/atoms/repetition.rb
|
165
|
+
- lib/parslet-export/atoms/sequence.rb
|
166
|
+
- lib/parslet-export/atoms/str.rb
|
167
|
+
- lib/parslet-export/atoms.rb
|
168
|
+
- lib/parslet-export/parser.rb
|
169
|
+
- lib/parslet-export/version.rb
|
171
170
|
- lib/parslet-export.rb
|
172
171
|
- spec/lib/hash_spec.rb
|
173
|
-
- spec/lib/parslet/atoms/entity_spec.rb
|
174
|
-
- spec/lib/parslet/atoms/named_spec.rb
|
175
|
-
- spec/lib/parslet/atoms/re_spec.rb
|
176
|
-
- spec/lib/parslet/atoms/repetition_spec.rb
|
177
|
-
- spec/lib/parslet/atoms/sequence_spec.rb
|
178
|
-
- spec/lib/parslet/atoms/str_spec.rb
|
179
|
-
- spec/lib/parslet/
|
180
|
-
- spec/lib/parslet
|
181
|
-
- spec/lib/parslet/export_spec.rb
|
182
|
-
- spec/lib/parslet/parser_spec.rb
|
172
|
+
- spec/lib/parslet-export/atoms/entity_spec.rb
|
173
|
+
- spec/lib/parslet-export/atoms/named_spec.rb
|
174
|
+
- spec/lib/parslet-export/atoms/re_spec.rb
|
175
|
+
- spec/lib/parslet-export/atoms/repetition_spec.rb
|
176
|
+
- spec/lib/parslet-export/atoms/sequence_spec.rb
|
177
|
+
- spec/lib/parslet-export/atoms/str_spec.rb
|
178
|
+
- spec/lib/parslet-export/parser_spec.rb
|
179
|
+
- spec/lib/parslet-export/version_spec.rb
|
183
180
|
- spec/spec_helper.rb
|
184
181
|
homepage: http://krainboltgreene.github.com/parslet-export
|
185
182
|
licenses:
|
@@ -207,15 +204,13 @@ specification_version: 4
|
|
207
204
|
summary: Turn Parslet::Parser into other things
|
208
205
|
test_files:
|
209
206
|
- spec/lib/hash_spec.rb
|
210
|
-
- spec/lib/parslet/atoms/entity_spec.rb
|
211
|
-
- spec/lib/parslet/atoms/named_spec.rb
|
212
|
-
- spec/lib/parslet/atoms/re_spec.rb
|
213
|
-
- spec/lib/parslet/atoms/repetition_spec.rb
|
214
|
-
- spec/lib/parslet/atoms/sequence_spec.rb
|
215
|
-
- spec/lib/parslet/atoms/str_spec.rb
|
216
|
-
- spec/lib/parslet/
|
217
|
-
- spec/lib/parslet
|
218
|
-
- spec/lib/parslet/export_spec.rb
|
219
|
-
- spec/lib/parslet/parser_spec.rb
|
207
|
+
- spec/lib/parslet-export/atoms/entity_spec.rb
|
208
|
+
- spec/lib/parslet-export/atoms/named_spec.rb
|
209
|
+
- spec/lib/parslet-export/atoms/re_spec.rb
|
210
|
+
- spec/lib/parslet-export/atoms/repetition_spec.rb
|
211
|
+
- spec/lib/parslet-export/atoms/sequence_spec.rb
|
212
|
+
- spec/lib/parslet-export/atoms/str_spec.rb
|
213
|
+
- spec/lib/parslet-export/parser_spec.rb
|
214
|
+
- spec/lib/parslet-export/version_spec.rb
|
220
215
|
- spec/spec_helper.rb
|
221
216
|
has_rdoc:
|
data/lib/parslet/export.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Parslet::Atoms::Entity do
|
4
|
-
describe "#to_hash" do
|
5
|
-
let(:atom) do
|
6
|
-
described_class.new("foo").tap do |entity|
|
7
|
-
entity.instance_variable_set("@parslet", Parslet::Atoms::Str.new("foo"))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "returns a Hash object" do
|
12
|
-
expect(atom.to_hash).to be_kind_of(Hash)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "contains the name" do
|
16
|
-
expect(atom.to_hash["name"]).to eq("foo")
|
17
|
-
end
|
18
|
-
|
19
|
-
it "contains the parslet" do
|
20
|
-
expect(atom.to_hash["parslet"]).to be_kind_of(Hash)
|
21
|
-
expect(atom.to_hash["parslet"]).to have_key("atom")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Parslet::Atoms::Named do
|
4
|
-
describe "#to_hash" do
|
5
|
-
let(:atom) { described_class.new(Parslet::Atoms::Str.new("foo"), "foo") }
|
6
|
-
|
7
|
-
it "returns a Hash object" do
|
8
|
-
expect(atom.to_hash).to be_kind_of(Hash)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "contains the name" do
|
12
|
-
expect(atom.to_hash["name"]).to eq("foo")
|
13
|
-
end
|
14
|
-
|
15
|
-
it "contains the parslet" do
|
16
|
-
expect(atom.to_hash["parslet"]).to be_kind_of(Hash)
|
17
|
-
expect(atom.to_hash["parslet"]).to have_key("atom")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Parslet::Atoms::Re do
|
4
|
-
describe "#to_hash" do
|
5
|
-
let(:atom) { described_class.new(/foo/) }
|
6
|
-
it "returns a Hash object" do
|
7
|
-
expect(atom.to_hash).to be_kind_of(Hash)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "contains the formatted regular expression" do
|
11
|
-
expect(atom.to_hash["re"]).to eq(/(?-mix:foo)/m)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Parslet::Atoms::Repetition do
|
4
|
-
describe "#to_hash" do
|
5
|
-
let(:atom) { described_class.new(Parslet::Atoms::Str.new("foo"), 1, 2) }
|
6
|
-
|
7
|
-
it "returns a Hash object" do
|
8
|
-
expect(atom.to_hash).to be_kind_of(Hash)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should contain the min" do
|
12
|
-
expect(atom.to_hash["min"]).to eq(1)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should contain the max" do
|
16
|
-
expect(atom.to_hash["max"]).to eq(2)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should contain the parslet" do
|
20
|
-
expect(atom.to_hash["parslet"]).to be_kind_of(Hash)
|
21
|
-
expect(atom.to_hash["parslet"]).to have_key("atom")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Parslet::Atoms::Sequence do
|
4
|
-
describe "#to_hash" do
|
5
|
-
let(:atom) do
|
6
|
-
described_class.new(Parslet::Atoms::Str.new("str"))
|
7
|
-
end
|
8
|
-
|
9
|
-
it "returns a Hash object" do
|
10
|
-
expect(atom.to_hash).to be_kind_of(Hash)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "contains a parslet" do
|
14
|
-
expect(atom.to_hash["parslets"]).to be_kind_of(Array)
|
15
|
-
expect(atom.to_hash["parslets"].first).to have_key("atom")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|