facebook-cli 1.1.0 → 1.2.0

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: 85e2fd8af22474966be9457355cc77a65c17d9a8
4
- data.tar.gz: a2bef3fc01f49f721a2a35e8ea44130493a83cda
3
+ metadata.gz: b43e88b0462f22b153e6b31aa3f14ab6e3129aab
4
+ data.tar.gz: 3b39f775a897e4e5c9ab3cb7bb0310ddbcd28092
5
5
  SHA512:
6
- metadata.gz: 4e4fb9deef5f748bb72d23f088bd1f8d2e1c8bb032709cb9c57717fb7bbe88339c3d0ca6e23ab950e7be74540799df3494559d07a6584778fa206da5be430329
7
- data.tar.gz: 6a6dfbd622ada5a5627e00729ec08a0c315344bb34cf97985a2063c4df3a7b11ae67237e8da7f709e60fe9599296373758c425a0cd8fdc38a1e05a796a5196fa
6
+ metadata.gz: 8730da7429b2dcb7c57677bb450083430fbac028962cc042ff0be74031dd9eaf7f6d075918d231be046ad6f7368a8cd77313f35cf3c4d6fb87deb726a30c9570
7
+ data.tar.gz: 4149d6345806ee902dfb37947f485a80bd7d1c50a548d02fc0d1e542de14b93f93b75c58e568d2836a2e829868b1f3d183b3f178269dcac21b9d1802e4739cbe
data/lib/fbcli.rb CHANGED
@@ -11,7 +11,7 @@ include GLI::App
11
11
 
12
12
  program_desc "Facebook command line interface"
13
13
 
14
- version '1.1.0'
14
+ version '1.2.0'
15
15
 
16
16
  flag [:token], :desc => 'Provide Facebook access token', :required => false
17
17
  flag [:format], :desc => 'Output format (values: text, html)', :default_value => "text"
@@ -44,7 +44,9 @@ formattable_commands = [
44
44
  :feed,
45
45
  :friends,
46
46
  :photos,
47
- :photosof
47
+ :photosof,
48
+ :events,
49
+ :pastevents
48
50
  ]
49
51
 
50
52
  def save_config
@@ -208,4 +210,45 @@ command :photosof do |c|
208
210
  end
209
211
  end
210
212
 
213
+ def list_events(global_options, past = false)
214
+ now = Time.new
215
+
216
+ FBCLI::page_items global_options, "events" do |item|
217
+ starts = Time.parse(item['start_time'])
218
+
219
+ if (past and starts < now) ^ (not past and starts > now)
220
+ unless item['end_time'].nil?
221
+ ends = Time.parse(item['end_time'])
222
+ duration = ends - starts
223
+ end
224
+
225
+ FBCLI::write "#{item['name']} (#{item['id']})"
226
+ FBCLI::write
227
+ FBCLI::write "Location: #{item['place']['name']}" unless item['place'].nil?
228
+ FBCLI::write "Date: #{FBCLI::date(item['start_time'])}"
229
+ FBCLI::write "Duration: #{duration / 3600} hours" if defined?(duration) and not duration.nil?
230
+ FBCLI::write "RSVP: #{item['rsvp_status'].sub(/unsure/, "maybe")}"
231
+ FBCLI::write
232
+ FBCLI::write FBCLI::link "events/#{item['id']}"
233
+ FBCLI::write
234
+ FBCLI::write item['description']
235
+ FBCLI::write "---------------------------------"
236
+ end
237
+ end
238
+ end
239
+
240
+ desc "List your upcoming events"
241
+ command :events do |c|
242
+ c.action do |global_options,options,args|
243
+ list_events global_options
244
+ end
245
+ end
246
+
247
+ desc "List your past events"
248
+ command :pastevents do |c|
249
+ c.action do |global_options,options,args|
250
+ list_events global_options, true
251
+ end
252
+ end
253
+
211
254
  exit run(ARGV)
data/lib/fbcli/auth.rb CHANGED
@@ -9,7 +9,7 @@ module FBCLI
9
9
  def self.listen_for_auth_code(port, app_id, app_secret)
10
10
  uri = "https://www.facebook.com/dialog/oauth?client_id=#{app_id}" +
11
11
  "&redirect_uri=http://localhost:#{port}/" +
12
- "&scope=user_likes,user_friends,user_photos,user_posts"
12
+ "&scope=user_likes,user_friends,user_photos,user_posts,user_events"
13
13
 
14
14
  puts "Please open: #{uri}"
15
15
  puts
data/lib/fbcli/format.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module FBCLI
2
2
  # Facebook returns dates in ISO 8601 format
3
3
  def self.date(fb_date)
4
- Time.parse(fb_date).httpdate
4
+ Time.parse(fb_date).localtime.rfc2822
5
5
  end
6
6
 
7
7
  def self.link(path, format = $format)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facebook-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ildar Sagdejev