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.
Files changed (95) hide show
  1. data/.gitmodules +3 -0
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -0
  4. data/README.md +52 -1
  5. data/Rakefile +12 -1
  6. data/lib/json_select/helpers/depth.rb +6 -2
  7. data/lib/json_select/helpers/key.rb +6 -2
  8. data/lib/json_select/helpers/position.rb +15 -7
  9. data/lib/json_select/helpers/size.rb +14 -6
  10. data/lib/json_select/helpers/type.rb +8 -4
  11. data/lib/json_select/selector.rb +47 -11
  12. data/lib/json_select/selector_parser.rb +179 -44
  13. data/lib/json_select/selector_parser.tt +9 -2
  14. data/lib/json_select/version.rb +1 -1
  15. data/spec/conformance_spec.rb +94 -38
  16. data/spec/fixtures/{basic_children.selector → parser/level_1/basic_children.output} +0 -0
  17. data/spec/fixtures/parser/level_1/basic_children.selector +1 -0
  18. data/spec/fixtures/{basic_combination.selector → parser/level_1/basic_combination.output} +0 -0
  19. data/spec/fixtures/parser/level_1/basic_combination.selector +1 -0
  20. data/spec/fixtures/parser/level_1/basic_first-child.output +1 -0
  21. data/spec/fixtures/{basic_first-child.selector → parser/level_1/basic_first-child.selector} +0 -0
  22. data/spec/fixtures/parser/level_1/basic_grouping.output +1 -0
  23. data/spec/fixtures/{basic_grouping.selector → parser/level_1/basic_grouping.selector} +0 -0
  24. data/spec/fixtures/parser/level_1/basic_id.output +1 -0
  25. data/spec/fixtures/{basic_id.selector → parser/level_1/basic_id.selector} +0 -0
  26. data/spec/fixtures/parser/level_1/basic_id_multiple.output +1 -0
  27. data/spec/fixtures/{basic_id_multiple.selector → parser/level_1/basic_id_multiple.selector} +0 -0
  28. data/spec/fixtures/parser/level_1/basic_id_quotes.output +1 -0
  29. data/spec/fixtures/{basic_id_quotes.selector → parser/level_1/basic_id_quotes.selector} +0 -0
  30. data/spec/fixtures/parser/level_1/basic_id_with_type.output +1 -0
  31. data/spec/fixtures/{basic_id_with_type.selector → parser/level_1/basic_id_with_type.selector} +0 -0
  32. data/spec/fixtures/parser/level_1/basic_last-child.output +1 -0
  33. data/spec/fixtures/{basic_last-child.selector → parser/level_1/basic_last-child.selector} +0 -0
  34. data/spec/fixtures/parser/level_1/basic_nth-child-2.output +1 -0
  35. data/spec/fixtures/{basic_nth-child-2.selector → parser/level_1/basic_nth-child-2.selector} +0 -0
  36. data/spec/fixtures/parser/level_1/basic_nth-child.output +1 -0
  37. data/spec/fixtures/{basic_nth-child.selector → parser/level_1/basic_nth-child.selector} +0 -0
  38. data/spec/fixtures/parser/level_1/basic_nth-last-child.output +1 -0
  39. data/spec/fixtures/{basic_nth-last-child.selector → parser/level_1/basic_nth-last-child.selector} +0 -0
  40. data/spec/fixtures/parser/level_1/basic_root_pseudo.output +1 -0
  41. data/spec/fixtures/{basic_root_pseudo.selector → parser/level_1/basic_root_pseudo.selector} +0 -0
  42. data/spec/fixtures/{basic_type.selector → parser/level_1/basic_type.output} +0 -0
  43. data/spec/fixtures/parser/level_1/basic_type.selector +1 -0
  44. data/spec/fixtures/{basic_type2.selector → parser/level_1/basic_type2.output} +0 -0
  45. data/spec/fixtures/parser/level_1/basic_type2.selector +1 -0
  46. data/spec/fixtures/parser/level_1/basic_type3.output +1 -0
  47. data/spec/fixtures/{basic_type3.selector → parser/level_1/basic_type3.selector} +0 -0
  48. data/spec/fixtures/parser/level_1/basic_universal.output +1 -0
  49. data/spec/fixtures/{basic_universal.selector → parser/level_1/basic_universal.selector} +0 -0
  50. data/spec/fixtures/parser/level_3/basic_has-sans-paren.output +1 -0
  51. data/spec/fixtures/parser/level_3/basic_has-sans-paren.selector +2 -0
  52. data/spec/fixtures/parser/level_3/basic_has-whitespace.output +1 -0
  53. data/spec/fixtures/parser/level_3/basic_has-whitespace.selector +3 -0
  54. data/spec/fixtures/parser/level_3/basic_has.output +1 -0
  55. data/spec/fixtures/parser/level_3/basic_has.selector +1 -0
  56. data/spec/parser_spec.rb +52 -0
  57. metadata +123 -148
  58. data/spec/fixtures/README.md +0 -14
  59. data/spec/fixtures/alltests.txt +0 -31
  60. data/spec/fixtures/basic.json +0 -31
  61. data/spec/fixtures/basic.xml +0 -31
  62. data/spec/fixtures/basic_children.ast +0 -14
  63. data/spec/fixtures/basic_children.output +0 -1
  64. data/spec/fixtures/basic_combination.ast +0 -13
  65. data/spec/fixtures/basic_combination.output +0 -1
  66. data/spec/fixtures/basic_first-child.ast +0 -11
  67. data/spec/fixtures/basic_first-child.output +0 -2
  68. data/spec/fixtures/basic_grouping.ast +0 -22
  69. data/spec/fixtures/basic_grouping.output +0 -4
  70. data/spec/fixtures/basic_id.ast +0 -7
  71. data/spec/fixtures/basic_id.output +0 -1
  72. data/spec/fixtures/basic_id_multiple.ast +0 -7
  73. data/spec/fixtures/basic_id_multiple.output +0 -3
  74. data/spec/fixtures/basic_id_quotes.ast +0 -7
  75. data/spec/fixtures/basic_id_quotes.output +0 -2
  76. data/spec/fixtures/basic_id_with_type.ast +0 -10
  77. data/spec/fixtures/basic_id_with_type.output +0 -1
  78. data/spec/fixtures/basic_last-child.ast +0 -11
  79. data/spec/fixtures/basic_last-child.output +0 -2
  80. data/spec/fixtures/basic_nth-child-2.ast +0 -11
  81. data/spec/fixtures/basic_nth-child-2.output +0 -4
  82. data/spec/fixtures/basic_nth-child.ast +0 -11
  83. data/spec/fixtures/basic_nth-child.output +0 -3
  84. data/spec/fixtures/basic_nth-last-child.ast +0 -11
  85. data/spec/fixtures/basic_nth-last-child.output +0 -2
  86. data/spec/fixtures/basic_root_pseudo.ast +0 -6
  87. data/spec/fixtures/basic_root_pseudo.output +0 -31
  88. data/spec/fixtures/basic_type.ast +0 -7
  89. data/spec/fixtures/basic_type.output +0 -14
  90. data/spec/fixtures/basic_type2.ast +0 -7
  91. data/spec/fixtures/basic_type2.output +0 -1
  92. data/spec/fixtures/basic_type3.ast +0 -7
  93. data/spec/fixtures/basic_type3.output +0 -47
  94. data/spec/fixtures/basic_universal.ast +0 -5
  95. data/spec/fixtures/basic_universal.output +0 -86
@@ -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.
@@ -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
@@ -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,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,14 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "has_class"
3
- , "n" : "name"
4
- }
5
- ]
6
- }
7
- , ">"
8
- , { "tests" :
9
- [ { "f" : "has_class"
10
- , "n" : "first"
11
- }
12
- ]
13
- }
14
- ]
@@ -1 +0,0 @@
1
- "Lloyd"
@@ -1,13 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "has_class"
3
- , "n" : "name"
4
- }
5
- ]
6
- }
7
- , { "tests" :
8
- [ { "f" : "has_class"
9
- , "n" : "first"
10
- }
11
- ]
12
- }
13
- ]
@@ -1 +0,0 @@
1
- "Lloyd"
@@ -1,11 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "nth_child"
6
- , "a" : 0
7
- , "b" : 1
8
- }
9
- ]
10
- }
11
- ]
@@ -1,2 +0,0 @@
1
- "window"
2
- "beer"
@@ -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
- ]
@@ -1,4 +0,0 @@
1
- "advanced"
2
- "native"
3
- "beginner"
4
- 172
@@ -1,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "has_class"
3
- , "n" : "favoriteColor"
4
- }
5
- ]
6
- }
7
- ]
@@ -1 +0,0 @@
1
- "yellow"
@@ -1,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "has_class"
3
- , "n" : "language"
4
- }
5
- ]
6
- }
7
- ]
@@ -1,3 +0,0 @@
1
- "Bulgarian"
2
- "English"
3
- "Spanish"
@@ -1,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "has_class"
3
- , "n" : "weight"
4
- }
5
- ]
6
- }
7
- ]
@@ -1,2 +0,0 @@
1
- 172
2
-
@@ -1,10 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "has_class"
6
- , "n" : "favoriteColor"
7
- }
8
- ]
9
- }
10
- ]
@@ -1 +0,0 @@
1
- "yellow"
@@ -1,11 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "nth_last_child"
6
- , "a" : 0
7
- , "b" : 1
8
- }
9
- ]
10
- }
11
- ]
@@ -1,2 +0,0 @@
1
- "aisle"
2
- "wine"
@@ -1,11 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "nth_child"
6
- , "a" : -1
7
- , "b" : 2
8
- }
9
- ]
10
- }
11
- ]
@@ -1,4 +0,0 @@
1
- "window"
2
- "aisle"
3
- "beer"
4
- "whiskey"
@@ -1,11 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "nth_child"
6
- , "a" : 2
7
- , "b" : 1
8
- }
9
- ]
10
- }
11
- ]
@@ -1,3 +0,0 @@
1
- "window"
2
- "beer"
3
- "wine"
@@ -1,11 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- , { "f" : "nth_last_child"
6
- , "a" : 0
7
- , "b" : 1
8
- }
9
- ]
10
- }
11
- ]
@@ -1,2 +0,0 @@
1
- "aisle"
2
- "wine"
@@ -1,6 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "is_root"
3
- }
4
- ]
5
- }
6
- ]
@@ -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,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "string"
4
- }
5
- ]
6
- }
7
- ]
@@ -1,14 +0,0 @@
1
- "Lloyd"
2
- "Hilaiel"
3
- "yellow"
4
- "Bulgarian"
5
- "advanced"
6
- "English"
7
- "native"
8
- "Spanish"
9
- "beginner"
10
- "window"
11
- "aisle"
12
- "beer"
13
- "whiskey"
14
- "wine"
@@ -1,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "number"
4
- }
5
- ]
6
- }
7
- ]
@@ -1 +0,0 @@
1
- 172
@@ -1,7 +0,0 @@
1
- [ { "tests" :
2
- [ { "f" : "instance_of_type"
3
- , "n" : "object"
4
- }
5
- ]
6
- }
7
- ]
@@ -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
- }