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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e7cf77685db56762493294c58103f63598c109f
4
- data.tar.gz: dda64de17fb9f2754cbb4c3efd30b7d72e4de1ef
3
+ metadata.gz: a13a49371c7ccfc542e43e7d7fce1ea8117e572c
4
+ data.tar.gz: cd5a65c87114f4619267c7d623460088a630aa6f
5
5
  SHA512:
6
- metadata.gz: acbbd981745168be505bea860172a75bf2d4715e0a234bce625f8f5d7b3e58e8f61937fe7fe961f5768a7f28d5465e68686bb8824e187cda7f10987650ccb13b
7
- data.tar.gz: 8896365d2820399d8dd91288f500aec155e1dc3e12aaa1d657025aa69c42101ca26ea316019b9e9cc68534e596f657d2168dffd38682fdab53d1258b0d61c2ff
6
+ metadata.gz: fea2337106ce89df4378c733dd712e0a5e6f72bf1e91a02170bd5c9d8e63eedfb81102945a13845f507a9a3c31ebefd82eb179aca58de1a8d3c5bfbdc2490642
7
+ data.tar.gz: e947bc2aca68b388e937ccfee36c986dd715b1a438054d996561ee16f89c41aff21d2ce6d40de808732d59be76c72df5faad034de1f5c14fa4e69dd78fa5ca8d
data/.gitignore CHANGED
@@ -7,3 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .DS_Store
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml CHANGED
@@ -1,3 +1,8 @@
1
+ sudo: false
1
2
  language: ruby
2
3
  rvm:
3
- - 2.2.2
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
6
+ script:
7
+ - bundle exec rspec
8
+ - bundle exec yard stats | grep "100.00% documented"
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
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
+ gem 'pry-nav'
2
3
 
3
4
  # Specify your gem's dependencies in fb-core.gemspec
4
5
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 claudiob
3
+ Copyright (c) 2017 Fullscreen, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,3 +1,57 @@
1
1
  # Fb::Core
2
2
 
3
- :star: :star: :star:
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
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new :spec
5
+
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "fb-core"
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
@@ -1,6 +1,7 @@
1
- #!/bin/bash
1
+ #!/usr/bin/env bash
2
2
  set -euo pipefail
3
3
  IFS=$'\n\t'
4
+ set -vx
4
5
 
5
6
  bundle install
6
7
 
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 'Fb/Core/version'
4
+ require 'fb/core/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "fb-core"
7
+ spec.name = 'fb-core'
8
8
  spec.version = Fb::Core::VERSION
9
- spec.authors = ["claudiob"]
10
- spec.email = ["claudiob@gmail.com"]
9
+ spec.authors = ['Claudio Baccigalupo']
10
+ spec.email = ['claudio@fullscreen.net']
11
11
 
12
- spec.summary = %q{Write a short summary, because Rubygems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
14
- spec.homepage = "https://github.com/fullscreen/fb-core"
15
- spec.license = "MIT"
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
- # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.bindir = "exe"
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 = ["lib"]
23
+ spec.require_paths = ['lib']
22
24
 
23
- spec.add_development_dependency "bundler", "~> 1.9"
24
- spec.add_development_dependency "rake", "~> 10.0"
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
@@ -0,0 +1,8 @@
1
+ require 'fb/support'
2
+ require 'fb/page'
3
+ require 'fb/user'
4
+
5
+ # An object-oriented Ruby client for the Facebook Graph API.
6
+ # @see http://www.rubydoc.info/gems/fb-core/
7
+ module Fb
8
+ end
@@ -1,5 +1,8 @@
1
1
  module Fb
2
- module Core
3
- VERSION = "0.0.0"
2
+ # Provides basic functionality to connect to the Facebook Graph API.
3
+ class Core
4
+ # @return [String] the SemVer-compatible gem version.
5
+ # @see http://semver.org
6
+ VERSION = '1.0.0.alpha1'
4
7
  end
5
8
  end
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.0
4
+ version: 1.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
- - claudiob
7
+ - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
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.9'
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.9'
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
- description: Write a longer description or delete this line.
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
- - claudiob@gmail.com
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-core.rb
118
+ - lib/fb/core.rb
58
119
  - lib/fb/core/version.rb
59
- - yt-auth-0.0.0.gem
60
- homepage: https://github.com/fullscreen/fb-core
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: '0'
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: Write a short summary, because Rubygems requires one.
145
+ summary: Ruby client to interact with Facebook Graph API.
84
146
  test_files: []
data/lib/fb-core.rb DELETED
@@ -1,3 +0,0 @@
1
- module Fb::Core
2
- # Your code goes here...
3
- end
data/yt-auth-0.0.0.gem DELETED
Binary file