facebook-cli 1.4.15 → 1.5.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/fbcli.rb +32 -2
- data/lib/fbcli/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e47520322957827ab66194802d5fe1fd313ab10f
|
4
|
+
data.tar.gz: c63975e1c13c770185dbabaa0ccb2378279f4eab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b623e4152455148443b38be3559741abb35a1bea9dd96af0dc91f3b7ce3a96642bc64c25a53b6b3b39fd9c4dc1fa6121477f3c53488be84c3a4dae515340ed8
|
7
|
+
data.tar.gz: 02c77fff8f919e8ab1b00acdb0c2fefeb5f6f17f3057691aa2030670b3d549950ffd59af2b09aa6483f6ed6f3e5fd34d189e5871f5b08a98657bc5898f4befb3
|
data/lib/fbcli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'gli'
|
2
2
|
require 'yaml'
|
3
3
|
require 'json'
|
4
|
+
require 'jsonpath'
|
4
5
|
require 'fbcli/auth'
|
5
6
|
require 'fbcli/version'
|
6
7
|
require 'fbcli/facebook'
|
@@ -164,13 +165,42 @@ long_desc %(
|
|
164
165
|
|
165
166
|
#{APP_NAME} api "165795193558366?metadata=1"
|
166
167
|
|
167
|
-
|
168
|
+
Moreover, you can extract a value from the response using --get. For example:
|
169
|
+
|
170
|
+
#{APP_NAME} api --get name 165795193558366
|
171
|
+
|
172
|
+
Use JsonPath language to retrieve nested values. For example:
|
173
|
+
|
174
|
+
#{APP_NAME} api --get "metadata.fields..name" "165795193558366?metadata=1"
|
175
|
+
|
176
|
+
Some valid requests may not be honored or return incomplete results due to
|
177
|
+
insufficient permissions, which were established during the authentication
|
178
|
+
process.
|
168
179
|
)
|
169
180
|
command :api do |c|
|
181
|
+
c.flag [:get], :desc => "Extract a particular value from the JSON response"
|
170
182
|
c.switch [:raw], :desc => 'Output unformatted JSON', :negatable => false
|
171
183
|
c.action do |global_options, options, args|
|
172
184
|
res = FBCLI::raw_request args[0]
|
173
|
-
|
185
|
+
|
186
|
+
# Extract value(s) using JsonPath
|
187
|
+
if options['get']
|
188
|
+
path = JsonPath.new("$.#{options['get']}")
|
189
|
+
res = path.on(res)
|
190
|
+
|
191
|
+
# If the result is a JSON structure, unwrap it
|
192
|
+
if res[0].class == Hash
|
193
|
+
res = res[0]
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
# Nicely format JSON result if not --raw
|
198
|
+
unless options['raw']
|
199
|
+
if res.class == Hash
|
200
|
+
res = JSON.pretty_generate res
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
174
204
|
puts res
|
175
205
|
end
|
176
206
|
end
|
data/lib/fbcli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: facebook-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ildar Sagdejev
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: jsonpath
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.5'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: gli
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|