json_select 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +7 -0
  3. data/LICENSE +20 -0
  4. data/README.md +67 -0
  5. data/Rakefile +18 -0
  6. data/json_select.gemspec +23 -0
  7. data/lib/json_select.rb +35 -0
  8. data/lib/json_select/ast/combination_selector.rb +14 -0
  9. data/lib/json_select/ast/complex_expr.rb +27 -0
  10. data/lib/json_select/ast/even_expr.rb +7 -0
  11. data/lib/json_select/ast/hash_selector.rb +12 -0
  12. data/lib/json_select/ast/odd_expr.rb +7 -0
  13. data/lib/json_select/ast/pseudo_selector.rb +24 -0
  14. data/lib/json_select/ast/selector_group.rb +17 -0
  15. data/lib/json_select/ast/simple_expr.rb +7 -0
  16. data/lib/json_select/ast/simple_selector.rb +23 -0
  17. data/lib/json_select/ast/type_selector.rb +8 -0
  18. data/lib/json_select/ast/universal_selector.rb +7 -0
  19. data/lib/json_select/parser.rb +19 -0
  20. data/lib/json_select/selector.rb +176 -0
  21. data/lib/json_select/selector_parser.rb +1251 -0
  22. data/lib/json_select/selector_parser.tt +161 -0
  23. data/lib/json_select/version.rb +3 -0
  24. data/spec/conformance_spec.rb +41 -0
  25. data/spec/fixtures/README.md +14 -0
  26. data/spec/fixtures/alltests.txt +31 -0
  27. data/spec/fixtures/basic.json +31 -0
  28. data/spec/fixtures/basic.xml +31 -0
  29. data/spec/fixtures/basic_first-child.ast +6 -0
  30. data/spec/fixtures/basic_first-child.output +6 -0
  31. data/spec/fixtures/basic_first-child.selector +2 -0
  32. data/spec/fixtures/basic_grouping.ast +12 -0
  33. data/spec/fixtures/basic_grouping.output +4 -0
  34. data/spec/fixtures/basic_grouping.selector +1 -0
  35. data/spec/fixtures/basic_id.ast +3 -0
  36. data/spec/fixtures/basic_id.output +1 -0
  37. data/spec/fixtures/basic_id.selector +1 -0
  38. data/spec/fixtures/basic_id_multiple.ast +3 -0
  39. data/spec/fixtures/basic_id_multiple.output +3 -0
  40. data/spec/fixtures/basic_id_multiple.selector +1 -0
  41. data/spec/fixtures/basic_id_quotes.ast +3 -0
  42. data/spec/fixtures/basic_id_quotes.output +2 -0
  43. data/spec/fixtures/basic_id_quotes.selector +1 -0
  44. data/spec/fixtures/basic_id_with_type.ast +4 -0
  45. data/spec/fixtures/basic_id_with_type.output +1 -0
  46. data/spec/fixtures/basic_id_with_type.selector +1 -0
  47. data/spec/fixtures/basic_last-child.ast +6 -0
  48. data/spec/fixtures/basic_last-child.output +6 -0
  49. data/spec/fixtures/basic_last-child.selector +2 -0
  50. data/spec/fixtures/basic_nth-child-2.ast +6 -0
  51. data/spec/fixtures/basic_nth-child-2.output +13 -0
  52. data/spec/fixtures/basic_nth-child-2.selector +1 -0
  53. data/spec/fixtures/basic_nth-child.ast +6 -0
  54. data/spec/fixtures/basic_nth-child.output +7 -0
  55. data/spec/fixtures/basic_nth-child.selector +1 -0
  56. data/spec/fixtures/basic_nth-last-child.ast +6 -0
  57. data/spec/fixtures/basic_nth-last-child.output +6 -0
  58. data/spec/fixtures/basic_nth-last-child.selector +1 -0
  59. data/spec/fixtures/basic_root_pseudo.ast +3 -0
  60. data/spec/fixtures/basic_root_pseudo.output +31 -0
  61. data/spec/fixtures/basic_root_pseudo.selector +1 -0
  62. data/spec/fixtures/basic_type.ast +3 -0
  63. data/spec/fixtures/basic_type.output +14 -0
  64. data/spec/fixtures/basic_type.selector +1 -0
  65. data/spec/fixtures/basic_type2.ast +3 -0
  66. data/spec/fixtures/basic_type2.output +1 -0
  67. data/spec/fixtures/basic_type2.selector +1 -0
  68. data/spec/fixtures/basic_type3.ast +3 -0
  69. data/spec/fixtures/basic_type3.output +47 -0
  70. data/spec/fixtures/basic_type3.selector +1 -0
  71. data/spec/fixtures/basic_universal.ast +2 -0
  72. data/spec/fixtures/basic_universal.output +85 -0
  73. data/spec/fixtures/basic_universal.selector +1 -0
  74. data/spec/spec_helper.rb +6 -0
  75. metadata +190 -0
@@ -0,0 +1,13 @@
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"
@@ -0,0 +1 @@
1
+ string:nth-child(-n+2)
@@ -0,0 +1,6 @@
1
+ [ { "type" : "string"
2
+ , "pseudo_function" : "nth-child"
3
+ , "a" : 2
4
+ , "b" : 1
5
+ }
6
+ ]
@@ -0,0 +1,7 @@
1
+ "Lloyd"
2
+ "Bulgarian"
3
+ "English"
4
+ "Spanish"
5
+ "window"
6
+ "beer"
7
+ "wine"
@@ -0,0 +1 @@
1
+ string:nth-child(odd)
@@ -0,0 +1,6 @@
1
+ [ { "type" : "string"
2
+ , "pseudo_function" : "nth-last-child"
3
+ , "a" : 0
4
+ , "b" : 1
5
+ }
6
+ ]
@@ -0,0 +1,6 @@
1
+ "Hilaiel"
2
+ "advanced"
3
+ "native"
4
+ "beginner"
5
+ "aisle"
6
+ "wine"
@@ -0,0 +1 @@
1
+ string:nth-last-child(1)
@@ -0,0 +1,3 @@
1
+ [ { "pseudo_class" : "root"
2
+ }
3
+ ]
@@ -0,0 +1,31 @@
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
+ }
@@ -0,0 +1 @@
1
+ :root
@@ -0,0 +1,3 @@
1
+ [ { "type" : "string"
2
+ }
3
+ ]
@@ -0,0 +1,14 @@
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"
@@ -0,0 +1 @@
1
+ string
@@ -0,0 +1,3 @@
1
+ [ { "type" : "number"
2
+ }
3
+ ]
@@ -0,0 +1 @@
1
+ 172
@@ -0,0 +1 @@
1
+ number
@@ -0,0 +1,3 @@
1
+ [ { "type" : "object"
2
+ }
3
+ ]
@@ -0,0 +1,47 @@
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
+ }
@@ -0,0 +1 @@
1
+ object
@@ -0,0 +1,2 @@
1
+ [ { }
2
+ ]
@@ -0,0 +1,85 @@
1
+ "Lloyd"
2
+ "Hilaiel"
3
+ {
4
+ "first": "Lloyd",
5
+ "last": "Hilaiel"
6
+ }
7
+ "yellow"
8
+ "Bulgarian"
9
+ "advanced"
10
+ {
11
+ "language": "Bulgarian",
12
+ "level": "advanced"
13
+ }
14
+ "English"
15
+ "native"
16
+ {
17
+ "language": "English",
18
+ "level": "native"
19
+ }
20
+ "Spanish"
21
+ "beginner"
22
+ {
23
+ "language": "Spanish",
24
+ "level": "beginner"
25
+ }
26
+ [
27
+ {
28
+ "language": "Bulgarian",
29
+ "level": "advanced"
30
+ },
31
+ {
32
+ "language": "English",
33
+ "level": "native"
34
+ },
35
+ {
36
+ "language": "Spanish",
37
+ "level": "beginner"
38
+ }
39
+ ]
40
+ "window"
41
+ "aisle"
42
+ [
43
+ "window",
44
+ "aisle"
45
+ ]
46
+ "beer"
47
+ "whiskey"
48
+ "wine"
49
+ [
50
+ "beer",
51
+ "whiskey",
52
+ "wine"
53
+ ]
54
+ 172
55
+ {
56
+ "name": {
57
+ "first": "Lloyd",
58
+ "last": "Hilaiel"
59
+ },
60
+ "favoriteColor": "yellow",
61
+ "languagesSpoken": [
62
+ {
63
+ "language": "Bulgarian",
64
+ "level": "advanced"
65
+ },
66
+ {
67
+ "language": "English",
68
+ "level": "native"
69
+ },
70
+ {
71
+ "language": "Spanish",
72
+ "level": "beginner"
73
+ }
74
+ ],
75
+ "seatingPreference": [
76
+ "window",
77
+ "aisle"
78
+ ],
79
+ "drinkPreference": [
80
+ "beer",
81
+ "whiskey",
82
+ "wine"
83
+ ],
84
+ "weight": 172
85
+ }
@@ -0,0 +1 @@
1
+ *
@@ -0,0 +1,6 @@
1
+ require 'yajl'
2
+ require 'json_select'
3
+
4
+ RSpec.configure do |config|
5
+
6
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json_select
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Simon Menke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-23 00:00:00 +02:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: treetop
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: JSONSelect implementation for Ruby
28
+ email:
29
+ - simon.menke@gmail.com
30
+ executables: []
31
+
32
+ extensions: []
33
+
34
+ extra_rdoc_files: []
35
+
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - json_select.gemspec
43
+ - lib/json_select.rb
44
+ - lib/json_select/ast/combination_selector.rb
45
+ - lib/json_select/ast/complex_expr.rb
46
+ - lib/json_select/ast/even_expr.rb
47
+ - lib/json_select/ast/hash_selector.rb
48
+ - lib/json_select/ast/odd_expr.rb
49
+ - lib/json_select/ast/pseudo_selector.rb
50
+ - lib/json_select/ast/selector_group.rb
51
+ - lib/json_select/ast/simple_expr.rb
52
+ - lib/json_select/ast/simple_selector.rb
53
+ - lib/json_select/ast/type_selector.rb
54
+ - lib/json_select/ast/universal_selector.rb
55
+ - lib/json_select/parser.rb
56
+ - lib/json_select/selector.rb
57
+ - lib/json_select/selector_parser.rb
58
+ - lib/json_select/selector_parser.tt
59
+ - lib/json_select/version.rb
60
+ - spec/conformance_spec.rb
61
+ - spec/fixtures/README.md
62
+ - spec/fixtures/alltests.txt
63
+ - spec/fixtures/basic.json
64
+ - spec/fixtures/basic.xml
65
+ - spec/fixtures/basic_first-child.ast
66
+ - spec/fixtures/basic_first-child.output
67
+ - spec/fixtures/basic_first-child.selector
68
+ - spec/fixtures/basic_grouping.ast
69
+ - spec/fixtures/basic_grouping.output
70
+ - spec/fixtures/basic_grouping.selector
71
+ - spec/fixtures/basic_id.ast
72
+ - spec/fixtures/basic_id.output
73
+ - spec/fixtures/basic_id.selector
74
+ - spec/fixtures/basic_id_multiple.ast
75
+ - spec/fixtures/basic_id_multiple.output
76
+ - spec/fixtures/basic_id_multiple.selector
77
+ - spec/fixtures/basic_id_quotes.ast
78
+ - spec/fixtures/basic_id_quotes.output
79
+ - spec/fixtures/basic_id_quotes.selector
80
+ - spec/fixtures/basic_id_with_type.ast
81
+ - spec/fixtures/basic_id_with_type.output
82
+ - spec/fixtures/basic_id_with_type.selector
83
+ - spec/fixtures/basic_last-child.ast
84
+ - spec/fixtures/basic_last-child.output
85
+ - spec/fixtures/basic_last-child.selector
86
+ - spec/fixtures/basic_nth-child-2.ast
87
+ - spec/fixtures/basic_nth-child-2.output
88
+ - spec/fixtures/basic_nth-child-2.selector
89
+ - spec/fixtures/basic_nth-child.ast
90
+ - spec/fixtures/basic_nth-child.output
91
+ - spec/fixtures/basic_nth-child.selector
92
+ - spec/fixtures/basic_nth-last-child.ast
93
+ - spec/fixtures/basic_nth-last-child.output
94
+ - spec/fixtures/basic_nth-last-child.selector
95
+ - spec/fixtures/basic_root_pseudo.ast
96
+ - spec/fixtures/basic_root_pseudo.output
97
+ - spec/fixtures/basic_root_pseudo.selector
98
+ - spec/fixtures/basic_type.ast
99
+ - spec/fixtures/basic_type.output
100
+ - spec/fixtures/basic_type.selector
101
+ - spec/fixtures/basic_type2.ast
102
+ - spec/fixtures/basic_type2.output
103
+ - spec/fixtures/basic_type2.selector
104
+ - spec/fixtures/basic_type3.ast
105
+ - spec/fixtures/basic_type3.output
106
+ - spec/fixtures/basic_type3.selector
107
+ - spec/fixtures/basic_universal.ast
108
+ - spec/fixtures/basic_universal.output
109
+ - spec/fixtures/basic_universal.selector
110
+ - spec/spec_helper.rb
111
+ has_rdoc: true
112
+ homepage: http://github.com/fd/json_select
113
+ licenses: []
114
+
115
+ post_install_message:
116
+ rdoc_options: []
117
+
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: "0"
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: "0"
132
+ requirements: []
133
+
134
+ rubyforge_project: json_select
135
+ rubygems_version: 1.6.2
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: JSONSelect implementation for Ruby
139
+ test_files:
140
+ - spec/conformance_spec.rb
141
+ - spec/fixtures/README.md
142
+ - spec/fixtures/alltests.txt
143
+ - spec/fixtures/basic.json
144
+ - spec/fixtures/basic.xml
145
+ - spec/fixtures/basic_first-child.ast
146
+ - spec/fixtures/basic_first-child.output
147
+ - spec/fixtures/basic_first-child.selector
148
+ - spec/fixtures/basic_grouping.ast
149
+ - spec/fixtures/basic_grouping.output
150
+ - spec/fixtures/basic_grouping.selector
151
+ - spec/fixtures/basic_id.ast
152
+ - spec/fixtures/basic_id.output
153
+ - spec/fixtures/basic_id.selector
154
+ - spec/fixtures/basic_id_multiple.ast
155
+ - spec/fixtures/basic_id_multiple.output
156
+ - spec/fixtures/basic_id_multiple.selector
157
+ - spec/fixtures/basic_id_quotes.ast
158
+ - spec/fixtures/basic_id_quotes.output
159
+ - spec/fixtures/basic_id_quotes.selector
160
+ - spec/fixtures/basic_id_with_type.ast
161
+ - spec/fixtures/basic_id_with_type.output
162
+ - spec/fixtures/basic_id_with_type.selector
163
+ - spec/fixtures/basic_last-child.ast
164
+ - spec/fixtures/basic_last-child.output
165
+ - spec/fixtures/basic_last-child.selector
166
+ - spec/fixtures/basic_nth-child-2.ast
167
+ - spec/fixtures/basic_nth-child-2.output
168
+ - spec/fixtures/basic_nth-child-2.selector
169
+ - spec/fixtures/basic_nth-child.ast
170
+ - spec/fixtures/basic_nth-child.output
171
+ - spec/fixtures/basic_nth-child.selector
172
+ - spec/fixtures/basic_nth-last-child.ast
173
+ - spec/fixtures/basic_nth-last-child.output
174
+ - spec/fixtures/basic_nth-last-child.selector
175
+ - spec/fixtures/basic_root_pseudo.ast
176
+ - spec/fixtures/basic_root_pseudo.output
177
+ - spec/fixtures/basic_root_pseudo.selector
178
+ - spec/fixtures/basic_type.ast
179
+ - spec/fixtures/basic_type.output
180
+ - spec/fixtures/basic_type.selector
181
+ - spec/fixtures/basic_type2.ast
182
+ - spec/fixtures/basic_type2.output
183
+ - spec/fixtures/basic_type2.selector
184
+ - spec/fixtures/basic_type3.ast
185
+ - spec/fixtures/basic_type3.output
186
+ - spec/fixtures/basic_type3.selector
187
+ - spec/fixtures/basic_universal.ast
188
+ - spec/fixtures/basic_universal.output
189
+ - spec/fixtures/basic_universal.selector
190
+ - spec/spec_helper.rb