social_feed_agregator 0.0.3 → 0.0.4
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 +4 -4
 - data/README.md +11 -1
 - data/lib/social_feed_agregator/facebook_reader.rb +30 -28
 - data/lib/social_feed_agregator/feed.rb +4 -3
 - data/lib/social_feed_agregator/googleplus_reader.rb +83 -0
 - data/lib/social_feed_agregator/pinterest_reader.rb +27 -20
 - data/lib/social_feed_agregator/twitter_reader.rb +39 -34
 - data/lib/social_feed_agregator/version.rb +1 -1
 - data/lib/social_feed_agregator.rb +2 -1
 - data/social_feed_agregator.gemspec +1 -0
 - metadata +17 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c25a7863ae0347bf1137b9e8d944e8cdbb57df83
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 183bf16b93688b987c07ce1b1fe0e66768af5366
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 79c9bb597064ca084f47e1669e0e157d37b91fc189484d380bdb041fe10ab5754f2e82015ab0d2d4948dc56c5a8ee6d885e764a3a87ca7c4b9905c78f8ee4a7e
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d226b91b2dacae93ea545b6f871f0b0a7b355fdd6aeeb5e84328c1c8d56ee2d6f52d3931ddc9f8e97a087cb86ec755ef122a399262cc344d49306c21b31a2093
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Or install it yourself as: 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            ## Usage
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                ## 1. Create reader for some social service (available Facebook, Twitter, Pinterest)
         
     | 
| 
      
 21 
     | 
    
         
            +
                ## 1. Create reader for some social service (available Facebook, Twitter, Pinterest, GooglePlus)
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                fb = SFA::Facebook.new ({      
         
     | 
| 
       24 
24 
     | 
    
         
             
                  facebook_app_id:            "FACEBOOK_APP_ID", 
         
     | 
| 
         @@ -38,6 +38,11 @@ Or install it yourself as: 
     | 
|
| 
       38 
38 
     | 
    
         
             
                  pinterest_user_name:        "PINTEREST_USER_NAME"
         
     | 
| 
       39 
39 
     | 
    
         
             
                })
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
      
 41 
     | 
    
         
            +
                gp = SFA::Googleplus.new ({
         
     | 
| 
      
 42 
     | 
    
         
            +
                  googleplus_user_id: "GOOGLEPLUS_USER_ID",
         
     | 
| 
      
 43 
     | 
    
         
            +
                  googleplus_api_key: "GOOGLEPLUS_API_KEY"
         
     | 
| 
      
 44 
     | 
    
         
            +
                })
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
       41 
46 
     | 
    
         | 
| 
       42 
47 
     | 
    
         
             
                ## 2. Get data
         
     | 
| 
       43 
48 
     | 
    
         | 
| 
         @@ -58,6 +63,11 @@ Or install it yourself as: 
     | 
|
| 
       58 
63 
     | 
    
         
             
                  res << feed
         
     | 
| 
       59 
64 
     | 
    
         
             
                end
         
     | 
| 
       60 
65 
     | 
    
         | 
| 
      
 66 
     | 
    
         
            +
                # Default 25
         
     | 
| 
      
 67 
     | 
    
         
            +
                gp.get_feeds(count: 2) do |feed|
         
     | 
| 
      
 68 
     | 
    
         
            +
                  res << feed
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
       61 
71 
     | 
    
         
             
                res.sort!{|a, b| a.created_at <=> b.created_at}
         
     | 
| 
       62 
72 
     | 
    
         | 
| 
       63 
73 
     | 
    
         
             
                res.to_json
         
     | 
| 
         @@ -9,58 +9,60 @@ module SocialFeedAgregator 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                def initialize(options={})
         
     | 
| 
       11 
11 
     | 
    
         
             
                  super(options)
         
     | 
| 
       12 
     | 
    
         
            -
                  options.replace( 
     | 
| 
      
 12 
     | 
    
         
            +
                  options.replace(SFA.default_options.merge(options))
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                  @name =       options[:facebook_user_name]
         
     | 
| 
       15 
15 
     | 
    
         
             
                  @app_id =     options[:facebook_app_id]
         
     | 
| 
       16 
16 
     | 
    
         
             
                  @app_secret = options[:facebook_app_secret]      
         
     | 
| 
       17 
     | 
    
         
            -
                end
         
     | 
| 
      
 17 
     | 
    
         
            +
                end    
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                def get_feeds(options={})
         
     | 
| 
       20 
20 
     | 
    
         
             
                  super(options)
         
     | 
| 
       21 
21 
     | 
    
         
             
                  @name = options[:name] if options[:name]
         
     | 
| 
       22 
     | 
    
         
            -
                  count = options[:count] || 25
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                  oauth = Koala::Facebook::OAuth.new(@app_id, @app_secret)      
         
     | 
| 
       25 
     | 
    
         
            -
                  graph = Koala::Facebook::API.new oauth.get_app_access_token      
         
     | 
| 
       26 
     | 
    
         
            -
                  posts = graph.get_connections(@name, "posts")
         
     | 
| 
      
 22 
     | 
    
         
            +
                  count = options[:count] || 25      
         
     | 
| 
       27 
23 
     | 
    
         | 
| 
       28 
24 
     | 
    
         
             
                  feeds, i, count_per_request, items = [], 0, 25, 0
         
     | 
| 
       29 
25 
     | 
    
         | 
| 
       30 
26 
     | 
    
         
             
                  parts = (count.to_f / count_per_request).ceil
         
     | 
| 
       31 
27 
     | 
    
         | 
| 
      
 28 
     | 
    
         
            +
                  oauth = Koala::Facebook::OAuth.new(@app_id, @app_secret)      
         
     | 
| 
      
 29 
     | 
    
         
            +
                  graph = Koala::Facebook::API.new oauth.get_app_access_token      
         
     | 
| 
      
 30 
     | 
    
         
            +
                  posts = graph.get_connections(@name, "posts")
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
       32 
32 
     | 
    
         
             
                  begin
         
     | 
| 
       33 
33 
     | 
    
         
             
                    i+=1
         
     | 
| 
       34 
34 
     | 
    
         
             
                    posts.each do |post|    
         
     | 
| 
       35 
35 
     | 
    
         
             
                      items+=1
         
     | 
| 
       36 
36 
     | 
    
         
             
                      break if items > count
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
     | 
    
         
            -
                      feed =  
     | 
| 
       39 
     | 
    
         
            -
                        feed_type: :facebook,
         
     | 
| 
       40 
     | 
    
         
            -
                        feed_id: post['id'],
         
     | 
| 
       41 
     | 
    
         
            -
                        
         
     | 
| 
       42 
     | 
    
         
            -
                        user_id: post['from']['id'],
         
     | 
| 
       43 
     | 
    
         
            -
                        user_name: post['from']['name'],
         
     | 
| 
       44 
     | 
    
         
            -
                        
         
     | 
| 
       45 
     | 
    
         
            -
                        permalink: "http://www.facebook.com/#{post['id'].gsub('_', '/posts/')}",
         
     | 
| 
       46 
     | 
    
         
            -
                        description: post['description'],
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                        name: post['name'],
         
     | 
| 
       49 
     | 
    
         
            -
                        picture_url: post['picture'],
         
     | 
| 
       50 
     | 
    
         
            -
                        link: post['link'],
         
     | 
| 
       51 
     | 
    
         
            -
                        caption: post['caption'],
         
     | 
| 
       52 
     | 
    
         
            -
                        story: post['story'],
         
     | 
| 
       53 
     | 
    
         
            -
                        message: post['message'],      
         
     | 
| 
       54 
     | 
    
         
            -
                        created_at: DateTime.parse(post["created_time"]),
         
     | 
| 
       55 
     | 
    
         
            -
                        type: post['type']
         
     | 
| 
       56 
     | 
    
         
            -
                      })
         
     | 
| 
      
 38 
     | 
    
         
            +
                      feed = fill_feed post
         
     | 
| 
       57 
39 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
                      block_given? ? yield(feed) : feeds << feed
         
     | 
| 
       59 
     | 
    
         
            -
                      
         
     | 
| 
      
 40 
     | 
    
         
            +
                      block_given? ? yield(feed) : feeds << feed          
         
     | 
| 
       60 
41 
     | 
    
         
             
                    end       
         
     | 
| 
       61 
42 
     | 
    
         
             
                  end while (posts = posts.next_page) && (i < parts)
         
     | 
| 
       62 
43 
     | 
    
         
             
                  feeds
         
     | 
| 
       63 
44 
     | 
    
         
             
                end   
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                private
         
     | 
| 
      
 47 
     | 
    
         
            +
              
         
     | 
| 
      
 48 
     | 
    
         
            +
                def fill_feed(post)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  Feed.new(
         
     | 
| 
      
 50 
     | 
    
         
            +
                    feed_type: :facebook,
         
     | 
| 
      
 51 
     | 
    
         
            +
                    feed_id: post['id'],                
         
     | 
| 
      
 52 
     | 
    
         
            +
                    user_id: post['from']['id'],
         
     | 
| 
      
 53 
     | 
    
         
            +
                    user_name: post['from']['name'],        
         
     | 
| 
      
 54 
     | 
    
         
            +
                    permalink: "http://www.facebook.com/#{post['id'].gsub('_', '/posts/')}",
         
     | 
| 
      
 55 
     | 
    
         
            +
                    description: post['description'],
         
     | 
| 
      
 56 
     | 
    
         
            +
                    name: post['name'],
         
     | 
| 
      
 57 
     | 
    
         
            +
                    picture_url: post['picture'],
         
     | 
| 
      
 58 
     | 
    
         
            +
                    link: post['link'],
         
     | 
| 
      
 59 
     | 
    
         
            +
                    caption: post['caption'],        
         
     | 
| 
      
 60 
     | 
    
         
            +
                    message: post['message'],      
         
     | 
| 
      
 61 
     | 
    
         
            +
                    created_at: DateTime.parse(post["created_time"]),
         
     | 
| 
      
 62 
     | 
    
         
            +
                    type: post['type']
         
     | 
| 
      
 63 
     | 
    
         
            +
                  )
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
       64 
66 
     | 
    
         
             
              end
         
     | 
| 
       65 
67 
     | 
    
         
             
              Facebook = FacebookReader
         
     | 
| 
       66 
68 
     | 
    
         
             
            end
         
     | 
| 
         @@ -10,7 +10,7 @@ module SocialFeedAgregator 
     | 
|
| 
       10 
10 
     | 
    
         
             
                              :picture_url,    
         
     | 
| 
       11 
11 
     | 
    
         
             
                              :name,
         
     | 
| 
       12 
12 
     | 
    
         
             
                              :link, 
         
     | 
| 
       13 
     | 
    
         
            -
                              :story, 
         
     | 
| 
      
 13 
     | 
    
         
            +
                              # :story, 
         
     | 
| 
       14 
14 
     | 
    
         
             
                              :message,          # status message
         
     | 
| 
       15 
15 
     | 
    
         
             
                              :caption, 
         
     | 
| 
       16 
16 
     | 
    
         
             
                              :created_at, 
         
     | 
| 
         @@ -29,11 +29,12 @@ module SocialFeedAgregator 
     | 
|
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                  @name  = options[:name]
         
     | 
| 
       31 
31 
     | 
    
         
             
                  @link  = options[:link]
         
     | 
| 
       32 
     | 
    
         
            -
                  @story = options[:story]
         
     | 
| 
      
 32 
     | 
    
         
            +
                  # @story = options[:story]
         
     | 
| 
       33 
33 
     | 
    
         
             
                  @message = options[:message]
         
     | 
| 
       34 
34 
     | 
    
         
             
                  @caption = options[:caption]
         
     | 
| 
       35 
35 
     | 
    
         
             
                  @created_at = options[:created_at]
         
     | 
| 
       36 
36 
     | 
    
         
             
                  @type = options[:type]              
         
     | 
| 
       37 
     | 
    
         
            -
                end 
     | 
| 
      
 37 
     | 
    
         
            +
                end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
       38 
39 
     | 
    
         
             
              end
         
     | 
| 
       39 
40 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require "social_feed_agregator/base_reader"
         
     | 
| 
      
 2 
     | 
    
         
            +
            require "social_feed_agregator/feed"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module SocialFeedAgregator
         
     | 
| 
      
 5 
     | 
    
         
            +
              class GoogleplusReader < BaseReader
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                attr_accessor :api_key, :user_id
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                def initialize(options={})
         
     | 
| 
      
 10 
     | 
    
         
            +
                  super(options)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  options.replace(SFA.default_options.merge(options))
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  @user_id = options[:googleplus_user_id]
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @api_key = options[:googleplus_api_key]
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
                    
         
     | 
| 
      
 17 
     | 
    
         
            +
                def get_feeds(options={}) 
         
     | 
| 
      
 18 
     | 
    
         
            +
                  super(options)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  @user_id = options[:user_id] if options[:user_id]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  count = options[:count] || 25
         
     | 
| 
      
 21 
     | 
    
         
            +
                  
         
     | 
| 
      
 22 
     | 
    
         
            +
                  feeds, i, count_per_request, items = [], 0, 100, 0
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                  opts =  {count: count < count_per_request ? count : count_per_request}
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  parts = (count.to_f / count_per_request).ceil
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  url = "https://www.googleapis.com/plus/v1/people/#{@user_id}/activities/public?key=#{@api_key}&maxResults=#{opts[:count]}"      
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 31 
     | 
    
         
            +
                    i+=1
         
     | 
| 
      
 32 
     | 
    
         
            +
                    next_query = ""
         
     | 
| 
      
 33 
     | 
    
         
            +
                    data = JSON.parse( RestClient.get("#{url}#{next_query}") )
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                    data['items'].each do |post|    
         
     | 
| 
      
 36 
     | 
    
         
            +
                      items+=1
         
     | 
| 
      
 37 
     | 
    
         
            +
                      break if items > count          
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
                      feed = fill_feed post
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                      block_given? ? yield(feed) : feeds << feed        
         
     | 
| 
      
 42 
     | 
    
         
            +
                    end       
         
     | 
| 
      
 43 
     | 
    
         
            +
                    next_query = "&pageToken=#{data['nextPageToken']}"
         
     | 
| 
      
 44 
     | 
    
         
            +
                    
         
     | 
| 
      
 45 
     | 
    
         
            +
                  end while (data['items'].count > 0 ) && (i < parts)      
         
     | 
| 
      
 46 
     | 
    
         
            +
                end   
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                private
         
     | 
| 
      
 49 
     | 
    
         
            +
                def fill_feed(post)
         
     | 
| 
      
 50 
     | 
    
         
            +
                  picture_url, link, caption = "", "", ""
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                  if atts = post['object']['attachments']
         
     | 
| 
      
 53 
     | 
    
         
            +
                    if atts.count > 0              
         
     | 
| 
      
 54 
     | 
    
         
            +
                      attach = atts.first
         
     | 
| 
      
 55 
     | 
    
         
            +
                      picture_url = attach['fullImage']['url'] if attach['fullImage']
         
     | 
| 
      
 56 
     | 
    
         
            +
                      link = attach['url']
         
     | 
| 
      
 57 
     | 
    
         
            +
                      caption = attach['displayName']
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                  Feed.new(
         
     | 
| 
      
 62 
     | 
    
         
            +
                    feed_type: :googleplus,
         
     | 
| 
      
 63 
     | 
    
         
            +
                    feed_id: post['id'],
         
     | 
| 
      
 64 
     | 
    
         
            +
                    
         
     | 
| 
      
 65 
     | 
    
         
            +
                    user_id: post['actor']['id'],
         
     | 
| 
      
 66 
     | 
    
         
            +
                    user_name: post['actor']['displayName'],
         
     | 
| 
      
 67 
     | 
    
         
            +
                    
         
     | 
| 
      
 68 
     | 
    
         
            +
                    permalink: post['url'],
         
     | 
| 
      
 69 
     | 
    
         
            +
                    description: post['object']['content'],
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                    name: post['title'],
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    picture_url: picture_url,
         
     | 
| 
      
 74 
     | 
    
         
            +
                    link: link,
         
     | 
| 
      
 75 
     | 
    
         
            +
                    caption: caption,
         
     | 
| 
      
 76 
     | 
    
         
            +
                    
         
     | 
| 
      
 77 
     | 
    
         
            +
                    created_at: DateTime.parse(post['published']),
         
     | 
| 
      
 78 
     | 
    
         
            +
                    type: post['object']['objectType']
         
     | 
| 
      
 79 
     | 
    
         
            +
                  )
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
              end
         
     | 
| 
      
 82 
     | 
    
         
            +
              Googleplus = GoogleplusReader
         
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -8,42 +8,49 @@ module SocialFeedAgregator 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                def initialize(options={})
         
     | 
| 
       10 
10 
     | 
    
         
             
                  super(options)
         
     | 
| 
       11 
     | 
    
         
            -
                  options.replace( 
     | 
| 
      
 11 
     | 
    
         
            +
                  options.replace(SFA.default_options.merge(options))
         
     | 
| 
       12 
12 
     | 
    
         
             
                  @name = options[:pinterest_user_name]      
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                def get_feeds(options={})
         
     | 
| 
       16 
16 
     | 
    
         
             
                  super(options)
         
     | 
| 
       17 
     | 
    
         
            -
                  @name = options[:name] 
     | 
| 
      
 17 
     | 
    
         
            +
                  @name = options[:name]  if options[:name]
         
     | 
| 
       18 
18 
     | 
    
         
             
                  count = options[:count] || 25
         
     | 
| 
      
 19 
     | 
    
         
            +
                  feeds = []
         
     | 
| 
      
 20 
     | 
    
         
            +
                  items = 0
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                  doc = Nokogiri::XML(RestClient.get("http://pinterest.com/#{@name}/feed.rss?page=2"))                       
         
     | 
| 
      
 22 
     | 
    
         
            +
                  doc = Nokogiri::XML( RestClient.get("http://pinterest.com/#{@name}/feed.rss") )
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                  doc.xpath('//item').each do |item|
         
     | 
| 
       25 
25 
     | 
    
         
             
                    items += 1
         
     | 
| 
       26 
26 
     | 
    
         
             
                    break if items > count
         
     | 
| 
       27 
     | 
    
         
            -
                    desc = item.xpath('description').inner_text.match(/src="(\S+)".+<p>(.+)<\/p>/)
         
     | 
| 
       28 
     | 
    
         
            -
                    
         
     | 
| 
       29 
     | 
    
         
            -
                    feed = Feed.new ({
         
     | 
| 
       30 
     | 
    
         
            -
                      feed_type: :pinterest,
         
     | 
| 
       31 
     | 
    
         
            -
                      feed_id: item.xpath('guid').inner_text.match(/\d+/)[0].to_s,
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                      user_id: @name,
         
     | 
| 
       34 
     | 
    
         
            -
                      user_name: @name,
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                      name: item.xpath('title').inner_text,          
         
     | 
| 
       37 
     | 
    
         
            -
                      permalink: item.xpath('link').inner_text,
         
     | 
| 
       38 
     | 
    
         
            -
                      picture_url: desc[1],
         
     | 
| 
       39 
     | 
    
         
            -
                      description: desc[2],
         
     | 
| 
       40 
     | 
    
         
            -
                      created_at: DateTime.parse(item.xpath('pubDate').inner_text), #.strftime("%Y-%m-%d %H:%M:%S")
         
     | 
| 
       41 
     | 
    
         
            -
                    })  
         
     | 
| 
       42 
27 
     | 
    
         | 
| 
      
 28 
     | 
    
         
            +
                    feed = fill_feed item
         
     | 
| 
      
 29 
     | 
    
         
            +
                    
         
     | 
| 
       43 
30 
     | 
    
         
             
                    block_given? ? yield(feed) : feeds << feed
         
     | 
| 
       44 
31 
     | 
    
         
             
                  end
         
     | 
| 
       45 
32 
     | 
    
         
             
                  feeds
         
     | 
| 
       46 
33 
     | 
    
         
             
                end   
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                private 
         
     | 
| 
      
 37 
     | 
    
         
            +
                def fill_feed(item)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  desc = item.xpath('description').inner_text.match(/src="(\S+)".+<p>(.+)<\/p>/)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    
         
     | 
| 
      
 40 
     | 
    
         
            +
                  feed = Feed.new(
         
     | 
| 
      
 41 
     | 
    
         
            +
                    feed_type: :pinterest,
         
     | 
| 
      
 42 
     | 
    
         
            +
                    feed_id: item.xpath('guid').inner_text.match(/\d+/)[0].to_s,
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    user_id: @name,
         
     | 
| 
      
 45 
     | 
    
         
            +
                    user_name: @name,
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    name: item.xpath('title').inner_text,          
         
     | 
| 
      
 48 
     | 
    
         
            +
                    permalink: item.xpath('link').inner_text,
         
     | 
| 
      
 49 
     | 
    
         
            +
                    picture_url: desc[1],
         
     | 
| 
      
 50 
     | 
    
         
            +
                    description: desc[2],
         
     | 
| 
      
 51 
     | 
    
         
            +
                    created_at: DateTime.parse(item.xpath('pubDate').inner_text), #.strftime("%Y-%m-%d %H:%M:%S")
         
     | 
| 
      
 52 
     | 
    
         
            +
                  )
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
       47 
54 
     | 
    
         
             
              end
         
     | 
| 
       48 
55 
     | 
    
         
             
              Pinterest = PinterestReader
         
     | 
| 
       49 
56 
     | 
    
         
             
            end
         
     | 
| 
         @@ -34,8 +34,7 @@ module SocialFeedAgregator 
     | 
|
| 
       34 
34 
     | 
    
         
             
                    config.oauth_token = @oauth_token
         
     | 
| 
       35 
35 
     | 
    
         
             
                    config.oauth_token_secret = @token_secret
         
     | 
| 
       36 
36 
     | 
    
         
             
                  end
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                      
         
     | 
| 
      
 37 
     | 
    
         
            +
                              
         
     | 
| 
       39 
38 
     | 
    
         
             
                  feeds, i = [], 0
         
     | 
| 
       40 
39 
     | 
    
         
             
                  count_per_request =  200 #::Twitter::REST::API::Timelines::MAX_TWEETS_PER_REQUEST      
         
     | 
| 
       41 
40 
     | 
    
         | 
| 
         @@ -47,37 +46,8 @@ module SocialFeedAgregator 
     | 
|
| 
       47 
46 
     | 
    
         
             
                    i+=1                
         
     | 
| 
       48 
47 
     | 
    
         | 
| 
       49 
48 
     | 
    
         
             
                    statuses.each do |status|                
         
     | 
| 
       50 
     | 
    
         
            -
                       
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
                      if status.entities?                      
         
     | 
| 
       53 
     | 
    
         
            -
                        if status.media.any?
         
     | 
| 
       54 
     | 
    
         
            -
                          photo_entity = status.media.first          
         
     | 
| 
       55 
     | 
    
         
            -
                          tweet_type = 'photo'
         
     | 
| 
       56 
     | 
    
         
            -
                          picture_url = photo_entity.media_url
         
     | 
| 
       57 
     | 
    
         
            -
                        end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                        if status.urls.any?
         
     | 
| 
       60 
     | 
    
         
            -
                          url_entity = status.urls.first          
         
     | 
| 
       61 
     | 
    
         
            -
                          tweet_type = 'link'
         
     | 
| 
       62 
     | 
    
         
            -
                          link = url_entity.url
         
     | 
| 
       63 
     | 
    
         
            -
                        end
         
     | 
| 
       64 
     | 
    
         
            -
                      end
         
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                      feed = Feed.new({
         
     | 
| 
       67 
     | 
    
         
            -
                        feed_type: :twitter,
         
     | 
| 
       68 
     | 
    
         
            -
                        feed_id: status.id.to_s,       
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                        user_id: status.user.id,
         
     | 
| 
       71 
     | 
    
         
            -
                        user_name: status.user.screen_name,
         
     | 
| 
       72 
     | 
    
         
            -
                        
         
     | 
| 
       73 
     | 
    
         
            -
                        permalink: "https://twitter.com/#{status.user.screen_name}/status/#{status.id}", #status.url,
         
     | 
| 
       74 
     | 
    
         
            -
                        message: status.text,          
         
     | 
| 
       75 
     | 
    
         
            -
                        created_at: status.created_at,
         
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                        type: tweet_type,
         
     | 
| 
       78 
     | 
    
         
            -
                        picture_url: picture_url,
         
     | 
| 
       79 
     | 
    
         
            -
                        link: link
         
     | 
| 
       80 
     | 
    
         
            -
                      }) 
         
     | 
| 
      
 49 
     | 
    
         
            +
                      
         
     | 
| 
      
 50 
     | 
    
         
            +
                      feed = fill_feed status
         
     | 
| 
       81 
51 
     | 
    
         | 
| 
       82 
52 
     | 
    
         
             
                      block_given? ? yield(feed) : feeds << feed     
         
     | 
| 
       83 
53 
     | 
    
         | 
| 
         @@ -88,7 +58,42 @@ module SocialFeedAgregator 
     | 
|
| 
       88 
58 
     | 
    
         
             
                  end
         
     | 
| 
       89 
59 
     | 
    
         
             
                  feeds
         
     | 
| 
       90 
60 
     | 
    
         
             
                end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                private 
         
     | 
| 
      
 64 
     | 
    
         
            +
                def fill_feed(status)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  tweet_type, picture_url, link  = 'status', '', ''
         
     | 
| 
      
 66 
     | 
    
         
            +
                       
         
     | 
| 
      
 67 
     | 
    
         
            +
                  if status.entities?                      
         
     | 
| 
      
 68 
     | 
    
         
            +
                    if status.media.any?
         
     | 
| 
      
 69 
     | 
    
         
            +
                      photo_entity = status.media.first          
         
     | 
| 
      
 70 
     | 
    
         
            +
                      tweet_type = 'photo'
         
     | 
| 
      
 71 
     | 
    
         
            +
                      picture_url = photo_entity.media_url
         
     | 
| 
      
 72 
     | 
    
         
            +
                    end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    if status.urls.any?
         
     | 
| 
      
 75 
     | 
    
         
            +
                      url_entity = status.urls.first          
         
     | 
| 
      
 76 
     | 
    
         
            +
                      tweet_type = 'link'
         
     | 
| 
      
 77 
     | 
    
         
            +
                      link = url_entity.url
         
     | 
| 
      
 78 
     | 
    
         
            +
                    end
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  feed = Feed.new(
         
     | 
| 
      
 82 
     | 
    
         
            +
                    feed_type: :twitter,
         
     | 
| 
      
 83 
     | 
    
         
            +
                    feed_id: status.id.to_s,       
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                    user_id: status.user.id,
         
     | 
| 
      
 86 
     | 
    
         
            +
                    user_name: status.user.screen_name,
         
     | 
| 
      
 87 
     | 
    
         
            +
                    
         
     | 
| 
      
 88 
     | 
    
         
            +
                    permalink: "https://twitter.com/#{status.user.screen_name}/status/#{status.id}", #status.url,
         
     | 
| 
      
 89 
     | 
    
         
            +
                    message: status.text,          
         
     | 
| 
      
 90 
     | 
    
         
            +
                    created_at: status.created_at,
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    type: tweet_type,
         
     | 
| 
      
 93 
     | 
    
         
            +
                    picture_url: picture_url,
         
     | 
| 
      
 94 
     | 
    
         
            +
                    link: link
         
     | 
| 
      
 95 
     | 
    
         
            +
                  ) 
         
     | 
| 
      
 96 
     | 
    
         
            +
                end   
         
     | 
| 
       92 
97 
     | 
    
         
             
              end
         
     | 
| 
       93 
98 
     | 
    
         
             
              Twitter = TwitterReader
         
     | 
| 
       94 
99 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,6 +2,7 @@ require "social_feed_agregator/version" 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require "social_feed_agregator/facebook_reader"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require "social_feed_agregator/twitter_reader"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require "social_feed_agregator/pinterest_reader"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "social_feed_agregator/googleplus_reader"
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            module SocialFeedAgregator  
         
     | 
| 
       7 
8 
     | 
    
         
             
              @default_options = {}
         
     | 
| 
         @@ -9,5 +10,5 @@ module SocialFeedAgregator 
     | 
|
| 
       9 
10 
     | 
    
         | 
| 
       10 
11 
     | 
    
         
             
              class Exception < ::Exception; end  
         
     | 
| 
       11 
12 
     | 
    
         
             
            end
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
       13 
14 
     | 
    
         
             
            SFA=SocialFeedAgregator
         
     | 
    
        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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-09-10 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -94,6 +94,20 @@ dependencies: 
     | 
|
| 
       94 
94 
     | 
    
         
             
                - - ~>
         
     | 
| 
       95 
95 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
96 
     | 
    
         
             
                    version: 1.6.0
         
     | 
| 
      
 97 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 98 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 99 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 100 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 101 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 102 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 103 
     | 
    
         
            +
                    version: 1.8.0
         
     | 
| 
      
 104 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 105 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 106 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 107 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 108 
     | 
    
         
            +
                - - ~>
         
     | 
| 
      
 109 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 110 
     | 
    
         
            +
                    version: 1.8.0
         
     | 
| 
       97 
111 
     | 
    
         
             
            description: Social Feed Agregator
         
     | 
| 
       98 
112 
     | 
    
         
             
            email:
         
     | 
| 
       99 
113 
     | 
    
         
             
            - eus@appfellas.co
         
     | 
| 
         @@ -110,6 +124,7 @@ files: 
     | 
|
| 
       110 
124 
     | 
    
         
             
            - lib/social_feed_agregator/base_reader.rb
         
     | 
| 
       111 
125 
     | 
    
         
             
            - lib/social_feed_agregator/facebook_reader.rb
         
     | 
| 
       112 
126 
     | 
    
         
             
            - lib/social_feed_agregator/feed.rb
         
     | 
| 
      
 127 
     | 
    
         
            +
            - lib/social_feed_agregator/googleplus_reader.rb
         
     | 
| 
       113 
128 
     | 
    
         
             
            - lib/social_feed_agregator/pinterest_reader.rb
         
     | 
| 
       114 
129 
     | 
    
         
             
            - lib/social_feed_agregator/twitter_reader.rb
         
     | 
| 
       115 
130 
     | 
    
         
             
            - lib/social_feed_agregator/version.rb
         
     |