koala 0.4 → 3.7.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/.github/workflows/test.yml +32 -0
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/.yardopts +3 -0
- data/Gemfile +25 -0
- data/ISSUE_TEMPLATE +25 -0
- data/LICENSE +22 -0
- data/Manifest +32 -5
- data/PULL_REQUEST_TEMPLATE +11 -0
- data/Rakefile +12 -12
- data/changelog.md +781 -0
- data/code_of_conduct.md +74 -0
- data/koala.gemspec +28 -24
- data/lib/koala/api/batch_operation.rb +86 -0
- data/lib/koala/api/graph_api_methods.rb +504 -0
- data/lib/koala/api/graph_batch_api.rb +167 -0
- data/lib/koala/api/graph_collection.rb +129 -0
- data/lib/koala/api/graph_error_checker.rb +72 -0
- data/lib/koala/api.rb +159 -0
- data/lib/koala/configuration.rb +56 -0
- data/lib/koala/errors.rb +126 -0
- data/lib/koala/http_service/request.rb +133 -0
- data/lib/koala/http_service/response.rb +20 -0
- data/lib/koala/http_service/uploadable_io.rb +183 -0
- data/lib/koala/http_service.rb +108 -0
- data/lib/koala/oauth.rb +342 -0
- data/lib/koala/realtime_updates.rb +151 -0
- data/lib/koala/test_users.rb +189 -0
- data/lib/koala/utils.rb +41 -0
- data/lib/koala/version.rb +3 -0
- data/lib/koala.rb +51 -291
- data/readme.md +269 -21
- data/spec/cases/api_spec.rb +362 -0
- data/spec/cases/configuration_spec.rb +11 -0
- data/spec/cases/error_spec.rb +143 -0
- data/spec/cases/graph_api_batch_spec.rb +788 -0
- data/spec/cases/graph_api_spec.rb +76 -0
- data/spec/cases/graph_collection_spec.rb +192 -0
- data/spec/cases/graph_error_checker_spec.rb +147 -0
- data/spec/cases/http_service/request_spec.rb +250 -0
- data/spec/cases/http_service/response_spec.rb +24 -0
- data/spec/cases/http_service_spec.rb +280 -0
- data/spec/cases/koala_spec.rb +57 -0
- data/spec/cases/koala_test_spec.rb +5 -0
- data/spec/cases/oauth_spec.rb +647 -0
- data/spec/cases/realtime_updates_spec.rb +327 -0
- data/spec/cases/test_users_spec.rb +383 -0
- data/spec/cases/uploadable_io_spec.rb +266 -0
- data/spec/cases/utils_spec.rb +55 -0
- data/spec/fixtures/beach.jpg +0 -0
- data/spec/fixtures/cat.m4v +0 -0
- data/spec/fixtures/facebook_data.yml +63 -0
- data/spec/fixtures/mock_facebook_responses.yml +483 -0
- data/spec/fixtures/vcr_cassettes/app_test_accounts.yml +97 -0
- data/spec/fixtures/vcr_cassettes/friend_list_next_page.yml +121 -0
- data/spec/integration/graph_collection_spec.rb +24 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/custom_matchers.rb +28 -0
- data/spec/support/graph_api_shared_examples.rb +534 -0
- data/spec/support/koala_test.rb +251 -0
- data/spec/support/mock_http_service.rb +140 -0
- data/spec/support/uploadable_io_shared_examples.rb +70 -0
- metadata +206 -62
- data/CHANGELOG +0 -24
- data/init.rb +0 -2
- data/lib/http_services.rb +0 -60
- data/test/facebook_data.yml +0 -5
- data/test/koala/facebook_no_access_token_tests.rb +0 -119
- data/test/koala/facebook_with_access_token_tests.rb +0 -106
- data/test/koala_tests.rb +0 -30
data/code_of_conduct.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/koala.gemspec
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
|
3
|
+
require 'koala/version'
|
|
2
4
|
|
|
3
|
-
Gem::Specification.new do |
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.name = "koala"
|
|
7
|
+
gem.summary = "A lightweight, flexible library for Facebook with support for the Graph API, the REST API, realtime updates, and OAuth authentication."
|
|
8
|
+
gem.description = "Koala is a lightweight, flexible Ruby SDK for Facebook. It allows read/write access to the social graph via the Graph and REST APIs, as well as support for realtime updates and OAuth and Facebook Connect authentication. Koala is fully tested and supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services."
|
|
9
|
+
gem.licenses = ['MIT']
|
|
10
|
+
gem.homepage = "http://github.com/arsduo/koala"
|
|
11
|
+
gem.version = Koala::VERSION
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
s.date = %q{2010-05-01}
|
|
10
|
-
s.description = %q{Koala is a lightweight, flexible Ruby SDK for Facebook's new Graph API. It allows read/write access to the Facebook Graph and provides OAuth URLs and cookie validation for Facebook Connect sites. Koala supports Net::HTTP and Typhoeus connections out of the box and can accept custom modules for other services.}
|
|
11
|
-
s.email = %q{alex@alexkoppel.com}
|
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "lib/http_services.rb", "lib/koala.rb"]
|
|
13
|
-
s.files = ["CHANGELOG", "Manifest", "Rakefile", "init.rb", "koala.gemspec", "lib/http_services.rb", "lib/koala.rb", "readme.md", "test/facebook_data.yml", "test/koala/facebook_no_access_token_tests.rb", "test/koala/facebook_with_access_token_tests.rb", "test/koala_tests.rb"]
|
|
14
|
-
s.homepage = %q{http://github.com/arsduo/ruby-sdk}
|
|
15
|
-
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Koala", "--main", "readme.md"]
|
|
16
|
-
s.require_paths = ["lib"]
|
|
17
|
-
s.rubyforge_project = %q{koala}
|
|
18
|
-
s.rubygems_version = %q{1.3.6}
|
|
19
|
-
s.summary = %q{A lightweight, flexible library for Facebook's new Graph API}
|
|
13
|
+
gem.authors = ["Alex Koppel"]
|
|
14
|
+
gem.email = "alex@alexkoppel.com"
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
17
|
+
gem.files = `git ls-files`.split("\n")
|
|
18
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
19
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
gem.extra_rdoc_files = ["readme.md", "changelog.md"]
|
|
22
|
+
gem.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Koala"]
|
|
23
|
+
|
|
24
|
+
gem.required_ruby_version = '>= 2.1'
|
|
25
|
+
|
|
26
|
+
gem.add_runtime_dependency("faraday")
|
|
27
|
+
gem.add_runtime_dependency("faraday-multipart")
|
|
28
|
+
gem.add_runtime_dependency("addressable")
|
|
29
|
+
gem.add_runtime_dependency("json", ">= 1.8")
|
|
30
|
+
gem.add_runtime_dependency("rexml")
|
|
31
|
+
gem.add_runtime_dependency("base64")
|
|
32
|
+
gem.add_runtime_dependency("ostruct")
|
|
33
|
+
gem.add_runtime_dependency("cgi")
|
|
30
34
|
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'koala/api'
|
|
2
|
+
require 'koala/api/graph_batch_api'
|
|
3
|
+
|
|
4
|
+
module Koala
|
|
5
|
+
module Facebook
|
|
6
|
+
class GraphBatchAPI < API
|
|
7
|
+
# @private
|
|
8
|
+
class BatchOperation
|
|
9
|
+
attr_reader :access_token, :http_options, :post_processing, :files, :batch_api, :identifier
|
|
10
|
+
|
|
11
|
+
@identifier = 0
|
|
12
|
+
|
|
13
|
+
def self.next_identifier
|
|
14
|
+
@identifier += 1
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def initialize(options = {})
|
|
18
|
+
@identifier = self.class.next_identifier
|
|
19
|
+
@args = (options[:args] || {}).dup # because we modify it below
|
|
20
|
+
@access_token = options[:access_token]
|
|
21
|
+
@http_options = (options[:http_options] || {}).dup # dup because we modify it below
|
|
22
|
+
@batch_args = @http_options.delete(:batch_args) || {}
|
|
23
|
+
@url = options[:url]
|
|
24
|
+
@method = options[:method].to_sym
|
|
25
|
+
@post_processing = options[:post_processing]
|
|
26
|
+
|
|
27
|
+
process_binary_args
|
|
28
|
+
|
|
29
|
+
raise AuthenticationError.new(nil, nil, "Batch operations require an access token, none provided.") unless @access_token
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def to_batch_params(main_access_token, app_secret)
|
|
33
|
+
# set up the arguments
|
|
34
|
+
if @access_token != main_access_token
|
|
35
|
+
@args[:access_token] = @access_token
|
|
36
|
+
if app_secret
|
|
37
|
+
@args[:appsecret_proof] = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), app_secret, @access_token)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
args_string = Koala.http_service.encode_params(@args)
|
|
41
|
+
|
|
42
|
+
response = {
|
|
43
|
+
:method => @method.to_s,
|
|
44
|
+
:relative_url => @url,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# handle batch-level arguments, such as name, depends_on, and attached_files
|
|
48
|
+
@batch_args[:attached_files] = @files.keys.join(",") if @files
|
|
49
|
+
response.merge!(@batch_args) if @batch_args
|
|
50
|
+
|
|
51
|
+
# for get and delete, we append args to the URL string
|
|
52
|
+
# otherwise, they go in the body
|
|
53
|
+
if args_string.length > 0
|
|
54
|
+
if args_in_url?
|
|
55
|
+
response[:relative_url] += (@url =~ /\?/ ? "&" : "?") + args_string if args_string.length > 0
|
|
56
|
+
else
|
|
57
|
+
response[:body] = args_string if args_string.length > 0
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
response
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
protected
|
|
65
|
+
|
|
66
|
+
def process_binary_args
|
|
67
|
+
# collect binary files
|
|
68
|
+
@args.each_pair do |key, value|
|
|
69
|
+
if HTTPService::UploadableIO.binary_content?(value)
|
|
70
|
+
@files ||= {}
|
|
71
|
+
# we use a class-level counter to ensure unique file identifiers across multiple batch operations
|
|
72
|
+
# (this is thread safe, since we just care about uniqueness)
|
|
73
|
+
# so remove the file from the original hash and add it to the file store
|
|
74
|
+
id = "op#{identifier}_file#{@files.keys.length}"
|
|
75
|
+
@files[id] = @args.delete(key).is_a?(HTTPService::UploadableIO) ? value : HTTPService::UploadableIO.new(value)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def args_in_url?
|
|
81
|
+
@method == :get || @method == :delete
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|