facegroup 0.2.0 → 0.2.1

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: dc7ee158ae35fa2c11b34facde81784382b7d973
4
- data.tar.gz: 570fad708f94c07ddba5f29f1521d988e3e935e9
3
+ metadata.gz: c009373d0d3128abc9ab870314d7ee411736f4f4
4
+ data.tar.gz: 8aab07878d2451753b2e368b2f1b516f21c16121
5
5
  SHA512:
6
- metadata.gz: 693ae084c9d9cace16f4a760d46e826212ad0b33988e74691405a09f9790b7a02290769602a137d09f8e32434c8265da7286f63d211933428bfa641844cbea6a
7
- data.tar.gz: 1cfda29bc1824050eba0a4fce0c47be5694a72692f60a85c2641563e2fc4ce7af4a487ef223d0d797c21431ef901feb60cfac4624cd6816f654ec9a5ae07eba0
6
+ metadata.gz: f7dbfaa8bb444e2fa038a89fda5a3da23bed88fd1e3008856fd4bdb0aa28c68472e63197e97594e66ca26210a65c0d43db0a598016c7cd3c269dbf32b727e348
7
+ data.tar.gz: 90f8d5919659ce6dfcc235a4a79f398835f30ffe064e923a3351335de02f54520fbefafc7f6b81232d869ecd0e622551169c5008c83dad065f1ffe698d8ef8b3
data/bin/facegroup CHANGED
@@ -1,21 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w(.. lib))
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
4
  require 'facegroup'
5
5
 
6
- group_id = ARGV[0] || ENV['FB_GROUP_ID']
7
- unless group_id
8
- puts 'USAGE: facegroup [group_id]'
9
- exit(1)
10
- end
11
-
12
- group = FaceGroup::Group.find(id: group_id)
13
-
14
- puts group.name
15
- puts Array.new(group.name.length) { '-' }.join
16
- group.feed.postings.first(3).each.with_index do |post, index|
17
- print "#{index + 1}: "
18
- puts post.message ? post.message : '(blank)'
19
- puts "Attached: #{post.attachment.url}" if post.attachment
20
- puts
21
- end
6
+ puts FaceGroup::Runner.run!(ARGV)
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FaceGroup
4
+ # Executable code for file(s) in bin/ folder
5
+ class Runner
6
+ def self.run!(args)
7
+ group_id = args[0] || ENV['FB_GROUP_ID']
8
+ unless group_id
9
+ puts 'USAGE: facegroup [group_id]'
10
+ exit(1)
11
+ end
12
+
13
+ group = FaceGroup::Group.find(id: group_id)
14
+
15
+ output_info(group)
16
+ end
17
+
18
+ def self.output_info(group)
19
+ name = group.name
20
+ separator = Array.new(group.name.length) { '-' }.join
21
+ group_info =
22
+ group.feed.postings.first(3).map.with_index do |post, index|
23
+ posting_info(post, index)
24
+ end.join
25
+
26
+ [name, separator, group_info].join("\n")
27
+ end
28
+
29
+ def self.posting_info(post, index)
30
+ [
31
+ "#{index + 1}: ",
32
+ message_output(post.message),
33
+ 'Attached: ' + attachment_output(post.attachment),
34
+ "\n\n"
35
+ ].join
36
+ end
37
+
38
+ def self.message_output(message)
39
+ message ? message : '(blank)'
40
+ end
41
+
42
+ def self.attachment_output(attachment)
43
+ attachment ? attachment.url.to_s : '(none)'
44
+ end
45
+ end
46
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FaceGroup
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
@@ -78,4 +78,9 @@ describe 'FaceGroup specifications' do
78
78
  retrieved.attachment.description.must_equal attachment['description']
79
79
  retrieved.attachment.url.must_match 'tutorialzine'
80
80
  end
81
+
82
+ it 'should run the executable file' do
83
+ output = FaceGroup::Runner.run!([ENV['FB_GROUP_ID']])
84
+ output.split("\n").length.must_be :>, 5
85
+ end
81
86
  end
@@ -427,4 +427,55 @@ http_interactions:
427
427
  constants.stuffy.activism.","url":"http:\/\/www.facebook.com\/l.php?u=http\u00253A\u00252F\u00252Fqz.com\u00252F705273\u00252Fmongolia-is-changing-all-its-addresses-to-three-word-phrases\u00252F&h=JAQFMAksP&s=1&enc=AZN02PMmsYT-iK2B1lVh0qeNY7OGxEegLsCoQEytDDBIJgskc9gKuVUVI0SOHPwA5RbLYjALZVY9tHuLS0F0_86P","media":{"image":{"height":720,"src":"https:\/\/external.xx.fbcdn.net\/safe_image.php?d=AQBCzb8yBioJKKug&w=720&h=720&url=https\u00253A\u00252F\u00252Fqzprod.files.wordpress.com\u00252F2016\u00252F06\u00252Fjune-13-rtx12cmt-e1465820880769.jpg\u00253Fquality\u00253D80\u002526strip\u00253Dall\u002526w\u00253D1600&cfs=1","width":720}}}]}}],"paging":{"previous":"https:\/\/graph.facebook.com\/v2.6\/150352985174571\/feed?fields=name,message,updated_time,created_time,attachments\u00257Btitle,description,url,media\u00257D&since=1476952146&access_token=<ACCESS_TOKEN>&limit=25&__paging_token=enc_AdDRT3FRqddWHdExcEnxBuffZCipxhESZBM93TZAL1VTlcfHQr3aWV1rq23kG3uiPxcZCwvQeCiZC8fEJvrhCQFCo6fyMk1u9HaT3EXZBICgj897coSwZDZD&__previous=1","next":"https:\/\/graph.facebook.com\/v2.6\/150352985174571\/feed?fields=name,message,updated_time,created_time,attachments\u00257Btitle,description,url,media\u00257D&access_token=<ACCESS_TOKEN>&limit=25&until=1466917498&__paging_token=enc_AdBmZAsUzYqHLvymmCwfLv8K48KqrS6LGOHvgiJYkb7Brd7RrwyTZA8gMCDGPWYdza3XzU34YBZB7Xn0iN7WcT9cLhvOIFzhb8ZCDP8F35OnaNwZBtQZDZD"}}}'
428
428
  http_version:
429
429
  recorded_at: Wed, 26 Oct 2016 16:55:01 GMT
430
+ - request:
431
+ method: get
432
+ uri: https://graph.facebook.com/1?access_token=<ACCESS_TOKEN_ESCAPED>&fields=id,name,feed%7Bname,message,updated_time,created_time,attachments%7Btitle,description,url,media%7D%7D
433
+ body:
434
+ encoding: US-ASCII
435
+ string: ''
436
+ headers:
437
+ Connection:
438
+ - close
439
+ Host:
440
+ - graph.facebook.com
441
+ User-Agent:
442
+ - http.rb/2.0.3
443
+ response:
444
+ status:
445
+ code: 404
446
+ message: Not Found
447
+ headers:
448
+ Www-Authenticate:
449
+ - 'OAuth "Facebook Platform" "not_found" "(#803) Some of the aliases you requested
450
+ do not exist: 1"'
451
+ Access-Control-Allow-Origin:
452
+ - "*"
453
+ Pragma:
454
+ - no-cache
455
+ Cache-Control:
456
+ - no-store
457
+ Facebook-Api-Version:
458
+ - v2.6
459
+ Expires:
460
+ - Sat, 01 Jan 2000 00:00:00 GMT
461
+ Content-Type:
462
+ - text/javascript; charset=UTF-8
463
+ X-Fb-Trace-Id:
464
+ - AGqrqQnTSPL
465
+ X-Fb-Rev:
466
+ - '2652207'
467
+ X-Fb-Debug:
468
+ - A/XhkwqFNTd7k4IulSk3nhSvx9O8hz+xkGWl1WczfxUq35DFTf1ziedwF0YdlzEB4D/LAnTfOf5/SCIZOe2vVw==
469
+ Date:
470
+ - Sun, 30 Oct 2016 15:57:05 GMT
471
+ Connection:
472
+ - close
473
+ Content-Length:
474
+ - '142'
475
+ body:
476
+ encoding: UTF-8
477
+ string: '{"error":{"message":"(#803) Some of the aliases you requested do not
478
+ exist: 1","type":"OAuthException","code":803,"fbtrace_id":"AGqrqQnTSPL"}}'
479
+ http_version:
480
+ recorded_at: Sun, 30 Oct 2016 15:57:07 GMT
430
481
  recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facegroup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soumya Ray
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-27 00:00:00.000000000 Z
11
+ date: 2016-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http
@@ -190,6 +190,7 @@ files:
190
190
  - lib/facegroup/feed.rb
191
191
  - lib/facegroup/group.rb
192
192
  - lib/facegroup/posting.rb
193
+ - lib/facegroup/runner.rb
193
194
  - lib/facegroup/version.rb
194
195
  - spec/facegroup_spec.rb
195
196
  - spec/fixtures/cassettes/facebook_api.yml