social_feed_agregator 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b36b56a9cd33c294d1b3e7da712042233ccdefd4
4
- data.tar.gz: d139dc6518c09e0c150ccafc8a62235690822466
3
+ metadata.gz: f548b461c4328280e0e85046aaf241f6f9083659
4
+ data.tar.gz: 2ba8f7d20acf36b32c6f20ff1ed511eac17bfeac
5
5
  SHA512:
6
- metadata.gz: a7fcab329c15c09781b5ca83bb456ae95ba809eefdc886ff2325e8d45357ffb02411eb52e201ef37e98ad66f5914ad755641aec86ce60b5984429fa4d1e6db8d
7
- data.tar.gz: 9d94827c0a15e701cbadc91f6b85000cd4643bce34e61db473a9ec1f6f22cc0bf9022b64504785be28e1e31c6945572daa1ef8eb27748a6189b34e11560954be
6
+ metadata.gz: 064e1ccde9755477090af8a13fc159d5d6ab6d245e98882c06e48fede8a11fef2b1b22e8e86397ba21ebc39bf24c0996a6203721279f55994899372744bcf03c
7
+ data.tar.gz: fc042377bbaf949625ed7fca328b8f4dd2fbee676cf3267eb41c47f310f65d9a5428aa98e24820225a2d59ea1d8d361c18d8ce8090acb5195428ac1e5a60a857
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in social_feed_agregator.gemspec
4
+ gem 'twitter', '=4.6.2'
4
5
  gemspec
@@ -0,0 +1,51 @@
1
+ require "social_feed_agregator/feed"
2
+ require "koala"
3
+
4
+ module SocialFeedAgregator
5
+ class FacebookReader
6
+
7
+ attr_accessor :app_id, :app_secret, :name
8
+
9
+ def initialize(options={})
10
+ options.replace(SocialFeedAgregator.default_options.merge(options))
11
+
12
+ @name = options[:facebook_user_name]
13
+ @app_id = options[:facebook_app_id]
14
+ @app_secret = options[:facebook_app_secret]
15
+ end
16
+
17
+ def get_feeds(options={})
18
+ @name = options[:name] if options[:name]
19
+
20
+ oauth = Koala::Facebook::OAuth.new(@app_id, @app_secret)
21
+ graph = Koala::Facebook::API.new oauth.get_app_access_token
22
+ posts = graph.get_connections(@name, "posts")
23
+
24
+ begin
25
+ posts.map do |post|
26
+ Feed.new ({
27
+ feed_type: :facebook,
28
+ feed_id: post['id'],
29
+
30
+ user_id: post['from']['id'],
31
+ user_name: post['from']['name'],
32
+
33
+ permalink: "http://www.facebook.com/#{post['id'].gsub('_', '/posts/')}",
34
+ description: post['description'],
35
+
36
+ name: post['name'],
37
+ picture_url: post['picture'],
38
+ link: post['link'],
39
+ caption: post['caption'],
40
+ story: post['story'],
41
+ message: post['message'],
42
+ created_at: post["created_time" ],
43
+ type: post['type']
44
+ })
45
+ end
46
+ end while not posts = posts.next_page
47
+
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,39 @@
1
+ module SocialFeedAgregator
2
+ class Feed
3
+
4
+ attr_accessor :feed_type, # :facebook, :twitter or :linkedin
5
+ :feed_id, # origin feed id
6
+ :user_id, # user id
7
+ :user_name, # user name
8
+ :permalink,
9
+ :description,
10
+ :picture_url,
11
+ :name,
12
+ :link,
13
+ :story,
14
+ :message, # status message
15
+ :caption,
16
+ :created_at,
17
+ :type # link or status
18
+
19
+ def initialize(options={})
20
+ @feed_type = options[:feed_type]
21
+ @feed_id = options[:feed_id]
22
+
23
+ @user_id = options[:user_id]
24
+ @user_name = options[:user_name]
25
+
26
+ @permalink = options[:permalink]
27
+ @description = options[:description]
28
+ @picture_url = options[:picture_url]
29
+
30
+ @name = options[:name]
31
+ @link = options[:link]
32
+ @story = options[:story]
33
+ @message = options[:message]
34
+ @caption = options[:caption]
35
+ @created_at = options[:created_at]
36
+ @type = options[:type]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,79 @@
1
+ require "social_feed_agregator/feed"
2
+ require "twitter"
3
+
4
+ module SocialFeedAgregator
5
+ class TwitterReader
6
+
7
+ attr_accessor :consumer_key,
8
+ :consumer_secret,
9
+ :twitter_oauth_token,
10
+ :twitter_oauth_token_secret,
11
+ :twitter_name
12
+
13
+ def initialize(options={})
14
+ options.replace(SocialFeedAgregator.default_options.merge(options))
15
+
16
+ @consumer_key = options[:twitter_consumer_key]
17
+ @consumer_secret = options[:twitter_consumer_secret]
18
+ @oauth_token = options[:twitter_oauth_token]
19
+ @token_secret = options[:twitter_oauth_token_secret]
20
+ @name = options[:twitter_user_name]
21
+ end
22
+
23
+ def get_feeds(options={})
24
+ @name = options[:name] if options[:name]
25
+ count = options[:count] if options[:count]
26
+
27
+ client = ::Twitter.configure do |config|
28
+ config.consumer_key = @consumer_key
29
+ config.consumer_secret = @consumer_secret
30
+ config.oauth_token = @oauth_token
31
+ config.oauth_token_secret = @token_secret
32
+ end
33
+
34
+ statuses = client.user_timeline(@name, {count: count})
35
+
36
+ statuses.map do |status|
37
+ tweet_type = 'status'
38
+ picture_url = ''
39
+ link = ''
40
+
41
+ if status.entities?
42
+
43
+ if status.media.any?
44
+ photo_entity = status.media.first
45
+ tweet_type = 'photo'
46
+ picture_url = photo_entity.media_url
47
+ end
48
+
49
+ if status.urls.any?
50
+ url_entity = status.urls.first
51
+ tweet_type = 'link'
52
+ link = url_entity.url
53
+ end
54
+
55
+ end
56
+
57
+
58
+ Feed.new ({
59
+ feed_type: :twitter,
60
+ feed_id: status.id.to_s,
61
+
62
+ user_id: status.user.id,
63
+ user_name: status.user.screen_name,
64
+
65
+ permalink: "https://twitter.com/#{status.user.screen_name}/status/#{status.id}", #status.url,
66
+ message: status.text,
67
+ created_at: status.created_at,
68
+
69
+ type: tweet_type,
70
+ picture_url: picture_url,
71
+ link: link
72
+ })
73
+ end
74
+
75
+ end
76
+
77
+ end
78
+ Twitter = TwitterReader
79
+ end
@@ -1,3 +1,3 @@
1
1
  module SocialFeedAgregator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,5 +1,12 @@
1
1
  require "social_feed_agregator/version"
2
+ require "social_feed_agregator/facebook_reader"
3
+ require "social_feed_agregator/twitter_reader"
2
4
 
3
- module SocialFeedAgregator
4
- # Your code goes here...
5
+ module SocialFeedAgregator
6
+ @default_options = {}
7
+ class << self; attr_accessor :default_options; end
8
+
9
+ class Exception < ::Exception; end
5
10
  end
11
+
12
+ SFA=SocialFeedAgregator
@@ -20,4 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+
24
+ spec.add_dependency("koala", "~> 1.6.0")
25
+ spec.add_dependency("twitter", "= 4.6.2")
23
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_feed_agregator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugene Sobolev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: koala
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.6.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.6.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: twitter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 4.6.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 4.6.2
41
69
  description: Social Feed Agregator
42
70
  email:
43
71
  - eus@appfellas.co
@@ -51,6 +79,9 @@ files:
51
79
  - README.md
52
80
  - Rakefile
53
81
  - lib/social_feed_agregator.rb
82
+ - lib/social_feed_agregator/facebook_reader.rb
83
+ - lib/social_feed_agregator/feed.rb
84
+ - lib/social_feed_agregator/twitter_reader.rb
54
85
  - lib/social_feed_agregator/version.rb
55
86
  - social_feed_agregator.gemspec
56
87
  homepage: ''