burtpath 1.1.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 +7 -0
- data/LICENSE.txt +174 -0
- data/lib/burtpath.rb +3 -0
- data/lib/jmespath/caching_parser.rb +30 -0
- data/lib/jmespath/errors.rb +17 -0
- data/lib/jmespath/lexer.rb +118 -0
- data/lib/jmespath/nodes/comparator.rb +77 -0
- data/lib/jmespath/nodes/condition.rb +136 -0
- data/lib/jmespath/nodes/current.rb +10 -0
- data/lib/jmespath/nodes/expression.rb +25 -0
- data/lib/jmespath/nodes/field.rb +63 -0
- data/lib/jmespath/nodes/flatten.rb +29 -0
- data/lib/jmespath/nodes/function.rb +464 -0
- data/lib/jmespath/nodes/index.rb +18 -0
- data/lib/jmespath/nodes/literal.rb +16 -0
- data/lib/jmespath/nodes/multi_select_hash.rb +37 -0
- data/lib/jmespath/nodes/multi_select_list.rb +22 -0
- data/lib/jmespath/nodes/or.rb +24 -0
- data/lib/jmespath/nodes/pipe.rb +6 -0
- data/lib/jmespath/nodes/projection.rb +86 -0
- data/lib/jmespath/nodes/slice.rb +93 -0
- data/lib/jmespath/nodes/subexpression.rb +63 -0
- data/lib/jmespath/nodes.rb +40 -0
- data/lib/jmespath/optimizing_parser.rb +12 -0
- data/lib/jmespath/parser.rb +288 -0
- data/lib/jmespath/runtime.rb +82 -0
- data/lib/jmespath/token.rb +41 -0
- data/lib/jmespath/token_stream.rb +60 -0
- data/lib/jmespath/version.rb +3 -0
- data/lib/jmespath.rb +42 -0
- metadata +89 -0
data/lib/jmespath.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
module JMESPath
|
5
|
+
|
6
|
+
autoload :CachingParser, 'jmespath/caching_parser'
|
7
|
+
autoload :Errors, 'jmespath/errors'
|
8
|
+
autoload :ExprNode, 'jmespath/expr_node'
|
9
|
+
autoload :Lexer, 'jmespath/lexer'
|
10
|
+
autoload :Nodes, 'jmespath/nodes'
|
11
|
+
autoload :OptimizingParser, 'jmespath/optimizing_parser'
|
12
|
+
autoload :Parser, 'jmespath/parser'
|
13
|
+
autoload :Runtime, 'jmespath/runtime'
|
14
|
+
autoload :Token, 'jmespath/token'
|
15
|
+
autoload :TokenStream, 'jmespath/token_stream'
|
16
|
+
autoload :VERSION, 'jmespath/version'
|
17
|
+
|
18
|
+
class << self
|
19
|
+
|
20
|
+
|
21
|
+
# @param [String] expression A valid
|
22
|
+
# [JMESPath](https://github.com/boto/jmespath) expression.
|
23
|
+
# @param [Hash] data
|
24
|
+
# @return [Mixed,nil] Returns the matched values. Returns `nil` if the
|
25
|
+
# expression does not resolve inside `data`.
|
26
|
+
def search(expression, data)
|
27
|
+
data = case data
|
28
|
+
when Hash, Struct then data # check for most common case first
|
29
|
+
when Pathname then load_json(data)
|
30
|
+
when IO, StringIO then JSON.load(data.read)
|
31
|
+
else data
|
32
|
+
end
|
33
|
+
Runtime.new.search(expression, data)
|
34
|
+
end
|
35
|
+
|
36
|
+
# @api private
|
37
|
+
def load_json(path)
|
38
|
+
JSON.load(File.open(path, 'r', encoding: 'UTF-8') { |f| f.read })
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: burtpath
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trevor Rowe
|
8
|
+
- Burt Platform Team
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-09-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.8'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.8'
|
28
|
+
description: Implements JMESPath for Ruby
|
29
|
+
email:
|
30
|
+
- trevorrowe@gmail.com
|
31
|
+
executables: []
|
32
|
+
extensions: []
|
33
|
+
extra_rdoc_files: []
|
34
|
+
files:
|
35
|
+
- LICENSE.txt
|
36
|
+
- lib/burtpath.rb
|
37
|
+
- lib/jmespath.rb
|
38
|
+
- lib/jmespath/caching_parser.rb
|
39
|
+
- lib/jmespath/errors.rb
|
40
|
+
- lib/jmespath/lexer.rb
|
41
|
+
- lib/jmespath/nodes.rb
|
42
|
+
- lib/jmespath/nodes/comparator.rb
|
43
|
+
- lib/jmespath/nodes/condition.rb
|
44
|
+
- lib/jmespath/nodes/current.rb
|
45
|
+
- lib/jmespath/nodes/expression.rb
|
46
|
+
- lib/jmespath/nodes/field.rb
|
47
|
+
- lib/jmespath/nodes/flatten.rb
|
48
|
+
- lib/jmespath/nodes/function.rb
|
49
|
+
- lib/jmespath/nodes/index.rb
|
50
|
+
- lib/jmespath/nodes/literal.rb
|
51
|
+
- lib/jmespath/nodes/multi_select_hash.rb
|
52
|
+
- lib/jmespath/nodes/multi_select_list.rb
|
53
|
+
- lib/jmespath/nodes/or.rb
|
54
|
+
- lib/jmespath/nodes/pipe.rb
|
55
|
+
- lib/jmespath/nodes/projection.rb
|
56
|
+
- lib/jmespath/nodes/slice.rb
|
57
|
+
- lib/jmespath/nodes/subexpression.rb
|
58
|
+
- lib/jmespath/optimizing_parser.rb
|
59
|
+
- lib/jmespath/parser.rb
|
60
|
+
- lib/jmespath/runtime.rb
|
61
|
+
- lib/jmespath/token.rb
|
62
|
+
- lib/jmespath/token_stream.rb
|
63
|
+
- lib/jmespath/version.rb
|
64
|
+
homepage: http://github.com/burtcorp/burtpath
|
65
|
+
licenses:
|
66
|
+
- Apache 2.0
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.4.5
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: JMESPath - Optimized Ruby Edition
|
88
|
+
test_files: []
|
89
|
+
has_rdoc:
|