twog 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +39 -0
- data/README.textile +9 -7
- data/Rakefile +3 -2
- data/VERSION.yml +2 -2
- data/bin/twog +54 -10
- data/lib/twog/twitter_handler.rb +1 -1
- data/twog.gemspec +8 -4
- metadata +19 -6
data/History.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
=== Version 0.3.0 / 2010-04-10
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Added binary commands "--cronadd N" and "--cronrm" to install/remove
|
5
|
+
cron job that calls twog every N minutes (added dependency on whenever gem)
|
6
|
+
* added more options to binary commands for help and version (-?,-h,-v)
|
7
|
+
|
8
|
+
=== Version 0.2.2 / 2010-04-09
|
9
|
+
|
10
|
+
* Bugs
|
11
|
+
* fix README to reference "--conf" binary command instead of legacy rake task
|
12
|
+
|
13
|
+
=== Version 0.2.1 / 2010-04-08
|
14
|
+
|
15
|
+
* Features
|
16
|
+
* change creating of conf file to a binary option (--conf) instead of rake task
|
17
|
+
|
18
|
+
=== Version 0.2.0 / 2010-04-08
|
19
|
+
|
20
|
+
* Features
|
21
|
+
* setup Jeweler to autogenerate gemspec file
|
22
|
+
* pushed gem versions to rubygems.org
|
23
|
+
|
24
|
+
=== Version 0.1.0 / 2010-04-07
|
25
|
+
|
26
|
+
* Features
|
27
|
+
* Change structure to be more rubyish (modules instead of classes)
|
28
|
+
Due to no state being maintained in application
|
29
|
+
|
30
|
+
=== Version 0.0.1 / 2010-04-07
|
31
|
+
|
32
|
+
* Features
|
33
|
+
* parses RSS feed
|
34
|
+
* tweets posts that haven't been tweeted
|
35
|
+
(time > blog post time in conf yaml file)
|
36
|
+
|
37
|
+
=== Version 0.0.0 / 2010-03-31
|
38
|
+
|
39
|
+
* Initial Commit
|
data/README.textile
CHANGED
@@ -11,25 +11,27 @@ One you have those, run the command:
|
|
11
11
|
|
12
12
|
bq. twog --conf
|
13
13
|
|
14
|
-
and a hidden configuration file will be created in the your home folder (~/.twog.yaml). Once there, please fill it out with the information necessary to use this tool.
|
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
15
|
|
16
16
|
h2. Bitly API
|
17
17
|
|
18
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
19
|
|
20
|
-
Put your bit.ly username and api key into the ~/.twog.yaml file to be used in the code.
|
20
|
+
Put your bit.ly username and api key into the ~/.twog/conf.yaml file to be used in the code.
|
21
21
|
|
22
22
|
h2. cron
|
23
23
|
|
24
|
-
|
24
|
+
To install twog as a crontab job, run the command:
|
25
25
|
|
26
|
-
|
26
|
+
bq. twog --cronadd N
|
27
27
|
|
28
|
-
|
28
|
+
where N is the number of minutes you want twog to fire off every time.
|
29
29
|
|
30
|
-
|
30
|
+
To remove twog as a crontab job, run the command:
|
31
31
|
|
32
|
-
|
32
|
+
bq. twog --cronrm
|
33
|
+
|
34
|
+
"Crontab Info":http://www.unixgeeks.org/security/newbie/unix/cron-1.html for all my non-*nix bretheren.
|
33
35
|
|
34
36
|
h2. TODO
|
35
37
|
|
data/Rakefile
CHANGED
@@ -33,13 +33,14 @@ begin
|
|
33
33
|
Jeweler::Tasks.new do |s|
|
34
34
|
s.name = "twog"
|
35
35
|
s.summary = %Q{Tool to tweet blog posts}
|
36
|
-
s.email = ["jmeridth@gmail.com"
|
36
|
+
s.email = ["jmeridth@gmail.com"]
|
37
37
|
s.homepage = "http://github.com/armmer/twog"
|
38
38
|
s.description = "Tool to tweet blog posts"
|
39
|
-
s.authors = ["Jason Meridth"
|
39
|
+
s.authors = ["Jason Meridth"]
|
40
40
|
s.rubyforge_project = "twog"
|
41
41
|
s.add_dependency('twitter_oauth', '>= 0.3.3')
|
42
42
|
s.add_dependency('bitly', '>= 0.4.0')
|
43
|
+
s.add_dependency('whenever', '>= 0.4.1')
|
43
44
|
end
|
44
45
|
rescue LoadError
|
45
46
|
puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
|
data/VERSION.yml
CHANGED
data/bin/twog
CHANGED
@@ -2,22 +2,65 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
4
|
|
5
|
+
require 'tempfile'
|
5
6
|
require 'twog'
|
6
7
|
require 'optparse'
|
8
|
+
require 'whenever'
|
9
|
+
require 'fileutils'
|
10
|
+
|
11
|
+
twog_dir = "#{ENV['HOME']}/.twog"
|
12
|
+
FileUtils.mkdir_p twog_dir unless File.exists?(twog_dir)
|
13
|
+
twog_cron_schedule_file = "#{twog_dir}/schedule.rb"
|
14
|
+
twog_cron_schedule_log = "#{twog_dir}/cron.log"
|
15
|
+
twog_cron_identifier = "twog"
|
16
|
+
legacy_conf_file_name = "#{ENV['HOME']}/.twog.yaml"
|
17
|
+
twog_conf_file = "#{twog_dir}/conf.yaml"
|
7
18
|
|
8
19
|
options = {}
|
9
20
|
opts = OptionParser.new do |opts|
|
10
21
|
opts.banner = "Twog is a tool to tweet blog posts"
|
11
22
|
|
12
|
-
opts.
|
23
|
+
opts.on_tail("-h","-?","--help", "Display help") do
|
24
|
+
puts opts
|
25
|
+
exit 0
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-v", "--version", "Display current version") do
|
13
29
|
puts "Twog " + Twog.version
|
14
30
|
exit 0
|
15
31
|
end
|
32
|
+
|
33
|
+
opts.on("--cronadd N", "Add crontab job to run twog every N minutes") do |n|
|
34
|
+
twog_cron_schedule_content = <<-EOS
|
35
|
+
set :output, "#{twog_cron_schedule_log}"
|
36
|
+
every #{n}.minutes do
|
37
|
+
command "twog"
|
38
|
+
end
|
39
|
+
EOS
|
40
|
+
|
41
|
+
answer = ""
|
42
|
+
if File.exists?(twog_cron_schedule_file)
|
43
|
+
puts "Cron schedule file (#{twog_cron_schedule_file}) already exists. Overwrite? [Y/n]"
|
44
|
+
answer = gets
|
45
|
+
end
|
46
|
+
|
47
|
+
File.open(twog_cron_schedule_file, 'w') {|f| f.write(twog_cron_schedule_content) } if ["Y","y",""].include?(answer.chomp)
|
48
|
+
|
49
|
+
cron_options = {:file => twog_cron_schedule_file, :identifier => twog_cron_identifier, :update => true}
|
50
|
+
Whenever::CommandLine.execute(cron_options)
|
51
|
+
exit 0
|
52
|
+
end
|
16
53
|
|
54
|
+
opts.on("--cronrm", "Remove twog crontab job") do
|
55
|
+
File.open(twog_cron_schedule_file, 'w') {|f| f.write("") }
|
56
|
+
cron_options = {:file => twog_cron_schedule_file, :identifier => twog_cron_identifier, :update => true}
|
57
|
+
Whenever::CommandLine.execute(cron_options)
|
58
|
+
puts "Twog cron job removed successfully"
|
59
|
+
exit 0
|
60
|
+
end
|
61
|
+
|
17
62
|
opts.on("--conf", "Create default conf file") do
|
18
|
-
|
19
|
-
|
20
|
-
AUTH_CONFIG_FILE = <<-EOS
|
63
|
+
conf_file_contents = <<-EOS
|
21
64
|
rss_feed: 'http://url.com/feed.rss'
|
22
65
|
consumer_key: 'consumer key'
|
23
66
|
consumer_secret: 'consumer secret'
|
@@ -28,13 +71,14 @@ opts = OptionParser.new do |opts|
|
|
28
71
|
last_blog_post_tweeted:
|
29
72
|
EOS
|
30
73
|
|
31
|
-
if File.exists?(
|
32
|
-
|
74
|
+
FileUtils.mv(legacy_conf_file_name, twog_conf_file) if File.exists?(legacy_conf_file_name)
|
75
|
+
if File.exists?(twog_conf_file)
|
76
|
+
puts "#{twog_conf_file} already exists"
|
33
77
|
exit 0
|
34
78
|
end
|
35
79
|
|
36
|
-
File.open(
|
37
|
-
puts "Default configuration file created at
|
80
|
+
File.open(twog_conf_file, 'w') {|f| f.write(conf_file_contents) }
|
81
|
+
puts "Default configuration file created at #{twog_conf_file}"
|
38
82
|
exit 0
|
39
83
|
end
|
40
84
|
end
|
@@ -48,7 +92,7 @@ if ARGV.size > 1
|
|
48
92
|
exit(1)
|
49
93
|
end
|
50
94
|
|
51
|
-
raise "please run 'twog --conf' to create the
|
52
|
-
conf = YAML.load_file(
|
95
|
+
raise "please run 'twog --conf' to create the #{twog_conf_file} file" unless File.exists?(twog_conf_file)
|
96
|
+
conf = YAML.load_file(twog_conf_file)
|
53
97
|
|
54
98
|
Twog.run(conf)
|
data/lib/twog/twitter_handler.rb
CHANGED
@@ -46,6 +46,6 @@ module TwitterHandler
|
|
46
46
|
|
47
47
|
def update_config_file_with_latest_tweet_date(last_blog_post_tweeted, conf)
|
48
48
|
conf['last_blog_post_tweeted'] = last_blog_post_tweeted
|
49
|
-
File.open("#{ENV['HOME']}/.twog.yaml","w") { |out| out.write(conf.to_yaml) }
|
49
|
+
File.open("#{ENV['HOME']}/.twog/conf.yaml","w") { |out| out.write(conf.to_yaml) }
|
50
50
|
end
|
51
51
|
end
|
data/twog.gemspec
CHANGED
@@ -5,14 +5,14 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{twog}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Jason Meridth"
|
12
|
-
s.date = %q{2010-04-
|
11
|
+
s.authors = ["Jason Meridth"]
|
12
|
+
s.date = %q{2010-04-10}
|
13
13
|
s.default_executable = %q{twog}
|
14
14
|
s.description = %q{Tool to tweet blog posts}
|
15
|
-
s.email = ["jmeridth@gmail.com"
|
15
|
+
s.email = ["jmeridth@gmail.com"]
|
16
16
|
s.executables = ["twog"]
|
17
17
|
s.extra_rdoc_files = [
|
18
18
|
"LICENSE",
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
]
|
21
21
|
s.files = [
|
22
22
|
".gitignore",
|
23
|
+
"History.rdoc",
|
23
24
|
"LICENSE",
|
24
25
|
"README.textile",
|
25
26
|
"Rakefile",
|
@@ -57,13 +58,16 @@ Gem::Specification.new do |s|
|
|
57
58
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
58
59
|
s.add_runtime_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
59
60
|
s.add_runtime_dependency(%q<bitly>, [">= 0.4.0"])
|
61
|
+
s.add_runtime_dependency(%q<whenever>, [">= 0.4.1"])
|
60
62
|
else
|
61
63
|
s.add_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
62
64
|
s.add_dependency(%q<bitly>, [">= 0.4.0"])
|
65
|
+
s.add_dependency(%q<whenever>, [">= 0.4.1"])
|
63
66
|
end
|
64
67
|
else
|
65
68
|
s.add_dependency(%q<twitter_oauth>, [">= 0.3.3"])
|
66
69
|
s.add_dependency(%q<bitly>, [">= 0.4.0"])
|
70
|
+
s.add_dependency(%q<whenever>, [">= 0.4.1"])
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
metadata
CHANGED
@@ -4,18 +4,17 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Jason Meridth
|
13
|
-
- Joe Ocampo
|
14
13
|
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-10 00:00:00 -05:00
|
19
18
|
default_executable: twog
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -46,10 +45,23 @@ dependencies:
|
|
46
45
|
version: 0.4.0
|
47
46
|
type: :runtime
|
48
47
|
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: whenever
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 0
|
57
|
+
- 4
|
58
|
+
- 1
|
59
|
+
version: 0.4.1
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
49
62
|
description: Tool to tweet blog posts
|
50
63
|
email:
|
51
64
|
- jmeridth@gmail.com
|
52
|
-
- agilejoe@gmail.com
|
53
65
|
executables:
|
54
66
|
- twog
|
55
67
|
extensions: []
|
@@ -59,6 +71,7 @@ extra_rdoc_files:
|
|
59
71
|
- README.textile
|
60
72
|
files:
|
61
73
|
- .gitignore
|
74
|
+
- History.rdoc
|
62
75
|
- LICENSE
|
63
76
|
- README.textile
|
64
77
|
- Rakefile
|