fb_graph_api 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 815b37cfc9412e4613fe18a5e9c45551426dea5e
4
+ data.tar.gz: aaa895dea9bbd7f0b2cdb76389731c13b9a6f58a
5
+ SHA512:
6
+ metadata.gz: 592dac23666fce852b7b7faa7734554889d9599c72f7ab9ade7d84ab517162782d5624fa3279564a1666ee983fb4a945c6c37ea54fb4a2a71da62b4911e03900
7
+ data.tar.gz: 4e4b57237025ebbd0cd52527e13097e4b997568a87819ef9a55c0157c800d1c5d2e84b4f398743871459dd7e23b60856de7f213ab003f795c540a5894d6618f8
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fb_graph_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # FbGraphApi !! Kudos !!
2
+
3
+ Ruby wrapper for [Facebook Graph APIs](https://developers.facebook.com/docs/graph-api).
4
+
5
+ You don't need to be a registered user of these APIs to use this gem.
6
+
7
+ __Features__
8
+
9
+ * Profile Details
10
+ * Profile Picture
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'fb_graph_api'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install fb_graph_api
27
+
28
+ ## Usage
29
+
30
+ ### Configuration Options
31
+
32
+ You can configure credentials via `FbGraphApi::Profile.new`:
33
+
34
+ ```ruby
35
+
36
+ Profile = FbGraphApi::Profile.new(facebook_user_access_token)
37
+
38
+ ```
39
+
40
+ User profile details:
41
+
42
+
43
+ ```ruby
44
+
45
+ Profile.info
46
+
47
+ ```
48
+
49
+ User profile details:
50
+
51
+ ```ruby
52
+
53
+ Profile.picture
54
+
55
+ or
56
+
57
+ Profile.picture('large')
58
+
59
+ ```
60
+
61
+ ## Documentation
62
+
63
+ Documentation is available [here]()
64
+
65
+ Some usage examples are also available [here](example/mock.rb)
66
+
67
+ ## Development
68
+
69
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
70
+
71
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
72
+
73
+
74
+ ## License
75
+
76
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
77
+
78
+ ## Contributing
79
+
80
+ 1. Fork it ( https://github.com/vishalgarg231/facebook_graph_api/fork )
81
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
82
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
83
+ 4. Push to the branch (`git push origin my-new-feature`)
84
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
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 ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fb_graph_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'readline'
14
+ require 'pry'
15
+ Pry.start
data/bin/fb_graph ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'fb_graph_api/cli'
5
+
6
+ FbGraphApi::CLI.start(ARGV)
data/bin/graph_api ADDED
@@ -0,0 +1,4 @@
1
+ require 'bundler/setup'
2
+ require 'fb_graph_api/cli'
3
+
4
+ FbGraphApi::CLI.start(ARGV)
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/example/mock.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'fb_graph_api'
2
+
3
+ # configure the client
4
+ Profile = FbGraphApi::Profile.new(facebook_user_access_token)
5
+
6
+ # Profle details examples
7
+ Profile.info
8
+
9
+ # Profile picture
10
+ Profile.picture('large')
11
+
12
+
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fb_graph_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fb_graph_api"
8
+ spec.version = FbGraphApi::VERSION
9
+ spec.authors = ['Vishal Garg']
10
+ spec.email = ['vishalgarg231@gmail.com']
11
+
12
+ spec.summary = %q{Ruby facebook graph APIs}
13
+ spec.description = %q{Gem consolidate all the graph api's into one set to ease the usage'}
14
+ spec.homepage = "https://github.com/vishalgarg231/fb_graph_api"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency 'thor', '~> 0.19'
23
+ spec.add_dependency 'faraday', '~> 0.9'
24
+ spec.add_dependency 'faraday_middleware', '~> 0.9'
25
+ spec.add_dependency 'recursive-open-struct', '~> 0.6'
26
+
27
+ spec.add_development_dependency 'bundler', '~> 1.10.6'
28
+ spec.add_development_dependency 'byebug'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'pry', '~> 0.10'
31
+ spec.add_development_dependency 'yard', '~> 0.8'
32
+ spec.add_development_dependency 'rb-readline'
33
+ end
@@ -0,0 +1,11 @@
1
+ require "fb_graph_api/version"
2
+ require "fb_graph_api/client"
3
+ require "fb_graph_api/profile"
4
+
5
+ require 'faraday'
6
+ require 'byebug'
7
+ require 'faraday_middleware'
8
+ require 'recursive-open-struct'
9
+
10
+ module FbGraphApi
11
+ end
@@ -0,0 +1,10 @@
1
+ require 'thor'
2
+
3
+ module FbGraphApi
4
+ class CLI < Thor
5
+ desc 'version', 'print version'
6
+ def version
7
+ puts "Version: #{FbGraphApi::VERSION}"
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,19 @@
1
+ module FbGraphApi
2
+ class Client
3
+ attr_accessor :token
4
+
5
+ def initialize(token)
6
+ @address = 'https://graph.facebook.com'
7
+ @acess_token = token
8
+ end
9
+
10
+ def connection
11
+ Faraday.new(url: @address) do |conn|
12
+ conn.authorization 'Bearer', @acess_token
13
+ conn.request :json
14
+ conn.response :json, :content_type => /\bjson$/
15
+ conn.adapter Faraday.default_adapter
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ module FbGraphApi
2
+
3
+ # This module provides API requests to get facebook profile details
4
+ # and profile picture
5
+
6
+ class Profile
7
+
8
+ attr_accessor :id
9
+
10
+ # Intialize connection
11
+ # Reverses the contents of a String or IO object.
12
+ # @param token [String]
13
+ def initialize(token = nil)
14
+ client = FbGraphApi::Client.new(token)
15
+ @connection = client.connection
16
+ end
17
+
18
+ # Retrieve profile details
19
+ # @return Object of facebook profile details
20
+ def info
21
+ response = @connection.get 'me'
22
+ self.id = response.body["id"].to_i
23
+ OpenStruct.new(response.body)
24
+ end
25
+
26
+
27
+ # Retrieve facebook picture
28
+ # @param size [String]
29
+ # @return Object of facebook picture
30
+ def picture(size = 'large')
31
+ info unless id
32
+ response = @connection.get "#{@id}/picture", {type: size}
33
+ OpenStruct.new(response.env.response_headers)
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module FbGraphApi
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,204 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fb_graph_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vishal Garg
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday_middleware
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.9'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.9'
55
+ - !ruby/object:Gem::Dependency
56
+ name: recursive-open-struct
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.10.6
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.10.6
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
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
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.10'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.10'
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.8'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.8'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rb-readline
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Gem consolidate all the graph api's into one set to ease the usage'
154
+ email:
155
+ - vishalgarg231@gmail.com
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
163
+ - CODE_OF_CONDUCT.md
164
+ - Gemfile
165
+ - LICENSE.txt
166
+ - README.md
167
+ - Rakefile
168
+ - bin/console
169
+ - bin/fb_graph
170
+ - bin/graph_api
171
+ - bin/setup
172
+ - example/mock.rb
173
+ - fb_graph_api.gemspec
174
+ - lib/fb_graph_api.rb
175
+ - lib/fb_graph_api/cli.rb
176
+ - lib/fb_graph_api/client.rb
177
+ - lib/fb_graph_api/profile.rb
178
+ - lib/fb_graph_api/version.rb
179
+ homepage: https://github.com/vishalgarg231/fb_graph_api
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubyforge_project:
199
+ rubygems_version: 2.4.8
200
+ signing_key:
201
+ specification_version: 4
202
+ summary: Ruby facebook graph APIs
203
+ test_files: []
204
+ has_rdoc: