fb-core 0.0.0 → 1.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -1
- data/LICENSE.txt +1 -1
- data/README.md +55 -1
- data/Rakefile +6 -1
- data/bin/console +2 -2
- data/bin/setup +2 -1
- data/fb-core.gemspec +21 -14
- data/lib/fb/core.rb +8 -0
- data/lib/fb/core/version.rb +5 -2
- data/lib/fb/page.rb +29 -0
- data/lib/fb/user.rb +39 -0
- metadata +75 -13
- data/lib/fb-core.rb +0 -3
- data/yt-auth-0.0.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a13a49371c7ccfc542e43e7d7fce1ea8117e572c
|
4
|
+
data.tar.gz: cd5a65c87114f4619267c7d623460088a630aa6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fea2337106ce89df4378c733dd712e0a5e6f72bf1e91a02170bd5c9d8e63eedfb81102945a13845f507a9a3c31ebefd82eb179aca58de1a8d3c5bfbdc2490642
|
7
|
+
data.tar.gz: e947bc2aca68b388e937ccfee36c986dd715b1a438054d996561ee16f89c41aff21d2ce6d40de808732d59be76c72df5faad034de1f5c14fa4e69dd78fa5ca8d
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
For more information about changelogs, check
|
6
|
+
[Keep a Changelog](http://keepachangelog.com) and
|
7
|
+
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
|
+
|
9
|
+
## 1.0.0 - 2017/07/24
|
10
|
+
|
11
|
+
* [FEATURE] Added `Fb::User`
|
12
|
+
* [FEATURE] Added `Fb::Page`
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,57 @@
|
|
1
1
|
# Fb::Core
|
2
2
|
|
3
|
-
|
3
|
+
Fb::Core provides methods to interact with Facebook users and pages through the Facebook Graph API.
|
4
|
+
|
5
|
+
[![Build Status](http://img.shields.io/travis/Fullscreen/fb-core/master.svg)](https://travis-ci.org/Fullscreen/fb-core)
|
6
|
+
[![Coverage Status](http://img.shields.io/coveralls/Fullscreen/fb-core/master.svg)](https://coveralls.io/r/Fullscreen/fb-core)
|
7
|
+
[![Dependency Status](http://img.shields.io/gemnasium/Fullscreen/fb-core.svg)](https://gemnasium.com/Fullscreen/fb-core)
|
8
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/Fullscreen/fb-core.svg)](https://codeclimate.com/github/Fullscreen/fb-core)
|
9
|
+
[![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://www.rubydoc.info/gems/fb-core/frames)
|
10
|
+
[![Gem Version](http://img.shields.io/gem/v/fb-core.svg)](http://rubygems.org/gems/fb-core)
|
11
|
+
|
12
|
+
The **source code** is available on [GitHub](https://github.com/Fullscreen/fb-core) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/fb-core/frames).
|
13
|
+
|
14
|
+
### Installing and Configuring
|
15
|
+
|
16
|
+
Add `fb-core` to your Gemfile and run `bundle install`.
|
17
|
+
|
18
|
+
Most methods of this library require to have an access token of a Facebook user.
|
19
|
+
If you need to obtain one programmatically, use the [fb-auth](https://github.com/Fullscreen/fb-auth) library.
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Fb::User#email
|
24
|
+
--------------
|
25
|
+
|
26
|
+
Given an user access token with the `email` scope, you can get the user's email by calling:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
user = Fb::User.new access_token: '--valid-access-token--'
|
30
|
+
user.email # => 'john.smith@example.com'
|
31
|
+
```
|
32
|
+
|
33
|
+
Fb::User#pages
|
34
|
+
--------------
|
35
|
+
|
36
|
+
Given an user access token with the `manage_pages` scope, you can get the list of Facebook pages managed by the user by calling:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
user = Fb::User.new access_token: '--valid-access-token--'
|
40
|
+
user.pages
|
41
|
+
# => [#<Fb::Page: id="1234", name="sample1">, #<Fb::Page: id="5678", name="sample2">]
|
42
|
+
```
|
43
|
+
|
44
|
+
## Development
|
45
|
+
|
46
|
+
To run tests, obtain a long-term access token for a Facebook user who manages
|
47
|
+
at least one page and includes `email` and `manage_pages` scopes. Set the token as:
|
48
|
+
|
49
|
+
export FB_TEST_ACCESS_TOKEN="YourToken"
|
50
|
+
|
51
|
+
Then, run `rake spec` to run the tests.
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
56
|
+
|
57
|
+
Thanks :tada:
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
-
require "fb
|
4
|
+
require "fb/core"
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -11,4 +11,4 @@ require "fb-core"
|
|
11
11
|
# Pry.start
|
12
12
|
|
13
13
|
require "irb"
|
14
|
-
IRB.start
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
data/fb-core.gemspec
CHANGED
@@ -1,25 +1,32 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require '
|
4
|
+
require 'fb/core/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'fb-core'
|
8
8
|
spec.version = Fb::Core::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Claudio Baccigalupo']
|
10
|
+
spec.email = ['claudio@fullscreen.net']
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
14
|
-
|
15
|
-
spec.
|
12
|
+
spec.summary = %q{Ruby client to interact with Facebook Graph API.}
|
13
|
+
spec.description = %q{Fb::Core provides methods to interact with User and
|
14
|
+
Pages through the Facebook Graph API.}
|
15
|
+
spec.homepage = 'https://github.com/Fullscreen/fb-core'
|
16
|
+
spec.license = 'MIT'
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
22
24
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
|
25
|
+
spec.add_development_dependency 'fb-support', '~> 1.0.0.alpha1'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'yard', '~> 0.9.9'
|
31
|
+
spec.add_development_dependency 'coveralls'
|
25
32
|
end
|
data/lib/fb/core.rb
ADDED
data/lib/fb/core/version.rb
CHANGED
data/lib/fb/page.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fb
|
2
|
+
# Provides methods to interact with Facebook pages through the Graph API.
|
3
|
+
# @see https://developers.facebook.com/docs/graph-api/reference/page/
|
4
|
+
class Page
|
5
|
+
# @option [String] the page’s unique ID.
|
6
|
+
attr_reader :id
|
7
|
+
|
8
|
+
# @option [String] the page’s name.
|
9
|
+
attr_reader :name
|
10
|
+
|
11
|
+
# @option [String] the page’s category.
|
12
|
+
attr_reader :category
|
13
|
+
|
14
|
+
# @param [Hash] options to initialize a Page object.
|
15
|
+
# @option [String] :id The page’s unique ID.
|
16
|
+
# @option [String] :name The page’s name.
|
17
|
+
# @option [String] :category The page’s category.
|
18
|
+
def initialize(options = {})
|
19
|
+
@id = options[:id]
|
20
|
+
@name = options[:name]
|
21
|
+
@category = options[:category]
|
22
|
+
end
|
23
|
+
|
24
|
+
# @return [String] the representation of the page.
|
25
|
+
def to_s
|
26
|
+
%Q(#<#{self.class.name} #{@id} "#{@name}">)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/fb/user.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fb
|
2
|
+
# Provides methods to interact with Facebook users through the Graph API.
|
3
|
+
# @see https://developers.facebook.com/docs/graph-api/reference/user/
|
4
|
+
class User
|
5
|
+
# @param [Hash] options to initialize a User object.
|
6
|
+
# @option [String] :access_token an access token for the user.
|
7
|
+
def initialize(options = {})
|
8
|
+
@access_token = options[:access_token]
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [String] the user’s email address.
|
12
|
+
def email
|
13
|
+
@email ||= begin
|
14
|
+
params = {fields: :email, access_token: @access_token}
|
15
|
+
request = HTTPRequest.new path: '/me', params: params
|
16
|
+
request.run.body['email']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# @return [Array<Fb::Page>] the pages managed by the user.
|
21
|
+
def pages
|
22
|
+
@pages ||= begin
|
23
|
+
params = {access_token: @access_token}
|
24
|
+
request = HTTPRequest.new path: '/me/accounts', params: params
|
25
|
+
request.run.body['data'].map do |page_data|
|
26
|
+
Page.new symbolize_keys(page_data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def symbolize_keys(hash)
|
34
|
+
{}.tap do |new_hash|
|
35
|
+
hash.each_key{|key| new_hash[key.to_sym] = hash[key]}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fb-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 1.0.0.alpha1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Claudio Baccigalupo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fb-support
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.alpha1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0.alpha1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - "~>"
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
33
|
+
version: '1.15'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
38
|
- - "~>"
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
40
|
+
version: '1.15'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,15 +52,62 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
41
|
-
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.9.9
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.9.9
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: |-
|
98
|
+
Fb::Core provides methods to interact with User and
|
99
|
+
Pages through the Facebook Graph API.
|
42
100
|
email:
|
43
|
-
-
|
101
|
+
- claudio@fullscreen.net
|
44
102
|
executables: []
|
45
103
|
extensions: []
|
46
104
|
extra_rdoc_files: []
|
47
105
|
files:
|
48
106
|
- ".gitignore"
|
107
|
+
- ".rspec"
|
49
108
|
- ".travis.yml"
|
109
|
+
- ".yardopts"
|
110
|
+
- CHANGELOG.md
|
50
111
|
- Gemfile
|
51
112
|
- LICENSE.txt
|
52
113
|
- README.md
|
@@ -54,10 +115,11 @@ files:
|
|
54
115
|
- bin/console
|
55
116
|
- bin/setup
|
56
117
|
- fb-core.gemspec
|
57
|
-
- lib/fb
|
118
|
+
- lib/fb/core.rb
|
58
119
|
- lib/fb/core/version.rb
|
59
|
-
-
|
60
|
-
|
120
|
+
- lib/fb/page.rb
|
121
|
+
- lib/fb/user.rb
|
122
|
+
homepage: https://github.com/Fullscreen/fb-core
|
61
123
|
licenses:
|
62
124
|
- MIT
|
63
125
|
metadata: {}
|
@@ -72,13 +134,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
134
|
version: '0'
|
73
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
136
|
requirements:
|
75
|
-
- - "
|
137
|
+
- - ">"
|
76
138
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
139
|
+
version: 1.3.1
|
78
140
|
requirements: []
|
79
141
|
rubyforge_project:
|
80
142
|
rubygems_version: 2.6.11
|
81
143
|
signing_key:
|
82
144
|
specification_version: 4
|
83
|
-
summary:
|
145
|
+
summary: Ruby client to interact with Facebook Graph API.
|
84
146
|
test_files: []
|
data/lib/fb-core.rb
DELETED
data/yt-auth-0.0.0.gem
DELETED
Binary file
|