json_select 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/.travis.yml +1 -1
- data/Gemfile +1 -0
- data/README.md +52 -1
- data/Rakefile +12 -1
- data/lib/json_select/helpers/depth.rb +6 -2
- data/lib/json_select/helpers/key.rb +6 -2
- data/lib/json_select/helpers/position.rb +15 -7
- data/lib/json_select/helpers/size.rb +14 -6
- data/lib/json_select/helpers/type.rb +8 -4
- data/lib/json_select/selector.rb +47 -11
- data/lib/json_select/selector_parser.rb +179 -44
- data/lib/json_select/selector_parser.tt +9 -2
- data/lib/json_select/version.rb +1 -1
- data/spec/conformance_spec.rb +94 -38
- data/spec/fixtures/{basic_children.selector → parser/level_1/basic_children.output} +0 -0
- data/spec/fixtures/parser/level_1/basic_children.selector +1 -0
- data/spec/fixtures/{basic_combination.selector → parser/level_1/basic_combination.output} +0 -0
- data/spec/fixtures/parser/level_1/basic_combination.selector +1 -0
- data/spec/fixtures/parser/level_1/basic_first-child.output +1 -0
- data/spec/fixtures/{basic_first-child.selector → parser/level_1/basic_first-child.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_grouping.output +1 -0
- data/spec/fixtures/{basic_grouping.selector → parser/level_1/basic_grouping.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_id.output +1 -0
- data/spec/fixtures/{basic_id.selector → parser/level_1/basic_id.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_id_multiple.output +1 -0
- data/spec/fixtures/{basic_id_multiple.selector → parser/level_1/basic_id_multiple.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_id_quotes.output +1 -0
- data/spec/fixtures/{basic_id_quotes.selector → parser/level_1/basic_id_quotes.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_id_with_type.output +1 -0
- data/spec/fixtures/{basic_id_with_type.selector → parser/level_1/basic_id_with_type.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_last-child.output +1 -0
- data/spec/fixtures/{basic_last-child.selector → parser/level_1/basic_last-child.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_nth-child-2.output +1 -0
- data/spec/fixtures/{basic_nth-child-2.selector → parser/level_1/basic_nth-child-2.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_nth-child.output +1 -0
- data/spec/fixtures/{basic_nth-child.selector → parser/level_1/basic_nth-child.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_nth-last-child.output +1 -0
- data/spec/fixtures/{basic_nth-last-child.selector → parser/level_1/basic_nth-last-child.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_root_pseudo.output +1 -0
- data/spec/fixtures/{basic_root_pseudo.selector → parser/level_1/basic_root_pseudo.selector} +0 -0
- data/spec/fixtures/{basic_type.selector → parser/level_1/basic_type.output} +0 -0
- data/spec/fixtures/parser/level_1/basic_type.selector +1 -0
- data/spec/fixtures/{basic_type2.selector → parser/level_1/basic_type2.output} +0 -0
- data/spec/fixtures/parser/level_1/basic_type2.selector +1 -0
- data/spec/fixtures/parser/level_1/basic_type3.output +1 -0
- data/spec/fixtures/{basic_type3.selector → parser/level_1/basic_type3.selector} +0 -0
- data/spec/fixtures/parser/level_1/basic_universal.output +1 -0
- data/spec/fixtures/{basic_universal.selector → parser/level_1/basic_universal.selector} +0 -0
- data/spec/fixtures/parser/level_3/basic_has-sans-paren.output +1 -0
- data/spec/fixtures/parser/level_3/basic_has-sans-paren.selector +2 -0
- data/spec/fixtures/parser/level_3/basic_has-whitespace.output +1 -0
- data/spec/fixtures/parser/level_3/basic_has-whitespace.selector +3 -0
- data/spec/fixtures/parser/level_3/basic_has.output +1 -0
- data/spec/fixtures/parser/level_3/basic_has.selector +1 -0
- data/spec/parser_spec.rb +52 -0
- metadata +123 -148
- data/spec/fixtures/README.md +0 -14
- data/spec/fixtures/alltests.txt +0 -31
- data/spec/fixtures/basic.json +0 -31
- data/spec/fixtures/basic.xml +0 -31
- data/spec/fixtures/basic_children.ast +0 -14
- data/spec/fixtures/basic_children.output +0 -1
- data/spec/fixtures/basic_combination.ast +0 -13
- data/spec/fixtures/basic_combination.output +0 -1
- data/spec/fixtures/basic_first-child.ast +0 -11
- data/spec/fixtures/basic_first-child.output +0 -2
- data/spec/fixtures/basic_grouping.ast +0 -22
- data/spec/fixtures/basic_grouping.output +0 -4
- data/spec/fixtures/basic_id.ast +0 -7
- data/spec/fixtures/basic_id.output +0 -1
- data/spec/fixtures/basic_id_multiple.ast +0 -7
- data/spec/fixtures/basic_id_multiple.output +0 -3
- data/spec/fixtures/basic_id_quotes.ast +0 -7
- data/spec/fixtures/basic_id_quotes.output +0 -2
- data/spec/fixtures/basic_id_with_type.ast +0 -10
- data/spec/fixtures/basic_id_with_type.output +0 -1
- data/spec/fixtures/basic_last-child.ast +0 -11
- data/spec/fixtures/basic_last-child.output +0 -2
- data/spec/fixtures/basic_nth-child-2.ast +0 -11
- data/spec/fixtures/basic_nth-child-2.output +0 -4
- data/spec/fixtures/basic_nth-child.ast +0 -11
- data/spec/fixtures/basic_nth-child.output +0 -3
- data/spec/fixtures/basic_nth-last-child.ast +0 -11
- data/spec/fixtures/basic_nth-last-child.output +0 -2
- data/spec/fixtures/basic_root_pseudo.ast +0 -6
- data/spec/fixtures/basic_root_pseudo.output +0 -31
- data/spec/fixtures/basic_type.ast +0 -7
- data/spec/fixtures/basic_type.output +0 -14
- data/spec/fixtures/basic_type2.ast +0 -7
- data/spec/fixtures/basic_type2.output +0 -1
- data/spec/fixtures/basic_type3.ast +0 -7
- data/spec/fixtures/basic_type3.output +0 -47
- data/spec/fixtures/basic_universal.ast +0 -5
- data/spec/fixtures/basic_universal.output +0 -86
data/spec/fixtures/README.md
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
## JSONSelect Conformance Tests.
|
2
|
-
|
3
|
-
Test documents have a suffix of `.json`, like `basic.json`.
|
4
|
-
|
5
|
-
Selectors to be applied to test documents have the document name,
|
6
|
-
followed by an underbar, followed by a description of the test, with
|
7
|
-
a `.selector` file name suffix, like `basic_grouping.selector`.
|
8
|
-
|
9
|
-
Expected output files have the same name as the `.selector` file,
|
10
|
-
but have a `.output` suffix, like `basic_grouping.output`.
|
11
|
-
|
12
|
-
Expected output files contain a stream of JSON objects that are what
|
13
|
-
is expected to be produced when a given selector is applied to a given
|
14
|
-
document.
|
data/spec/fixtures/alltests.txt
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
basic.json
|
2
|
-
basic_first-child.output
|
3
|
-
basic_first-child.selector
|
4
|
-
basic_grouping.output
|
5
|
-
basic_grouping.selector
|
6
|
-
basic_id.output
|
7
|
-
basic_id.selector
|
8
|
-
basic_id_multiple.output
|
9
|
-
basic_id_multiple.selector
|
10
|
-
basic_id_quotes.output
|
11
|
-
basic_id_quotes.selector
|
12
|
-
basic_id_with_type.output
|
13
|
-
basic_id_with_type.selector
|
14
|
-
basic_last-child.output
|
15
|
-
basic_last-child.selector
|
16
|
-
basic_nth-child-2.output
|
17
|
-
basic_nth-child-2.selector
|
18
|
-
basic_nth-child.output
|
19
|
-
basic_nth-child.selector
|
20
|
-
basic_nth-last-child.output
|
21
|
-
basic_nth-last-child.selector
|
22
|
-
basic_root_pseudo.output
|
23
|
-
basic_root_pseudo.selector
|
24
|
-
basic_type.output
|
25
|
-
basic_type.selector
|
26
|
-
basic_type2.output
|
27
|
-
basic_type2.selector
|
28
|
-
basic_type3.output
|
29
|
-
basic_type3.selector
|
30
|
-
basic_universal.output
|
31
|
-
basic_universal.selector
|
data/spec/fixtures/basic.json
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": {
|
3
|
-
"first": "Lloyd",
|
4
|
-
"last": "Hilaiel"
|
5
|
-
},
|
6
|
-
"favoriteColor": "yellow",
|
7
|
-
"languagesSpoken": [
|
8
|
-
{
|
9
|
-
"language": "Bulgarian",
|
10
|
-
"level": "advanced"
|
11
|
-
},
|
12
|
-
{
|
13
|
-
"language": "English",
|
14
|
-
"level": "native"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
"language": "Spanish",
|
18
|
-
"level": "beginner"
|
19
|
-
}
|
20
|
-
],
|
21
|
-
"seatingPreference": [
|
22
|
-
"window",
|
23
|
-
"aisle"
|
24
|
-
],
|
25
|
-
"drinkPreference": [
|
26
|
-
"beer",
|
27
|
-
"whiskey",
|
28
|
-
"wine"
|
29
|
-
],
|
30
|
-
"weight": 172
|
31
|
-
}
|
data/spec/fixtures/basic.xml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
<object>
|
2
|
-
<object id="name">
|
3
|
-
<string id="first">Lloyd</string>
|
4
|
-
<string id="last">Hilaiel</string>
|
5
|
-
</object>
|
6
|
-
<string id="favoriteColor">yellow</string>
|
7
|
-
<array id="languagesSpoken">
|
8
|
-
<object>
|
9
|
-
<string id="language">Bulgarian</string>
|
10
|
-
<string id="level">advanced</string>
|
11
|
-
</object>
|
12
|
-
<object>
|
13
|
-
<string id="language">English</string>
|
14
|
-
<string id="level">native</string>
|
15
|
-
</object>
|
16
|
-
<object>
|
17
|
-
<string id="language">Spanish</string>
|
18
|
-
<string id="level">beginner</string>
|
19
|
-
</object>
|
20
|
-
</array>
|
21
|
-
<array id="seatingPreference">
|
22
|
-
<string>window</string>
|
23
|
-
<string>aisle</string>
|
24
|
-
</array>
|
25
|
-
<array id="drinkPreference">
|
26
|
-
<string>beer</string>
|
27
|
-
<string>whiskey</string>
|
28
|
-
<string>wine</string>
|
29
|
-
</array>
|
30
|
-
<number id="weight">172</number>
|
31
|
-
</object>
|
@@ -1 +0,0 @@
|
|
1
|
-
"Lloyd"
|
@@ -1 +0,0 @@
|
|
1
|
-
"Lloyd"
|
@@ -1,22 +0,0 @@
|
|
1
|
-
[ ","
|
2
|
-
|
3
|
-
, [ { "tests" :
|
4
|
-
[ { "f" : "instance_of_type"
|
5
|
-
, "n" : "string"
|
6
|
-
}
|
7
|
-
, { "f" : "has_class"
|
8
|
-
, "n" : "level"
|
9
|
-
}
|
10
|
-
]
|
11
|
-
}
|
12
|
-
]
|
13
|
-
|
14
|
-
, [ { "tests" :
|
15
|
-
[ { "f" : "instance_of_type"
|
16
|
-
, "n" : "number"
|
17
|
-
}
|
18
|
-
]
|
19
|
-
}
|
20
|
-
]
|
21
|
-
|
22
|
-
]
|
data/spec/fixtures/basic_id.ast
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"yellow"
|
@@ -1 +0,0 @@
|
|
1
|
-
"yellow"
|
@@ -1,31 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": {
|
3
|
-
"first": "Lloyd",
|
4
|
-
"last": "Hilaiel"
|
5
|
-
},
|
6
|
-
"favoriteColor": "yellow",
|
7
|
-
"languagesSpoken": [
|
8
|
-
{
|
9
|
-
"language": "Bulgarian",
|
10
|
-
"level": "advanced"
|
11
|
-
},
|
12
|
-
{
|
13
|
-
"language": "English",
|
14
|
-
"level": "native"
|
15
|
-
},
|
16
|
-
{
|
17
|
-
"language": "Spanish",
|
18
|
-
"level": "beginner"
|
19
|
-
}
|
20
|
-
],
|
21
|
-
"seatingPreference": [
|
22
|
-
"window",
|
23
|
-
"aisle"
|
24
|
-
],
|
25
|
-
"drinkPreference": [
|
26
|
-
"beer",
|
27
|
-
"whiskey",
|
28
|
-
"wine"
|
29
|
-
],
|
30
|
-
"weight": 172
|
31
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
172
|
@@ -1,47 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"first": "Lloyd",
|
3
|
-
"last": "Hilaiel"
|
4
|
-
}
|
5
|
-
{
|
6
|
-
"language": "Bulgarian",
|
7
|
-
"level": "advanced"
|
8
|
-
}
|
9
|
-
{
|
10
|
-
"language": "English",
|
11
|
-
"level": "native"
|
12
|
-
}
|
13
|
-
{
|
14
|
-
"language": "Spanish",
|
15
|
-
"level": "beginner"
|
16
|
-
}
|
17
|
-
{
|
18
|
-
"name": {
|
19
|
-
"first": "Lloyd",
|
20
|
-
"last": "Hilaiel"
|
21
|
-
},
|
22
|
-
"favoriteColor": "yellow",
|
23
|
-
"languagesSpoken": [
|
24
|
-
{
|
25
|
-
"language": "Bulgarian",
|
26
|
-
"level": "advanced"
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"language": "English",
|
30
|
-
"level": "native"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"language": "Spanish",
|
34
|
-
"level": "beginner"
|
35
|
-
}
|
36
|
-
],
|
37
|
-
"seatingPreference": [
|
38
|
-
"window",
|
39
|
-
"aisle"
|
40
|
-
],
|
41
|
-
"drinkPreference": [
|
42
|
-
"beer",
|
43
|
-
"whiskey",
|
44
|
-
"wine"
|
45
|
-
],
|
46
|
-
"weight": 172
|
47
|
-
}
|