feedcellar 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +12 -0
- data/lib/feedcellar/command.rb +29 -13
- data/lib/feedcellar/feed.rb +2 -2
- data/lib/feedcellar/resource.rb +1 -1
- data/lib/feedcellar/version.rb +1 -1
- data/test/test-command.rb +0 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c68cc360529496d84b72f86f7bde1c3da53a54fa
|
4
|
+
data.tar.gz: 35ac9e19d288b2454cf8442077d1b41f7e3eae44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b77c019cd534abc6b58cdee970c8cf69223947770c58ecbc65ab66766672ab91df965edff6495e9a4da2ac86a004da0e9909c4dc99dd577f627999ce5be47b54
|
7
|
+
data.tar.gz: 0d29006fbcf81628d0dcf7b746b721b1c79edfb49b9344dc4a3402b146b6219b36f02a8101a338a963bc450608dbb206c73a96ad68d36120c36f88b99daa1917
|
data/NEWS.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# NEWS
|
2
2
|
|
3
|
+
## 0.2.2: 2013-06-16
|
4
|
+
|
5
|
+
Improve search command release!
|
6
|
+
|
7
|
+
### Changes
|
8
|
+
|
9
|
+
* Improvements
|
10
|
+
* Support multi word for search command
|
11
|
+
* Remove an API option from search command
|
12
|
+
* Add resource option to search command
|
13
|
+
* Add mtime option to search command
|
14
|
+
|
3
15
|
## 0.2.1: 2013-06-10
|
4
16
|
|
5
17
|
Fix output format of search command.
|
data/lib/feedcellar/command.rb
CHANGED
@@ -85,35 +85,51 @@ module Feedcellar
|
|
85
85
|
option :browser, :type => :boolean, :desc => "open *ALL* links in browser"
|
86
86
|
option :long, :type => :boolean, :aliases => "-l", :desc => "use a long listing format"
|
87
87
|
option :reverse, :type => :boolean, :aliases => "-r", :desc => "reverse order while sorting"
|
88
|
-
|
88
|
+
option :mtime, :type => :numeric, :desc => "feed's data was last modified n*24 hours ago."
|
89
|
+
option :resource, :type => :string, :desc => "search of partial match by feed's resource url"
|
90
|
+
def search(*words)
|
89
91
|
GroongaDatabase.new.open(@database_dir) do |database|
|
90
|
-
feeds = database.feeds
|
91
|
-
|
92
|
+
feeds = database.feeds
|
93
|
+
words.each do |word|
|
94
|
+
feeds = feeds.select do |feed|
|
95
|
+
(feed.title =~ word) | (feed.description =~ word)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if options[:mtime]
|
100
|
+
feeds = feeds.select do |feed|
|
101
|
+
feed.date > (Time.now - (options[:mtime] * 60 * 60 * 24))
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
if options[:resource]
|
106
|
+
feeds = feeds.select do |feed|
|
107
|
+
feed.resource =~ options[:resource]
|
108
|
+
end
|
92
109
|
end
|
93
110
|
|
94
111
|
order = options[:reverse] ? "descending" : "ascending"
|
95
112
|
sorted_feeds = feeds.sort([{:key => "date", :order => order}])
|
96
|
-
return sorted_feeds if api
|
97
113
|
|
98
|
-
sorted_feeds.each do |
|
99
|
-
resources = database.resources.select do |
|
100
|
-
|
114
|
+
sorted_feeds.each do |feed|
|
115
|
+
resources = database.resources.select do |resource|
|
116
|
+
resource.xmlUrl == feed.resource
|
101
117
|
end
|
102
118
|
next unless resources
|
103
119
|
next unless resources.first # FIXME
|
104
120
|
|
105
|
-
title =
|
121
|
+
title = feed.title.gsub(/\n/, " ")
|
106
122
|
if options[:long]
|
107
|
-
date =
|
123
|
+
date = feed.date.strftime("%Y/%m/%d %H:%M")
|
108
124
|
resource = resources.first.title
|
109
|
-
puts "#{date} #{title} - #{resource} / #{
|
125
|
+
puts "#{date} #{title} - #{resource} / #{feed.link}"
|
110
126
|
else
|
111
|
-
date =
|
127
|
+
date = feed.date.strftime("%Y/%m/%d")
|
112
128
|
puts "#{date} #{title}"
|
113
129
|
end
|
114
130
|
|
115
131
|
if options[:browser]
|
116
|
-
Gtk.show_uri(
|
132
|
+
Gtk.show_uri(feed.link) if browser_available?
|
117
133
|
end
|
118
134
|
end
|
119
135
|
end
|
@@ -125,7 +141,7 @@ module Feedcellar
|
|
125
141
|
begin
|
126
142
|
require "gtk2"
|
127
143
|
rescue LoadError
|
128
|
-
$stderr.puts "
|
144
|
+
$stderr.puts "WARNING: Sorry, browser option required \"gtk2\"."
|
129
145
|
@browser = false
|
130
146
|
else
|
131
147
|
@browser = true
|
data/lib/feedcellar/feed.rb
CHANGED
@@ -19,11 +19,11 @@ module Feedcellar
|
|
19
19
|
begin
|
20
20
|
rss = RSS::Parser.parse(feed_url, false)
|
21
21
|
rescue
|
22
|
-
$stderr.puts "
|
22
|
+
$stderr.puts "WARNING: #{$!} (#{feed_url})"
|
23
23
|
return nil
|
24
24
|
end
|
25
25
|
rescue
|
26
|
-
$stderr.puts "
|
26
|
+
$stderr.puts "WARNING: #{$!} (#{feed_url})"
|
27
27
|
return nil
|
28
28
|
end
|
29
29
|
return nil unless rss
|
data/lib/feedcellar/resource.rb
CHANGED
data/lib/feedcellar/version.rb
CHANGED
data/test/test-command.rb
CHANGED
@@ -60,14 +60,6 @@ class CommandTest < Test::Unit::TestCase
|
|
60
60
|
$stdout = io
|
61
61
|
@command.search("ruby")
|
62
62
|
assert_true(s.size > 100)
|
63
|
-
|
64
|
-
# confirm search command in case of API
|
65
|
-
s = ""
|
66
|
-
io = StringIO.new(s)
|
67
|
-
ret = @command.search("ruby", true)
|
68
|
-
assert_equal(Groonga::Array, ret.class)
|
69
|
-
assert_equal(0, s.size)
|
70
|
-
assert_not_equal(0, ret.size)
|
71
63
|
$stdout = STDOUT
|
72
64
|
|
73
65
|
# confirm unregister command
|
@@ -79,15 +71,6 @@ class CommandTest < Test::Unit::TestCase
|
|
79
71
|
Feedcellar::GroongaDatabase.new.open(@tmpdir) do |database|
|
80
72
|
assert_equal(2, database.resources.size)
|
81
73
|
end
|
82
|
-
|
83
|
-
# confirm search command after unregister
|
84
|
-
s = ""
|
85
|
-
io = StringIO.new(s)
|
86
|
-
ret = @command.search("ruby", true)
|
87
|
-
assert_equal(Groonga::Array, ret.class)
|
88
|
-
assert_equal(0, s.size)
|
89
|
-
assert_not_equal(0, ret.size)
|
90
|
-
$stdout = STDOUT
|
91
74
|
end
|
92
75
|
|
93
76
|
def teardown
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedcellar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rroonga
|