funky 0.2.21 → 0.2.22

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: 2397e152de3f60c0a262460e52aa1d7b27335e8c
4
- data.tar.gz: 26c4fd936b720a7de07465c8a5b48717824d9fe6
3
+ metadata.gz: 1e12d14881465b91bcee78d6c9797bc8a12bc69a
4
+ data.tar.gz: 25170d89ef0c5554c562201ad37dc39141715f23
5
5
  SHA512:
6
- metadata.gz: 98772a561547e85c7826e90fcd2a7108caeedc9cad442f9071dcc4946b28c7be466657753d07f6f5cdabd323c3fb3092c79ad573ce3f7d06f975f85d1b281470
7
- data.tar.gz: c97add8c5c1bba07c683c0a31d219f15444cd248194565ac454a172ec936ee3e8bc346d25d9a7b3a57a5aa82ae1fe794e434f17f8168a641bc562af4d070fd9c
6
+ metadata.gz: 154c3a34ba50d72d6959a09153835ef52f5f5ccc22f3a07857709c8cc1e951f0a1b9c73cc63a1e0f929eb1bfce3681c84ddb1b6cdf7ad06ca24b2ee0ff468f90
7
+ data.tar.gz: 9c1cdc566145ad1f43824384babf3337bab3a7959e993ad77ed912511bbacf04469fae6f390797cce754cf5e1dee5f20b36a19379d740a09108029331be76dd6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,11 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.2.22 - 2017/05/05
10
+
11
+ * [FEATURE] Add `Funky::Page#posts`.
12
+ * [FEATURE] Add `Funky::Page#has_featured_video?`.
13
+
9
14
  ## 0.2.21 - 2017/05/03
10
15
 
11
16
  * [FEATURE] Add `Funky::Page#fan_count`.
data/README.md CHANGED
@@ -54,7 +54,7 @@ from Facebook and one to fetch page data from Facebook.
54
54
 
55
55
  ## Pages API
56
56
 
57
- ### Use #where clause to get an array of videos
57
+ ### Use #where clause to get an array of pages
58
58
 
59
59
  ```ruby
60
60
  ids = ['1487249874853741', '526533744142224']
@@ -62,7 +62,14 @@ pages = Funky::Page.where(id: ids)
62
62
  pages.first.id # => '1487249874853741'
63
63
  pages.first.name # => 'Sony Pictures'
64
64
  pages.first.username # => 'SonyPicturesGlobal'
65
+ ```
65
66
 
67
+ ### Use #posts to get an array of posts
68
+
69
+ ```ruby
70
+ page = Funky::Page.find('FullscreenInc')
71
+ posts = page.posts
72
+ posts.first.type # => 'video'
66
73
  ```
67
74
 
68
75
  ## Videos API
data/lib/funky.rb CHANGED
@@ -7,6 +7,7 @@ require 'funky/connections/api'
7
7
  require 'funky/configuration'
8
8
  require "funky/graph_root_node"
9
9
  require "funky/video"
10
+ require "funky/post"
10
11
  require "funky/page"
11
12
 
12
13
  module Funky
data/lib/funky/page.rb CHANGED
@@ -11,7 +11,7 @@ module Funky
11
11
  #
12
12
  # @return [Funky::Page] containing the data fetched by Facebook Graph API.
13
13
  def self.find(page_id)
14
- page = Funky::Connection::API.fetch("#{page_id}?fields=name,username,location,fan_count")
14
+ page = Funky::Connection::API.fetch("#{page_id}?fields=name,username,location,fan_count,featured_video")
15
15
  new(page)
16
16
  end
17
17
 
@@ -32,6 +32,21 @@ module Funky
32
32
  videos.map {|video| Video.new(video) }
33
33
  end
34
34
 
35
+ # Fetches data from Facebook Graph API and returns an array of Funky::Post
36
+ # objects belong to the caller page.
37
+ #
38
+ # @example Getting posts under a page
39
+ # page = Funky::Page.find 'FullscreenInc'
40
+ # page.posts
41
+ # # => [#<Funky::Post @data={...}>, #<Funky::Post @data={...}>]
42
+ #
43
+ # @return [Array<Funky::Post>] multiple Funky::Post objects containing data
44
+ # fetched by Facebook Graph API.
45
+ def posts
46
+ posts = Funky::Connection::API.fetch("#{id}/posts?fields=type,created_time", is_array: true)
47
+ posts.map {|post| Post.new(post)}
48
+ end
49
+
35
50
  # @note
36
51
  # For example, for www.facebook.com/platform the username is 'platform'.
37
52
  # @see https://developers.facebook.com/docs/graph-api/reference/page/
@@ -54,6 +69,11 @@ module Funky
54
69
  data[:fan_count]
55
70
  end
56
71
 
72
+ # @return [Boolean] if the Facebook page has featured_video
73
+ def has_featured_video?
74
+ !data[:featured_video].nil?
75
+ end
76
+
57
77
  # @note
58
78
  # location is a Hash that contains more specific properties such as city,
59
79
  # state, zip, etc.
data/lib/funky/post.rb ADDED
@@ -0,0 +1,13 @@
1
+ module Funky
2
+ class Post < GraphRootNode
3
+ # @return [String] the type of post.
4
+ def type
5
+ data[:type]
6
+ end
7
+
8
+ # @return [DateTime] the created time of the post.
9
+ def created_time
10
+ DateTime.parse data[:created_time]
11
+ end
12
+ end
13
+ end
data/lib/funky/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funky
2
- VERSION = "0.2.21"
2
+ VERSION = "0.2.22"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-03 00:00:00.000000000 Z
11
+ date: 2017-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,6 +125,7 @@ files:
125
125
  - lib/funky/html/page.rb
126
126
  - lib/funky/html/parser.rb
127
127
  - lib/funky/page.rb
128
+ - lib/funky/post.rb
128
129
  - lib/funky/url.rb
129
130
  - lib/funky/version.rb
130
131
  - lib/funky/video.rb