-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
executable file
·82 lines (56 loc) · 2.65 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
= r2_tweet2
You might be wondering why another Twitter gem/plugin...let me highlight why you should give mine a whirl.
1.) This Twitter plugin doesn't require any libraries with C bindings. This is good news for those you who
are constrained to JRuby.
2.) This Twitter plugin doesn't force you to use additional plugins or gems.
My viewpoint is I want Twitter without crufty suck/bloat-ware
3.) This Twitter plugin has some nice hooks for ActiveRecord models or just plain
classes that enable "tweets" based on callbacks.
4.) I am making an on going effort to add more "bot" like functionality to enable natural language
processing.
I'd like to thank Susan Potter author of the twitter4r gem and John Nunemaker author of the twitter gem
since I took inspiration from their efforts for various parts of my plugin.
== Installation
ruby script/plugin install git://github.com/techwhizbang/r2_tweet2.git
= Configuration
Create a r2_tweet2.yml in your RAILS_ROOT/config directory with your default user
settings
== Usage
=Search API
#Example 1 - Construct a single user query with a jorts as keywords and a hash
search = Twitter::Search.new
search.containing("jorts").from("techwhizbang").hashed("jorts")
search_results = search.fetch
#Example 2 - Construct a multi-user OR query to pull from many users
search2 = Twitter::Search.new
search2.containing("ruby on rails").from("rails", "OR").from("techwhizbang", "OR").from("daveollie", "OR")
search_results2 = search2.fetch
#There are literally thousands of combinations for searches so crack open the twitter/search.rb
=Status API
#Example 1 - Construct an update with the default user and password config
status_result = Twitter::Status.new.update("this is a really stupid tweet")
#Example 2 - Construct an update with user and password as args
status_result2 = Twitter::Status.new("user", "password").update("blah blah blah")
=ActiveRecord/Class Methods
#send a status update/tweet when a new post is saved based on attributes or instance methods
class Post < ActiveRecord::Base
r2_tweet2(:attributes => [:message], :callbacks => [:after_save])
end
class Post < ActiveRecord::Base
r2_tweet2(:attributes => [:formatted_message], :callbacks => [:after_save])
def formatted_message
"This is the formatted message #{message}"
end
end
class PlainOldClass
include Twitter::R2Tweet2
attr_accessor :author, :brief
r2_tweet2(:attributes => ['author, 'brief'])
def update
#...do whatever logic
tweet
end
end
=== Other
Problems, comments, and suggestions all welcome. [email protected] or visit my blog
http://techwhizbang.com