rfql 0.1.alpha.3 → 0.1.alpha.4
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.
- data/CHANGELOG +2 -0
- data/README.rdoc +13 -5
- data/lib/rfql/request.rb +11 -20
- data/lib/rfql/response.rb +5 -10
- data/lib/rfql.rb +1 -2
- data/rfql.gemspec +3 -3
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +2 -1
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= RFQL - Ruby API for the {Facebook Query Language}[https://developers.facebook.com/docs/reference/fql/]
|
2
2
|
|
3
|
-
<b>Work In Progress - things can change (and probably they will
|
3
|
+
<b>Work In Progress - things can change (and probably they will)</b>
|
4
4
|
|
5
5
|
== Features
|
6
6
|
|
@@ -12,13 +12,21 @@
|
|
12
12
|
|
13
13
|
== Usage / Examples
|
14
14
|
|
15
|
+
require 'rfql'
|
16
|
+
|
17
|
+
# The query object
|
18
|
+
request = RFQL.request.select('aid, owner, name, object_id').from('album').where(aid: "20531316728_324257")
|
19
|
+
|
20
|
+
# Retrieving the JSON data response
|
21
|
+
request.fetch.response #=> {"data"=>[{"aid"=>"20531316728_324257", "owner"=>20531316728, "name"=>"Happy Lunar New Year 2011", "object_id"=>"10150146071791729"}]}
|
22
|
+
|
15
23
|
== TODO
|
16
24
|
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
25
|
+
* Add more examples
|
26
|
+
* Have I already implemented errors managing? Who knows!
|
27
|
+
* Refactoring
|
20
28
|
* Documentation
|
21
|
-
* ADD TESTS
|
29
|
+
* ADD TESTS!!!
|
22
30
|
|
23
31
|
== License
|
24
32
|
|
data/lib/rfql/request.rb
CHANGED
@@ -7,11 +7,12 @@ module RFQL
|
|
7
7
|
class Request
|
8
8
|
include RFQL::Request::QueryMethodsDelegations
|
9
9
|
|
10
|
+
FQLURL = "https://graph.facebook.com/fql"
|
11
|
+
|
10
12
|
attr_reader :response
|
11
13
|
|
12
14
|
def initialize(str = nil)
|
13
15
|
@query = RFQL::Query.new(str)
|
14
|
-
@format_param = :json
|
15
16
|
end
|
16
17
|
|
17
18
|
def query(query = nil)
|
@@ -30,42 +31,32 @@ module RFQL
|
|
30
31
|
self
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
-
|
35
|
-
raise ArgumentError, "illegal format" unless [:json, :xml].include?(format_param)
|
36
|
-
@format_param = format_param
|
37
|
-
self
|
38
|
-
end
|
39
|
-
|
40
|
-
def params(with_format_param = false)
|
41
|
-
params = {:query => to_sql, :access_token => access_token}
|
42
|
-
return params unless with_format_param
|
43
|
-
params.merge(:format => @format_param)
|
34
|
+
def params
|
35
|
+
{:q => to_sql, :access_token => access_token}
|
44
36
|
end
|
45
37
|
|
46
|
-
def to_url
|
47
|
-
|
38
|
+
def to_url
|
39
|
+
FQLURL + '?' + hash_to_params_string(params)
|
48
40
|
end
|
49
41
|
|
50
42
|
def hash_to_params_string(params)
|
51
43
|
params.to_a.select do |param|
|
52
44
|
param[0].present? and param[1].present?
|
53
45
|
end.map do |param|
|
54
|
-
|
55
|
-
k.gsub!('&', '%26'); k.gsub!('=', '%3D'); v.gsub!('&', '%26'); v.gsub!('=', '%3D')
|
56
|
-
"#{k}=#{v}"
|
46
|
+
"%s=%s" % [CGI.escape(param[0].to_s), CGI.escape(param[1].to_s)]
|
57
47
|
end.join('&')
|
58
48
|
end
|
59
49
|
|
60
|
-
def
|
50
|
+
def fetch(json_format = :parsed, options = {})
|
61
51
|
begin
|
62
|
-
|
52
|
+
fetch!(json_format, options)
|
63
53
|
rescue RFQL::Response::FQLError
|
64
54
|
nil
|
65
55
|
end
|
66
56
|
end
|
67
57
|
|
68
|
-
|
58
|
+
# Example: RFQL.request.query('SELECT aid, owner, name, object_id FROM album WHERE aid="20531316728_324257"').fetch
|
59
|
+
def fetch!(json_format = :parsed, options = {})
|
69
60
|
raise ArgumentError, "illegal format" unless [:raw, :parsed].include?(json_format)
|
70
61
|
unless options.is_a?(Hash) and (options.keys - [:open_uri_options, :json_parse_options, :force_execution]).blank?
|
71
62
|
raise ArgumentError, "illegal options"
|
data/lib/rfql/response.rb
CHANGED
@@ -8,20 +8,15 @@ module RFQL
|
|
8
8
|
class << self
|
9
9
|
def new(request, options = {})
|
10
10
|
options[:format] ||= :json_parsed
|
11
|
-
raise ArgumentError, 'illegal format' unless [:
|
11
|
+
raise ArgumentError, 'illegal format' unless [:json_raw, :json_parsed].include?(options[:format])
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
RFQL::Response::JSON.new(request, options)
|
17
|
-
when :xml
|
18
|
-
raise NotImplementedError, 'xml fetching is still a WIP :-P'
|
19
|
-
end
|
13
|
+
options[:format] = options[:format].to_s[/^json_(.*)/, 1].to_sym
|
14
|
+
|
15
|
+
RFQL::Response::JSON.new(request, options)
|
20
16
|
end
|
17
|
+
|
21
18
|
def read(request, options = {})
|
22
19
|
request_url = request.respond_to?(:to_url) ? request.to_url : request.to_s
|
23
|
-
raise ArgumentError, 'illegal format' unless [:xml, :json].include?(options[:format])
|
24
|
-
request_url << "&format=#{options[:format]}"
|
25
20
|
URI.parse(request_url).read(options[:open_uri_options] || {})
|
26
21
|
end
|
27
22
|
end
|
data/lib/rfql.rb
CHANGED
data/rfql.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rfql"
|
5
|
-
s.version = "0.1.alpha.
|
5
|
+
s.version = "0.1.alpha.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["De Santis Maurizio"]
|
9
9
|
s.cert_chain = ["/home/mau/.gem_keys/gem-public_cert.pem"]
|
10
|
-
s.date = "
|
10
|
+
s.date = "2012-01-04"
|
11
11
|
s.description = "RFQL - Ruby interface for Facebook Query Language"
|
12
12
|
s.email = "desantis.maurizio@gmail.com"
|
13
13
|
s.extra_rdoc_files = ["CHANGELOG", "LICENSE", "README.rdoc", "lib/rfql.rb", "lib/rfql/core_ext/object/blank.rb", "lib/rfql/query.rb", "lib/rfql/query/methods.rb", "lib/rfql/query/quoting.rb", "lib/rfql/request.rb", "lib/rfql/request/delegations.rb", "lib/rfql/response.rb", "lib/rfql/response/fql_error.rb", "lib/rfql/response/json.rb", "lib/rfql/response/json/parsed.rb", "lib/rfql/response/json/parsed/error.rb", "lib/rfql/response/json/parsed/null.rb", "lib/rfql/response/json/parsed/records.rb", "lib/rfql/response/json/raw.rb"]
|
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rfql", "--main", "README.rdoc"]
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
s.rubyforge_project = "rfql"
|
19
|
-
s.rubygems_version = "1.8.
|
19
|
+
s.rubygems_version = "1.8.12"
|
20
20
|
s.signing_key = "/home/mau/.gem_keys/gem-private_key.pem"
|
21
21
|
s.summary = "It lets you use ORM-style code for fetching data from Facebook through the Facebook Query Language"
|
22
22
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.alpha.
|
4
|
+
version: 0.1.alpha.4
|
5
5
|
prerelease: 4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,7 +50,7 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date:
|
53
|
+
date: 2012-01-04 00:00:00.000000000 Z
|
54
54
|
dependencies: []
|
55
55
|
description: RFQL - Ruby interface for Facebook Query Language
|
56
56
|
email: desantis.maurizio@gmail.com
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '1.2'
|
124
124
|
requirements: []
|
125
125
|
rubyforge_project: rfql
|
126
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.12
|
127
127
|
signing_key:
|
128
128
|
specification_version: 3
|
129
129
|
summary: It lets you use ORM-style code for fetching data from Facebook through the
|
metadata.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
3��Ju��9�#����X9u���1l�64%ɈϏK�)�
|
2
|
+
GR�H�3��pק�?uv+�\��Y��a7����1�{�@�[-Ѷv)x��y9�4tV���!N�B��ٹ_�#w��Zf�]��є�F5G��^t�ͬ�-]�1����}U�{tT%�oLO0w�� �1o_&�j3�fv�3���=��gs���I���ј���D��3�b��¼!��I�l���T�)`5O�TiO�:=��T���_�
|