twog 0.3.0 → 0.3.5
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 +7 -0
- data/.github/workflows/ruby.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +120 -0
- data/History.rdoc +35 -4
- data/LICENSE +3 -1
- data/README.md +77 -0
- data/Rakefile +15 -20
- data/VERSION.yml +3 -3
- data/bin/twog +36 -14
- data/lib/twog.rb +31 -21
- data/lib/twog/blog_posts_handler.rb +9 -7
- data/lib/twog/post.rb +23 -0
- data/lib/twog/rss_entry_to_twog_post_mapper.rb +7 -0
- data/lib/twog/rss_parser.rb +11 -9
- data/lib/twog/twitter_handler.rb +32 -44
- data/spec/spec_helper.rb +63 -59
- data/spec/twog/blog_posts_handler_spec.rb +38 -0
- data/spec/twog/post_spec.rb +77 -0
- data/spec/twog/rss_entry_to_twog_post_mapper_spec.rb +32 -0
- data/spec/twog/rss_parser_spec.rb +17 -0
- data/spec/{twitter_handler_spec.rb → twog/twitter_handler_spec.rb} +25 -27
- data/spec/twog/twog_spec.rb +43 -0
- data/twog.gemspec +64 -56
- metadata +170 -85
- data/.gitignore +0 -3
- data/README.textile +0 -49
- data/spec/blog_posts_handler_spec.rb +0 -33
- data/spec/rss_parser_spec.rb +0 -18
- data/spec/twog_spec.rb +0 -40
data/.gitignore
DELETED
data/README.textile
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
h1. twog
|
2
|
-
|
3
|
-
h2. Install
|
4
|
-
|
5
|
-
sudo gem install twog
|
6
|
-
|
7
|
-
h2. OAuth
|
8
|
-
|
9
|
-
Please read "this":http://blog.jasonmeridth.com/2010/04/02/oauth.html if you want to know how to get your Twitter OAuth consumer key/secret and access token/secret.
|
10
|
-
One you have those, run the command:
|
11
|
-
|
12
|
-
bq. twog --conf
|
13
|
-
|
14
|
-
and a hidden configuration file will be created in the your home folder (~/.twog/conf.yaml). Once there, please fill it out with the information necessary to use this tool.
|
15
|
-
|
16
|
-
h2. Bitly API
|
17
|
-
|
18
|
-
In order to use Bitly for URL shortening, you'll need to go to http://bit.ly and click the "Sign Up":http://bit.ly/account/register?rd=/ link on the top right and get an account. Once you are logged-in you click the "Account":http://bit.ly/account link in the same top right area. You will see your API Key in the middle of the page.
|
19
|
-
|
20
|
-
Put your bit.ly username and api key into the ~/.twog/conf.yaml file to be used in the code.
|
21
|
-
|
22
|
-
h2. cron
|
23
|
-
|
24
|
-
To install twog as a crontab job, run the command:
|
25
|
-
|
26
|
-
bq. twog --cronadd N
|
27
|
-
|
28
|
-
where N is the number of minutes you want twog to fire off every time.
|
29
|
-
|
30
|
-
To remove twog as a crontab job, run the command:
|
31
|
-
|
32
|
-
bq. twog --cronrm
|
33
|
-
|
34
|
-
"Crontab Info":http://www.unixgeeks.org/security/newbie/unix/cron-1.html for all my non-*nix bretheren.
|
35
|
-
|
36
|
-
h2. TODO
|
37
|
-
|
38
|
-
Please check the TODO file for items that are to be done in the near future.
|
39
|
-
|
40
|
-
h2. Technical Reviewers
|
41
|
-
|
42
|
-
Chris MacGown ("ChristopherMacGown":http://github.com/ChristopherMacGown)
|
43
|
-
Matt Dietz ("cerberus98":http://github.com/cerberus98)
|
44
|
-
Paul Voccio ("pvo":http://github.com/pvo)
|
45
|
-
Joe Ocampo ("agilejoe":http://github.com/agilejoe)
|
46
|
-
|
47
|
-
h2. Copyright
|
48
|
-
|
49
|
-
Copyright (c) 2010 Jason Meridth. See LICENSE for details.
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe BlogPostsHandler do
|
4
|
-
include TwogSpecHelper
|
5
|
-
include BlogPostsHandler
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
entry = rss_entry
|
9
|
-
entry.updated.content = Time.new
|
10
|
-
@posts = [entry]
|
11
|
-
@last_blog_post_tweeted = test_conf['last_blog_post_tweeted']
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should determine that there is one new blog post to tweet" do
|
15
|
-
posts = get_new_blog_posts(@posts, @last_blog_post_tweeted)
|
16
|
-
posts.length.should == 1
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should return zero if posts are nil" do
|
20
|
-
posts = get_new_blog_posts(nil, @last_blog_post_tweeted)
|
21
|
-
posts.length.should == 0
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return zero if no posts are passed" do
|
25
|
-
posts = get_new_blog_posts([], @last_blog_post_tweeted)
|
26
|
-
posts.length.should == 0
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should return the posts if there is no last_blog_post_tweeted in the conf file" do
|
30
|
-
posts = get_new_blog_posts(@posts, nil)
|
31
|
-
posts.length.should == 1
|
32
|
-
end
|
33
|
-
end
|
data/spec/rss_parser_spec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe RssParser do
|
4
|
-
include TwogSpecHelper
|
5
|
-
include RssParser
|
6
|
-
|
7
|
-
it "should throw exception if rss_feed isn't provided" do
|
8
|
-
lambda { parse(nil) }.should raise_error('RSS feed missing')
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should read the rss_feed_url and parse the items" do
|
12
|
-
self.stub!(:open).and_return(rss_feed_url_content)
|
13
|
-
items = parse(test_conf)
|
14
|
-
items.length.should == 1
|
15
|
-
items[0].title.content.should == "Pair Programming"
|
16
|
-
items[0].link.href.should == "http://blog.jasonmeridth.com/2009/01/29/pair-programming.html"
|
17
|
-
end
|
18
|
-
end
|
data/spec/twog_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe Twog do
|
4
|
-
include TwogSpecHelper
|
5
|
-
|
6
|
-
it "should not tweet if there are no new blog posts" do
|
7
|
-
Twog.stub!(:parse).with(test_conf['rss_feed']).and_return(1)
|
8
|
-
Twog.stub!(:get_new_blog_posts).with(1, test_conf['last_blog_post_tweeted']).and_return([])
|
9
|
-
Twog.stub!(:tweet).and_return(1)
|
10
|
-
result = Twog.run(test_conf)
|
11
|
-
result.should be nil
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should parse the rss feed and tweet new blog posts" do
|
15
|
-
entry = rss_entry
|
16
|
-
Twog.stub!(:parse).with(test_conf['rss_feed']).and_return(1)
|
17
|
-
Twog.stub!(:get_new_blog_posts).with(1, test_conf['last_blog_post_tweeted']).and_return([entry])
|
18
|
-
Twog.stub!(:get_bitly_from)
|
19
|
-
Twog.stub!(:tweet).and_return(1)
|
20
|
-
result = Twog.run(test_conf)
|
21
|
-
result.should == 1
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should return nil if bitly username is nil" do
|
25
|
-
conf = test_conf
|
26
|
-
conf['bitly_username'] = nil
|
27
|
-
Twog.get_bitly_from(conf).should be nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should return nil if bitly api key is nil" do
|
31
|
-
conf = test_conf
|
32
|
-
conf['bitly_username'] = nil
|
33
|
-
Twog.get_bitly_from(conf).should be nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return nil if bitly api key is nil" do
|
37
|
-
Bitly.stub!(:new).and_return("hello")
|
38
|
-
Twog.get_bitly_from(test_conf).should == "hello"
|
39
|
-
end
|
40
|
-
end
|