twog 0.3.0 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 68b919f5060d59cbf20d453287f3d61838f70dfe84e83b839d5c114fe411a985
4
+ data.tar.gz: 27638906b18b79a26ea1cb31522d234d87c6af689e3be3dfa72e8365fdb322c7
5
+ SHA512:
6
+ metadata.gz: ee3112d6823b9a5fc55af44798d55f0fa5fbabc6639f8564e14d1c5d449527b607e18c4cb5857ef5ce880ac075df01c0c12108e448b4b36e9c0f6046ee218a31
7
+ data.tar.gz: e3321b87f18f9c38ad48ca08110a8e81c057229f3f79fc1cafd8f558e57fb02ac3c7b31cee82d1ebe2bf0bdaa0399022b1a1804a112c1216cd6d43b21e2844a6
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v1
12
+ - name: Set up Ruby 2.7
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.7
16
+ - name: Build and test with Rspec
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rspec
@@ -0,0 +1 @@
1
+ twog
@@ -0,0 +1 @@
1
+ 2.7.1
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'http://rubygems.org'
2
+ ruby '2.7.1'
3
+
4
+ gem 'rack', '~>2.0.6'
5
+ gem 'nokogiri', '>= 1.10.4'
6
+ gem 'twitter_oauth', '>=0.3.3'
7
+ gem 'bitly', '>=0.4.0'
8
+ gem 'whenever', '>=0.4.1'
9
+ gem 'activesupport', '>=2.3.5'
10
+ gem 'juwelier', '>= 2.4.9'
11
+
12
+ group :development, :test do
13
+ gem 'rake'
14
+ gem 'rspec', '>=2.0.0.beta.22'
15
+ gem 'simplecov'
16
+ end
@@ -0,0 +1,120 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (6.0.3.1)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (>= 0.7, < 2)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ zeitwerk (~> 2.2, >= 2.2.2)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ bitly (2.0.0)
13
+ oauth2 (>= 0.5.0, < 2.0)
14
+ builder (3.2.4)
15
+ chronic (0.10.2)
16
+ concurrent-ruby (1.1.6)
17
+ descendants_tracker (0.0.4)
18
+ thread_safe (~> 0.3, >= 0.3.1)
19
+ diff-lcs (1.3)
20
+ docile (1.3.2)
21
+ faraday (0.9.2)
22
+ multipart-post (>= 1.2, < 3)
23
+ git (1.7.0)
24
+ rchardet (~> 1.8)
25
+ github_api (0.18.2)
26
+ addressable (~> 2.4)
27
+ descendants_tracker (~> 0.0.4)
28
+ faraday (~> 0.8)
29
+ hashie (~> 3.5, >= 3.5.2)
30
+ oauth2 (~> 1.0)
31
+ hashie (3.6.0)
32
+ highline (2.0.3)
33
+ i18n (1.8.2)
34
+ concurrent-ruby (~> 1.0)
35
+ json (2.3.0)
36
+ juwelier (2.4.9)
37
+ builder
38
+ bundler
39
+ git
40
+ github_api
41
+ highline
42
+ kamelcase (~> 0)
43
+ nokogiri
44
+ psych
45
+ rake
46
+ rdoc
47
+ semver2
48
+ jwt (2.2.1)
49
+ kamelcase (0.0.2)
50
+ semver2 (~> 3)
51
+ mime-types (2.99.3)
52
+ mini_portile2 (2.4.0)
53
+ minitest (5.14.1)
54
+ multi_json (1.14.1)
55
+ multi_xml (0.6.0)
56
+ multipart-post (2.1.1)
57
+ nokogiri (1.10.9)
58
+ mini_portile2 (~> 2.4.0)
59
+ oauth (0.5.4)
60
+ oauth2 (1.4.4)
61
+ faraday (>= 0.8, < 2.0)
62
+ jwt (>= 1.0, < 3.0)
63
+ multi_json (~> 1.3)
64
+ multi_xml (~> 0.5)
65
+ rack (>= 1.2, < 3)
66
+ psych (3.1.0)
67
+ public_suffix (4.0.5)
68
+ rack (2.0.9)
69
+ rake (13.0.1)
70
+ rchardet (1.8.0)
71
+ rdoc (6.2.1)
72
+ rspec (3.9.0)
73
+ rspec-core (~> 3.9.0)
74
+ rspec-expectations (~> 3.9.0)
75
+ rspec-mocks (~> 3.9.0)
76
+ rspec-core (3.9.2)
77
+ rspec-support (~> 3.9.3)
78
+ rspec-expectations (3.9.2)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.9.0)
81
+ rspec-mocks (3.9.1)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.9.0)
84
+ rspec-support (3.9.3)
85
+ semver2 (3.4.2)
86
+ simplecov (0.18.5)
87
+ docile (~> 1.1)
88
+ simplecov-html (~> 0.11)
89
+ simplecov-html (0.12.2)
90
+ thread_safe (0.3.6)
91
+ twitter_oauth (0.4.94)
92
+ json (>= 1.8.0)
93
+ mime-types (>= 1.16)
94
+ oauth (>= 0.4.7)
95
+ tzinfo (1.2.7)
96
+ thread_safe (~> 0.1)
97
+ whenever (1.0.0)
98
+ chronic (>= 0.6.3)
99
+ zeitwerk (2.3.0)
100
+
101
+ PLATFORMS
102
+ ruby
103
+
104
+ DEPENDENCIES
105
+ activesupport (>= 2.3.5)
106
+ bitly (>= 0.4.0)
107
+ juwelier (>= 2.4.9)
108
+ nokogiri (>= 1.10.4)
109
+ rack (~> 2.0.6)
110
+ rake
111
+ rspec (>= 2.0.0.beta.22)
112
+ simplecov
113
+ twitter_oauth (>= 0.3.3)
114
+ whenever (>= 0.4.1)
115
+
116
+ RUBY VERSION
117
+ ruby 2.7.1p83
118
+
119
+ BUNDLED WITH
120
+ 2.1.4
@@ -1,19 +1,50 @@
1
+ === Version 0.3.4 / 2020-03-15
2
+
3
+ * Security
4
+ * Update gem dependencies due to known CVEs
5
+
6
+ === Version 0.3.3 / 2019-09-23
7
+
8
+ * Enhancements
9
+ * Update to latest rspec mock formatting
10
+
11
+ * Security
12
+ * Update gem dependencies due to known CVEs
13
+
14
+ === Version 0.3.2 / 2013-01-29
15
+
16
+ * Enhancements
17
+ * Fix github repo links for new github username s/armmer/jmeridth
18
+
19
+ === Version 0.3.1 / 2010-04-16
20
+
21
+ * Enhancements
22
+ * Added executable command "-o/--output" to output what blog posts
23
+ will be tweeted
24
+ * Added activesupport gem dependency (needed by whatever gem)
25
+ * Restructured app to be mainly Ruby modules
26
+
27
+ * Bugs
28
+ * Added mapping of rss entries to Twog::Post due to rss entries
29
+ having multiple ways to get date, title, link
30
+
31
+
1
32
  === Version 0.3.0 / 2010-04-10
2
33
 
3
34
  * Enhancements
4
- * Added binary commands "--cronadd N" and "--cronrm" to install/remove
35
+ * Added exectable commands "--cronadd N" and "--cronrm" to install/remove
5
36
  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)
37
+ * added more options to exectable commands for help and version (-?,-h,-v)
7
38
 
8
39
  === Version 0.2.2 / 2010-04-09
9
40
 
10
41
  * Bugs
11
- * fix README to reference "--conf" binary command instead of legacy rake task
42
+ * fix README to reference "--conf" exectable command instead of legacy rake task
12
43
 
13
44
  === Version 0.2.1 / 2010-04-08
14
45
 
15
46
  * Features
16
- * change creating of conf file to a binary option (--conf) instead of rake task
47
+ * change creating of conf file to a exectable option (--conf) instead of rake task
17
48
 
18
49
  === Version 0.2.0 / 2010-04-08
19
50
 
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2010 Jason Meridth
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2019 Jason Meridth
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
@@ -0,0 +1,77 @@
1
+ # Twog
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/twog.png)](http://badge.fury.io/rb/twog)
4
+ [![CI Status](https://github.com/jmeridth/twog/workflows/Ruby/badge.svg)](https://github.com/jmeridth/twog/actions)
5
+ [![Code Climate](https://codeclimate.com/github/jmeridth/twog.png)](https://codeclimate.com/github/jmeridth/twog)
6
+
7
+ By Jason Meridth
8
+
9
+ Twog is a simple application that parses an RSS feed and will tweet any posts it hasn't already tweeted. Once you obtain OAuth access to a twitter account and provide it in the configuration and run Twog, it will tweet a prefix, your blog title, and a URL of the post. There are also options of using Bit.ly for URL shortening and you can install Twog as a cron job for automated polling.
10
+
11
+ ## Install
12
+
13
+ sudo gem install twog
14
+
15
+ ## Writing to Twitter With OAuth
16
+
17
+ 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.
18
+
19
+ One you have those, run the command:
20
+
21
+ twog --conf
22
+
23
+ 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.
24
+
25
+ ## Seeing What Will Be Tweeted
26
+
27
+ To see what will be Tweeted before it is, type:
28
+
29
+ twog -o
30
+
31
+ or
32
+
33
+ twog --output
34
+
35
+ ## Shortening Blog Post URLs With Bitly API
36
+
37
+ In order to use Bitly for URL shortening, you'll need to go to [http://bit.ly](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.
38
+
39
+ Put your bit.ly username and api key into the ~/.twog/conf.yaml file to be used in the code.
40
+
41
+ ## Automating Polling With Cron
42
+
43
+ To install twog as a crontab job, run the command:
44
+
45
+ twog --cronadd N
46
+
47
+ where N is the number of minutes you want twog to fire off every time.
48
+
49
+ To remove twog as a crontab job, run the command:
50
+
51
+ twog --cronrm
52
+
53
+ [Crontab Info](http://www.unixgeeks.org/security/newbie/unix/cron-1.html) for all my non-*nix bretheren.
54
+
55
+ ### Runtime Dependencies
56
+
57
+ * TwitterOauth: Writes tweets to Twitter (Ruby)
58
+ * Whenever: Sets up cron jobs (Ruby)
59
+ * Bitly: Shortens URLs (Ruby)
60
+
61
+ ## Developer Dependencies
62
+
63
+ * RSpec: Test and Mocking framework (Ruby)
64
+
65
+ ## TODO
66
+
67
+ Please check the [issues](http://github.com/jmeridth/twog/issues) on Github for future features or bugs that need to be fixed
68
+
69
+ ## Contributors
70
+
71
+ * Matt Dietz ([cerberus98](http://github.com/cerberus98)) special thanks
72
+ * Chris MacGown ([ChristopherMacGown](http://github.com/ChristopherMacGown))
73
+ * Joe Ocampo ([agilejoe](http://github.com/agilejoe))
74
+
75
+ ## Copyright
76
+
77
+ Copyright (c) 2019 Jason Meridth. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
1
  require 'rubygems'
2
- require 'spec/rake/spectask'
3
- require 'rake/gempackagetask'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubygems/package_task'
4
4
 
5
+ task :default => ['spec:coverage']
5
6
 
6
7
  namespace :twog do
7
8
  desc "Clean out the coverage and the pkg"
@@ -12,38 +13,32 @@ namespace :twog do
12
13
  end
13
14
 
14
15
  desc "Run all specs in spec directory"
15
- Spec::Rake::SpecTask.new(:spec) do |t|
16
- t.spec_files = FileList['spec/**/*_spec.rb']
17
- t.spec_opts = ['--color']
16
+ RSpec::Core::RakeTask.new(:spec) do |spec|
17
+ spec.pattern = FileList['spec/**/*_spec.rb']
18
+ spec.rspec_opts = ['--color']
18
19
  end
19
20
 
20
21
  namespace :spec do
21
- desc "Run rcov on the spec files"
22
- Spec::Rake::SpecTask.new(:coverage) do |t|
23
- t.spec_files = FileList['spec/**/*_spec.rb']
24
- t.spec_opts = ['--color']
25
- t.rcov = true
26
- t.rcov_opts = ['--exclude', 'spec']
22
+ desc "Run coverage on the spec files"
23
+ RSpec::Core::RakeTask.new(:coverage) do |spec|
24
+ spec.pattern = FileList['spec/**/*_spec.rb']
25
+ spec.rspec_opts = ['--color']
26
+ ENV['COVERAGE'] = "true"
27
27
  end
28
28
  end
29
29
 
30
30
  begin
31
- gem 'jeweler', '>= 0.11.0'
32
- require 'jeweler'
33
- Jeweler::Tasks.new do |s|
31
+ require 'juwelier'
32
+ Juwelier::Tasks.new do |s|
34
33
  s.name = "twog"
35
34
  s.summary = %Q{Tool to tweet blog posts}
36
35
  s.email = ["jmeridth@gmail.com"]
37
- s.homepage = "http://github.com/armmer/twog"
36
+ s.homepage = "http://github.com/jmeridth/twog"
38
37
  s.description = "Tool to tweet blog posts"
39
38
  s.authors = ["Jason Meridth"]
40
- s.rubyforge_project = "twog"
41
- s.add_dependency('twitter_oauth', '>= 0.3.3')
42
- s.add_dependency('bitly', '>= 0.4.0')
43
- s.add_dependency('whenever', '>= 0.4.1')
44
39
  end
45
40
  rescue LoadError
46
- puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
41
+ puts "Juwelier not available. Install it with: sudo gem install juwelier --version '>= 2.4.9'"
47
42
  exit(1)
48
43
  end
49
44
 
@@ -1,5 +1,5 @@
1
- ---
2
- :patch: 0
1
+ ---
3
2
  :major: 0
4
- :build:
5
3
  :minor: 3
4
+ :patch: 5
5
+ :build:
data/bin/twog CHANGED
@@ -8,6 +8,8 @@ require 'optparse'
8
8
  require 'whenever'
9
9
  require 'fileutils'
10
10
 
11
+ include Twog::Twog
12
+
11
13
  twog_dir = "#{ENV['HOME']}/.twog"
12
14
  FileUtils.mkdir_p twog_dir unless File.exists?(twog_dir)
13
15
  twog_cron_schedule_file = "#{twog_dir}/schedule.rb"
@@ -16,17 +18,21 @@ twog_cron_identifier = "twog"
16
18
  legacy_conf_file_name = "#{ENV['HOME']}/.twog.yaml"
17
19
  twog_conf_file = "#{twog_dir}/conf.yaml"
18
20
 
21
+ def help
22
+ puts "Invalid options. Run `twog --help` for assistance."
23
+ end
24
+
25
+ def get_conf(conf)
26
+ raise "please run 'twog --conf' to create the #{conf} file" unless File.exists?(conf)
27
+ YAML.load_file(conf)
28
+ end
29
+
19
30
  options = {}
20
31
  opts = OptionParser.new do |opts|
21
32
  opts.banner = "Twog is a tool to tweet blog posts"
22
33
 
23
- opts.on_tail("-h","-?","--help", "Display help") do
24
- puts opts
25
- exit 0
26
- end
27
-
28
34
  opts.on("-v", "--version", "Display current version") do
29
- puts "Twog " + Twog.version
35
+ puts "Twog " + version
30
36
  exit 0
31
37
  end
32
38
 
@@ -37,13 +43,14 @@ opts = OptionParser.new do |opts|
37
43
  command "twog"
38
44
  end
39
45
  EOS
40
-
46
+
41
47
  answer = ""
42
48
  if File.exists?(twog_cron_schedule_file)
43
49
  puts "Cron schedule file (#{twog_cron_schedule_file}) already exists. Overwrite? [Y/n]"
44
50
  answer = gets
45
51
  end
46
52
 
53
+ File.open(twog_cron_schedule_log, 'w') {|f| f.write("") } unless File.exists?(twog_cron_schedule_log)
47
54
  File.open(twog_cron_schedule_file, 'w') {|f| f.write(twog_cron_schedule_content) } if ["Y","y",""].include?(answer.chomp)
48
55
 
49
56
  cron_options = {:file => twog_cron_schedule_file, :identifier => twog_cron_identifier, :update => true}
@@ -59,7 +66,14 @@ opts = OptionParser.new do |opts|
59
66
  exit 0
60
67
  end
61
68
 
62
- opts.on("--conf", "Create default conf file") do
69
+ opts.on("-o", "--output", "View the blog posts that will be tweeted") do
70
+ posts = get_posts_to_tweet(get_conf(twog_conf_file))
71
+ puts "No posts to tweet" if posts.length == 0
72
+ posts.each {|post| puts "#{post.title} (#{Time.parse(post.date.to_s)})"; puts "#{post.link}" }
73
+ exit 0
74
+ end
75
+
76
+ opts.on("-c", "--conf", "Create default conf file") do
63
77
  conf_file_contents = <<-EOS
64
78
  rss_feed: 'http://url.com/feed.rss'
65
79
  consumer_key: 'consumer key'
@@ -81,18 +95,26 @@ opts = OptionParser.new do |opts|
81
95
  puts "Default configuration file created at #{twog_conf_file}"
82
96
  exit 0
83
97
  end
98
+
99
+ opts.on("-h","-?","--help", "Display help") do
100
+ puts opts
101
+ exit 0
102
+ end
84
103
  end
85
104
 
86
105
  # Read command line options into `options` hash
87
- opts.parse!
106
+ begin
107
+ opts.parse!
108
+ rescue OptionParser::MissingArgument => e
109
+ puts e.message
110
+ help
111
+ exit 0
112
+ end
88
113
 
89
114
  # Get args from the command line
90
115
  if ARGV.size > 1
91
- puts "Invalid options. Run `twog --help` for assistance."
116
+ help
92
117
  exit(1)
93
118
  end
94
119
 
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)
97
-
98
- Twog.run(conf)
120
+ run(get_conf(twog_conf_file))