fobos 0.0.5 → 0.0.6

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: 20741b72246c53e4964983a278f6fdb5388f847e
4
- data.tar.gz: 12acd2fb3cf7a5dbfaf83278ad1cc23a5ca9df95
3
+ metadata.gz: 6d50d60fa119b7ff9f0336379a0798d63cbe6215
4
+ data.tar.gz: a622fa5b2572d432dd07884d2bf5ff0cdb7e7e81
5
5
  SHA512:
6
- metadata.gz: 6dc78c2e2f2e979b56713b36ce4a28fe17ff327bd0fa5f68361e7d507ba9245f576238b72b8c0f6e525f14b45d8f3dc48e9651c1e84a71bfd8596ca88b7ce267
7
- data.tar.gz: 22e32021f21aa245a65000d8541b8c12100fe8293a510f942c3f98ffaea7635c37fab6d4daf2ed663cef12dc3c3bae1827fb48a646ec92c1c67723e3112bbcb6
6
+ metadata.gz: fb6566284b89c7a1982de84c2398ec1e2fbaf2e94045129a24688e74293af59387a0747907266fc7e59540e9cd6169f392b6cff7ff989799a5ffec98c5a902a4
7
+ data.tar.gz: f97f2d797954df718368b196520c9be8eba963c17bc210de33c692a87e34fa88ad188b53dd10e36997f33091f88e82acf081e3e15d0ea97c0bcb52ed9227baef
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm: 2.1.2
3
+ before_install:
4
+ - gem install bundler
5
+ script:
6
+ - gem update
7
+ - gem install httparty
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Fobos
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/fobos.svg)](http://badge.fury.io/rb/fobos)
4
+ [![Build Status](https://travis-ci.org/mxgoncharov/fobos.svg?branch=master)](https://travis-ci.org/mxgoncharov/fobos)
5
+ [![Dependency Status](https://gemnasium.com/mxgoncharov/fobos.svg)](https://gemnasium.com/mxgoncharov/fobos)
6
+ [![Code Climate](https://codeclimate.com/github/mxgoncharov/fobos/badges/gpa.svg)](https://codeclimate.com/github/mxgoncharov/fobos)
7
+
3
8
  Fobos is a easy to use, based on HTTParty gem for working with Facebook Graph and REST API.
4
9
 
5
10
 
@@ -36,16 +41,16 @@ Then call method which generate URL for getting access code.
36
41
  access_code_url = oauth.get_user_access_code_url
37
42
  ```
38
43
 
39
- **OR**, you can make HTTP request.
44
+ **THEN**, you need make HTTP request.
40
45
 
41
46
  ```ruby
42
- oauth.get_user_access_code
47
+ redirect_to access_code_url
43
48
  ```
44
49
 
45
50
  Now you can get access token from access code.
46
51
 
47
52
  ```ruby
48
- oauth.get_user_access_token
53
+ oauth.get_user_access_token(access_code)
49
54
  ```
50
55
 
51
56
  On oauth_callback_url facebook will send token in params.
@@ -57,7 +62,7 @@ Use Fobos::GraphAPI::Users for working with user's data and Fobos::GraphAPI::Pag
57
62
 
58
63
  ## Contributing
59
64
 
60
- 1. Fork it ( https://github.com/[my-github-username]/fobos/fork )
65
+ 1. Fork it ( https://github.com/mxgoncharov/fobos/fork )
61
66
  2. Create your feature branch (`git checkout -b my-new-feature`)
62
67
  3. Commit your changes (`git commit -am 'Add some feature'`)
63
68
  4. Push to the branch (`git push origin my-new-feature`)
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.7"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
 
24
- spec.add_dependency "httparty", "~> 0.13"
24
+ spec.add_dependency "httparty", "~>0.13"
25
25
  end
@@ -0,0 +1,7 @@
1
+ # Override Class::Hash
2
+ class Hash
3
+ # Add access_token to options for API call
4
+ def add_access_token_to_options(access_token)
5
+ self[:access_token] = access_token
6
+ end
7
+ end
@@ -39,8 +39,8 @@ module Fobos
39
39
  #
40
40
  # <b>Options</b> you can see here https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/v2.1#login
41
41
  def get_user_access_code_url(oauth_callback_url = @oauth_callback_url, options = {})
42
- options_part = ''
43
- options_part = "&" + options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&') unless options.empty?
42
+ options_part = String.new
43
+ options_part = Options.map_options_to_params(options) unless options.empty?
44
44
 
45
45
  query = "/dialog/oauth?client_id=#{@app_id}&redirect_uri=#{oauth_callback_url}#{options_part}"
46
46
 
@@ -0,0 +1,9 @@
1
+ module Fobos
2
+ module GraphAPI
3
+ class Options
4
+ def self.map_options_to_params(options)
5
+ options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&')
6
+ end
7
+ end
8
+ end
9
+ end
@@ -33,8 +33,8 @@ module Fobos
33
33
  #
34
34
  # If you want publish something from Page you need call it with <b>PAGE_ACCESS_TOKEN</b>. You can get it from list of user's account returned by Fobos::GraphAPI::Pages.get_accounts.
35
35
  def post_to_page(page_id, page_access_token, options = {})
36
- options_part = ''
37
- options_part = options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&') unless options.empty?
36
+ options_part = String.new
37
+ options_part = Options.map_options_to_params(options) unless options.empty?
38
38
 
39
39
  query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}&access_token=#{page_access_token}"
40
40
 
@@ -49,10 +49,10 @@ module Fobos
49
49
  #
50
50
  # Use access_token from Fobos::GraphAPI::Pages.new
51
51
  def get_feed(page_id, options = {})
52
- options_part = ''
53
- options_part = options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&') unless options.empty?
52
+ options.add_access_token_to_options(@access_token)
53
+ options_part = Options.map_options_to_params(options)
54
54
 
55
- query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}&access_token=#{@access_token}"
55
+ query = GRAPH_URI.to_s + "/#{page_id}" + "/feed?#{options_part}"
56
56
 
57
57
  self.class.get(query)
58
58
  end
@@ -5,7 +5,6 @@ module Fobos
5
5
  module GraphAPI
6
6
  class Users
7
7
  include HTTParty
8
-
9
8
  # You can get access token with Fobos::GraphAPI::Oauth.
10
9
  attr_accessor :access_token
11
10
 
@@ -19,34 +18,42 @@ module Fobos
19
18
  @access_token = access_token
20
19
  end
21
20
 
22
- # Provides getting user's data with options.
21
+ # Generate link for getting user's data with options.
23
22
  # Options must be a hash. You can provide value as String or Array.
24
23
  #
25
- # E.g. Fobos::GraphAPI::Users.new(access_token).get_request(fields: 'id,first_name,last_name') will return ID, FIRST NAME and LAST NAME of user.
26
- def get_request(options = {})
27
- options_part = ''
28
- options_part = options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&') unless options.empty?
24
+ # E.g. Fobos::GraphAPI::Users.new(access_token).get_request_url(fields: 'id') will return "https://graph.facebook.com/v2.1/me?fields=id&access_token=some_token"
25
+ def get_request_url(options = {})
26
+ options.add_access_token_to_options(@access_token)
27
+ options_part = Options.map_options_to_params(options)
29
28
 
30
- query = GRAPH_URI.to_s + '/v2.1' '/me?' + options_part + "&access_token=#{@access_token}"
31
-
32
- self.class.get(query)
29
+ GRAPH_URI.to_s + '/v2.1' '/me?' + options_part
33
30
  end
34
31
 
35
- # Provides sending post request (publishing) for user.
32
+
33
+ # Generate link for post request (publishing) for user.
36
34
  # Options must be a hash. You can provide value as String or Array.
37
35
  #
38
- # E.g. Fobos::GraphAPI::Users.new(access_token).post_request(message: 'This is test message') will post "This is test message" to user's feed.
39
- def post_request(options = {})
40
- options_part = ''
41
- options_part = options.map {|k,v| "#{k}=#{v.kind_of?(Array) ? v.join(',') : v}" }.join('&') unless options.empty?
36
+ # E.g. Fobos::GraphAPI::Users.new(access_token).post_request(message: 'This is test message') will return "https://graph.facebook.com/v2.1/me/feed?message=This is test message&access_token=some_token"
37
+ def post_request_url(options = {})
38
+ options.add_access_token_to_options(@access_token)
39
+ options_part = Options.map_options_to_params(options)
42
40
 
43
- query = GRAPH_URI.to_s + '/v2.1' '/me/feed?' + options_part + "&access_token=#{@access_token}"
41
+ query = GRAPH_URI.to_s + '/v2.1' '/me/feed?' + options_part
42
+ end
44
43
 
45
- encoded_url = URI.encode(query)
46
44
 
47
- self.class.post(URI.parse(encoded_url))
45
+
46
+ # Provides call of get_request_url
47
+ def get_request(options = {})
48
+ self.class.get(get_request_url(options))
48
49
  end
49
50
 
51
+ # Provides call of post_request_url
52
+ def post_request(options = {})
53
+ encoded_url = URI.encode(post_request_url(options))
54
+
55
+ self.class.post(URI.parse(encoded_url))
56
+ end
50
57
  end
51
58
  end
52
59
  end
@@ -1,3 +1,3 @@
1
1
  module Fobos
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fobos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Goncharov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2014-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,6 +60,7 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".travis.yml"
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md
@@ -67,7 +68,9 @@ files:
67
68
  - fobos.gemspec
68
69
  - lib/fobos.rb
69
70
  - lib/fobos/graph_api/graph_api.rb
71
+ - lib/fobos/graph_api/hash.rb
70
72
  - lib/fobos/graph_api/o_auth.rb
73
+ - lib/fobos/graph_api/options.rb
71
74
  - lib/fobos/graph_api/pages.rb
72
75
  - lib/fobos/graph_api/users.rb
73
76
  - lib/fobos/version.rb