fbwish 1.0.0 → 1.0.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.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/lib/fbwish.rb +41 -39
  3. data/lib/fbwish/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWEzZDc1ODA0ZjVjZGZkMjAzZWVkYmJiMzMwYjA4YjUzNzQ2NTU3Ng==
4
+ Mzc0OTA3MTAxMjMyMDlhYTU1ZTA4NGM0MmY5ZWU1MjYxZjA4NjhmMg==
5
5
  data.tar.gz: !binary |-
6
- ZTAwNmY3YThjNDhmMzJkZmUzMDc4N2VmZTk4NjM3YzhmYTIwMjQ4YQ==
6
+ NWRlODExZThlYzhlODAxZWQ2ZWVlYjBhNTY0MTk2OTY4NGJmYjM0NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDk4NDZiMTk4ZDY0NzkxNzJlYTU4Mjc1YjY3YWFiYmQ2ZTlhMjMwYjk0YjMw
10
- MmJkYzE4ZmM1MTgxOTYyNzM5ODIxZjY0NmEzODIwZTgzNmZhOWQ1NTZkMDNi
11
- ZGZmMDA4YmU3MjJjZTFjYjg1MjgwNWViYjg1MjJmNDY5MzAzZWE=
9
+ NjU0MzhlOWI0ZmZhMTgxNjhiMmMzMDk1NDZkY2U5ZTViZGRiYWIyNzA0NzY2
10
+ ODM2NDkxNDNmYzdiNzUxOWJlODcwYTg0NjVmNDdhMmVlOGNkYzJhOGQwYjAw
11
+ NGQ4OGExNGFlNGM2NTVkNDZjODg4MjI1YjE4Y2FkZGUyZWQ1N2Y=
12
12
  data.tar.gz: !binary |-
13
- ZmRjZGNiNjc3YTUyNjkzMDdiYTA2MjlhM2U4YjU5ZjI0MWJkOWI2YmMzODUw
14
- ZmRhZTY3OWMzMzA2ZjVmMzYwNDA4ZTMxNTVmYTU4NmQ3OTc0OWUyOGE5M2E0
15
- YjRmNTJiOGE1OTNmYTJlOTkwYWU2MDFjZDFjZGY4MWRiYzJjOTg=
13
+ YjlmYTY1ZTZhYzUwYmYzODFmYThjZWMwZWY0NTYwMDI0NmI5ZTc0NzkwZWYx
14
+ ZThlM2MwNzdkYTg1YWFhOWRiODgyNGFkMDZhYzJlN2JhZTJkNTNlMDk2NTI1
15
+ MWJhNjc4ZWQ5YTk2ZmEyY2I2ODBjNTdhYjIwYTUxODAyZmU0MWM=
data/lib/fbwish.rb CHANGED
@@ -2,57 +2,59 @@ require "fbwish/version"
2
2
  require "koala"
3
3
 
4
4
  module Fbwish
5
- def initialize(options={})
6
- required_options = [:access_token, :matcher, :replies]
7
- unspecified_options = options.keys.reject{ |key| options[key] }
5
+ class Wisher
6
+ def initialize(options={})
7
+ required_options = [:access_token, :matcher, :replies]
8
+ unspecified_options = options.keys.reject{ |key| options[key] }
8
9
 
9
- unless unspecified_options.empty?
10
- raise ArgumentError("Following options are required: #{unspecified_options.join(', ')}")
11
- end
10
+ unless unspecified_options.empty?
11
+ raise ArgumentError("Following options are required: #{unspecified_options.join(', ')}")
12
+ end
12
13
 
13
- self.graph = Koala::Facebook::API.new(options[:access_token])
14
- self.matcher = options[:matcher]
15
- self.replies = options[:replies]
16
- end
14
+ self.graph = Koala::Facebook::API.new(options[:access_token])
15
+ self.matcher = options[:matcher]
16
+ self.replies = options[:replies]
17
+ end
17
18
 
18
- def wish_em_all!
19
- wishes = nil
19
+ def wish_em_all!
20
+ wishes = nil
20
21
 
21
- 1.upto(13) do |idx|
22
- wishes = wishes.next_page rescue graph.get_connections('me', 'feed')
22
+ 1.upto(13) do |idx|
23
+ wishes = wishes.next_page rescue graph.get_connections('me', 'feed')
23
24
 
24
- wishes.each do |wish|
25
- like_and_comment(wish)
25
+ wishes.each do |wish|
26
+ like_and_comment(wish)
27
+ end
26
28
  end
27
29
  end
28
- end
29
30
 
30
- private
31
- def like(wish)
32
- graph.put_like(wish['id'])
33
- end
31
+ private
32
+ def like(wish)
33
+ graph.put_like(wish['id'])
34
+ end
34
35
 
35
- def comment(wish, replies)
36
- # If it is an array pick random else pick itself(assuming it is a string)
37
- reply = replies.is_a?(Array) ?
38
- replies[rand(replies.length-1)] :
39
- replies
40
- graph.put_comment(wish['id'], reply)
41
- end
36
+ def comment(wish, replies)
37
+ # If it is an array pick random else pick itself(assuming it is a string)
38
+ reply = replies.is_a?(Array) ?
39
+ replies[rand(replies.length-1)] :
40
+ replies
41
+ graph.put_comment(wish['id'], reply)
42
+ end
42
43
 
43
- def like_and_comment(wish)
44
- if matcher.is_a?(Object)
45
- matcher.each do |locale, regex|
46
- if regex.match(wish['message'])
44
+ def like_and_comment(wish)
45
+ if matcher.is_a?(Object)
46
+ matcher.each do |locale, regex|
47
+ if regex.match(wish['message'])
48
+ like(wish)
49
+ comment(wish, replies[locale])
50
+ end
51
+ end
52
+ else
53
+ if matcher.match(wish['message'])
47
54
  like(wish)
48
- comment(wish, replies[locale])
55
+ comment(wish, replies)
49
56
  end
50
57
  end
51
- else
52
- if matcher.match(wish['message'])
53
- like(wish)
54
- comment(wish, replies)
55
- end
56
58
  end
57
- end
59
+ end
58
60
  end
@@ -1,3 +1,3 @@
1
1
  module Fbwish
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbwish
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mudassir Ali