rubynews 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0fdb3e71ec898038bb1133905caf690931be0ad3
4
- data.tar.gz: b79b4fb0825d096d18a3ce65e02859e3c6578fea
3
+ metadata.gz: a78a0b89936710b0bcdea4c8d0f1c290fcd87dc4
4
+ data.tar.gz: 3a923b8e5f0ada89a19313a87b5152aa092aa18a
5
5
  SHA512:
6
- metadata.gz: f250fdb83015df7f8687d141123efc6f33d4cf2d6a4385876e7987fb184deda50b228f46b61f1ff7beda2ca39286bd50ea6b4463520a6d8c6ae57fde85cad174
7
- data.tar.gz: 04fad26539ab6fc59563112377d7c0f94ba447cff6ab5ac9e570cea8393917dab61d8a6c3aa2ac4d0e5d401c79190c55e5c8af451391ac35a4a97a20e165acde
6
+ metadata.gz: 7da8dda533a55ed7c72bbc28d4a5f59f3a31ca9d6c7e91db2d1b5ad90546404adc4f02c76c36386def13b13c112c546ce933b03528c071b969e4616f85417256
7
+ data.tar.gz: 1a13eb700358cfed947a1629277882accaee2828d0bf70de1d12904f02ba57e93cb8291216bc00877a366dfee4e63652e3f4cf092be26ecca05d97c2b81061a0
data/Manifest.txt CHANGED
@@ -2,7 +2,9 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/rubynews
5
6
  lib/rubynews.rb
7
+ lib/rubynews/tool.rb
6
8
  lib/rubynews/version.rb
7
9
  test/helper.rb
8
- test/test_print.rb
10
+ test/test_tool.rb
data/Rakefile CHANGED
@@ -18,7 +18,8 @@ Hoe.spec 'rubynews' do
18
18
  self.history_file = 'CHANGELOG.md'
19
19
 
20
20
  self.extra_deps = [
21
- ['whatson', '>=1.1.0']
21
+ ['whatson', '>=1.1.0'],
22
+ ['pluto-news', '>=1.0.0']
22
23
  ]
23
24
 
24
25
  self.licenses = ['Public Domain']
data/bin/rubynews ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ###################
4
+ # == DEV TIPS:
5
+ #
6
+ # For local testing run like:
7
+ #
8
+ # ruby -Ilib bin/rubynews
9
+ #
10
+ # Set the executable bit in Linux. Example:
11
+ #
12
+ # % chmod a+x bin/rubynews
13
+ #
14
+
15
+ require 'rubynews'
16
+
17
+ RubyNews.main
@@ -0,0 +1,182 @@
1
+
2
+
3
+ module RubyNews
4
+
5
+ class Tool
6
+ def update
7
+ News.subscribe(
8
+ 'http://www.ruby-lang.org/en/feeds/news.rss', # Ruby Lang News
9
+ 'http://www.jruby.org/atom.xml', # JRuby Lang News
10
+ 'http://blog.rubygems.org/atom.xml', # RubyGems News
11
+ 'http://bundler.io/blog/feed.xml', # Bundler News
12
+ 'https://www.ruby-toolbox.com/blog.rss', # Ruby Toolbox News
13
+ 'https://idiosyncratic-ruby.com/feed.xml', # Idiosyncratic Ruby
14
+ 'http://weblog.rubyonrails.org/feed/atom.xml', # Ruby on Rails News
15
+ 'http://sinatrarb.com/feed.xml', # Sinatra News
16
+ 'https://dry-rb.org/feed.xml', # DRY News
17
+ 'https://hanamirb.org/atom.xml', # Hanami News
18
+ 'http://jekyllrb.com/feed.xml', # Jekyll News
19
+ 'http://feeds.feedburner.com/jetbrains_rubymine?format=xml', # RubyMine IDE News
20
+ 'https://blog.phusion.nl/rss/', # Phusion News
21
+ 'https://rubyinstaller.org/feed.xml', # Ruby Installer for Windows News
22
+
23
+ 'http://planetruby.github.io/calendar/feed.xml', # Ruby Conferences & Camps News
24
+ 'https://rubytogether.org/news.xml', # Ruby Together News
25
+ 'https://foundation.travis-ci.org/feed.xml', # Travis Foundation News
26
+ 'https://railsgirlssummerofcode.org/blog.xml', # Rails Girls Summer of Code News
27
+
28
+ ## Ruby People ++ Personal Blog / Website
29
+ 'http://blog.zenspider.com/atom.xml', # Ryan Davis @ Seattle › Washington › United States
30
+ 'http://tenderlovemaking.com/atom.xml', # Aaron Patterson @ Seattle › Washington › United States
31
+ 'http://blog.headius.com/feed.xml', # Charles Nutter @ Richfield › Minnesota › United States
32
+ 'http://www.schneems.com/feed.xml', # Richard Schneeman @ Austin › Texas › United States
33
+ 'https://developers.redhat.com/blog/author/vnmakarov/feed/', # Vladimir Makarov @ Toronto › Canada
34
+
35
+ 'https://eregon.me/blog/feed.xml', # Benoit Daloze @ Zürich › Switzerland
36
+ 'https://gettalong.org/posts.atom', # Thomas Leitner @ Vienna • Wien › Austria
37
+ 'https://rubytuesday.katafrakt.me/feed.xml', # Paweł Świątkowski @ Kraków, Poland
38
+ 'https://solnic.codes/feed/', # Piotr Solnica @ Kraków › Poland
39
+ 'https://zverok.github.io/feed.xml', # Victor Shepelev @ Kharkiv › Ukraine
40
+
41
+ 'http://samsaffron.com/posts.rss', # Sam Saffron @ Sydney › Australia
42
+ 'https://www.rubypigeon.com/feed.xml', # Tom Dalling @ Melbourne› Australia
43
+ )
44
+
45
+ News.update
46
+ end
47
+
48
+
49
+ def banner
50
+ puts "Welcome to Ruby News v#{VERSION} (#{News.channels.count} Channels, #{News.items.count} Items)"
51
+ end
52
+
53
+ def list
54
+ date = Date.today
55
+ empty_week_counter = 0
56
+
57
+ loop do
58
+ week = date.cweek
59
+ year = date.year
60
+ week_start = Date.commercial( year, week, 1 )
61
+ week_end = Date.commercial( year, week, 7 )
62
+
63
+ count = News.week(week, year).count
64
+ if count == 0
65
+ empty_week_counter += 1
66
+ else
67
+ empty_week_counter = 0
68
+ end
69
+
70
+ print
71
+ print "Week #{week}/#{year} - "
72
+ print "#{week_start.format('Mon, 02 Jan')} to "
73
+ print "#{week_end.format('Mon, 02 Jan')} "
74
+ print "(#{count} Items)"
75
+ print "\n"
76
+
77
+
78
+ last_day = nil
79
+ last_host = nil
80
+
81
+ News.week(week, year).each do |item|
82
+ if last_day != item.date.day
83
+ puts
84
+ print " #{item.date.format( 'Mon, 02 Jan' )} "
85
+ print ">> #{URI(item.feed.feed_url).host} <<"
86
+ print "\n"
87
+ elsif last_host != URI(item.feed.feed_url).host
88
+ print " "
89
+ print ">> #{URI(item.feed.feed_url).host} <<"
90
+ print "\n"
91
+ else
92
+ end
93
+
94
+ puts " #{item.title}"
95
+
96
+ last_day = item.date.day
97
+ last_host = URI(item.feed.feed_url).host
98
+ end
99
+
100
+ if count > 0 || empty_week_counter > 10
101
+ puts
102
+ print ">> Press space for more; press any key to quit. <<"
103
+ ch = STDIN.getch
104
+ print "\r"
105
+
106
+ empty_week_counter = 0
107
+
108
+ break if ch != ' '
109
+ end
110
+ date = week_start-1
111
+ end
112
+
113
+ print " "
114
+ print "\n"
115
+
116
+ puts ">> TIP: Type > rubyconf < to list all upcoming ruby conferences & camps in #{Date.today.year}. <<"
117
+ puts
118
+ puts "Bye"
119
+ end
120
+ end # class Tool
121
+
122
+
123
+ def self.main( args=ARGV )
124
+
125
+ dbpath = "#{Env.home}/.news/news.db"
126
+ # puts "dbpath: >#{dbpath}<"
127
+
128
+ FileUtils.mkdir_p( File.dirname(dbpath) ) ## make sure path exists!!
129
+
130
+ News.config.database = { adapter: 'sqlite3',
131
+ database: dbpath }
132
+
133
+ tool = Tool.new
134
+
135
+ if args.empty? && News.items.count == 0 ## on first-time auto-update
136
+ puts
137
+ puts
138
+ tool.banner
139
+ puts
140
+ puts ">> TIP: Type > rubynews update < to update all news feeds. <<"
141
+ puts
142
+ puts "First time? Do you want to update all news feeds now?"
143
+ puts
144
+ print ">> Press y for yes; press any key to continue. <<"
145
+ ch = STDIN.getch
146
+ print "\r"
147
+ print " "
148
+ print "\n"
149
+
150
+ if ch == 'y' or ch == 'Y'
151
+ tool.update
152
+ puts
153
+ puts
154
+ end
155
+
156
+ tool.list
157
+ else
158
+
159
+ if args.include?( 'u' ) ||
160
+ args.include?( 'up' ) ||
161
+ args.include?( 'update' )
162
+ puts
163
+ puts
164
+ tool.banner
165
+ puts
166
+ tool.update
167
+ else
168
+ puts
169
+ puts ">> TIP: Type > rubynews update < to update all news feeds. <<"
170
+ puts
171
+ puts
172
+ ## todo/fix: add Last update on ??? --
173
+ ## add to News module use News.date ?
174
+ ## or use News.last_updated / last_update / last_fetch / fetched
175
+
176
+ tool.banner
177
+ puts
178
+ tool.list
179
+ end
180
+ end
181
+ end # method self.main
182
+ end # module RubyNews
@@ -1,8 +1,8 @@
1
1
 
2
2
  module RubyNews
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 0
5
- PATCH = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/rubynews.rb CHANGED
@@ -1,8 +1,13 @@
1
+ # stdlibs
2
+ require 'io/console'
3
+
4
+ # 3rd party libs / gems
5
+ require 'pluto/news'
1
6
 
2
7
 
3
8
  # our own code
4
9
  require 'rubynews/version' # note: let version always go first
5
-
10
+ require 'rubynews/tool'
6
11
 
7
12
 
8
13
  # say hello
data/test/test_tool.rb ADDED
@@ -0,0 +1,20 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_tool.rb
4
+
5
+
6
+ require 'helper'
7
+
8
+
9
+ class TestTool < MiniTest::Test
10
+
11
+
12
+ def test_main
13
+ RubyNews.main( [] )
14
+ RubyNews.main( ['up'])
15
+
16
+ assert true
17
+ ## assume everything ok if get here
18
+ end
19
+
20
+ end # class TestTool
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubynews
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-18 00:00:00.000000000 Z
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: whatson
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pluto-news
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rdoc
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +68,8 @@ dependencies:
54
68
  version: '3.16'
55
69
  description: rubynews - what's news in the ruby world? browse week by week
56
70
  email: ruby-talk@ruby-lang.org
57
- executables: []
71
+ executables:
72
+ - rubynews
58
73
  extensions: []
59
74
  extra_rdoc_files:
60
75
  - CHANGELOG.md
@@ -65,10 +80,12 @@ files:
65
80
  - Manifest.txt
66
81
  - README.md
67
82
  - Rakefile
83
+ - bin/rubynews
68
84
  - lib/rubynews.rb
85
+ - lib/rubynews/tool.rb
69
86
  - lib/rubynews/version.rb
70
87
  - test/helper.rb
71
- - test/test_print.rb
88
+ - test/test_tool.rb
72
89
  homepage: https://github.com/planetruby/planet
73
90
  licenses:
74
91
  - Public Domain
data/test/test_print.rb DELETED
@@ -1,18 +0,0 @@
1
- ###
2
- # to run use
3
- # ruby -I ./lib -I ./test test/test_print.rb
4
-
5
-
6
- require 'helper'
7
-
8
-
9
- class TestPrint < MiniTest::Test
10
-
11
-
12
- def test_week
13
-
14
- assert true
15
- ## assume everything ok if get here
16
- end
17
-
18
- end # class TestPrint