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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08349a53320968c7d67ee7ee77d0c6a0e6d8141c
4
- data.tar.gz: 612e284fddb33c71c2035bc4f07ea6b3058feb63
3
+ metadata.gz: c68cc360529496d84b72f86f7bde1c3da53a54fa
4
+ data.tar.gz: 35ac9e19d288b2454cf8442077d1b41f7e3eae44
5
5
  SHA512:
6
- metadata.gz: 7a3f12931734d1dd9f4a7a55b2b6f0f5b73ac24134fa186787885eacaed0c0773675c3540c5a685ff637915322d05a15b2ac1adde39a37d072ef90c211d3852e
7
- data.tar.gz: 07444c6e22023537652c9836dbd20d2ae72a1461da9672c4991ea8cf983eacc6376b6faff5a2051684babeab565af7398289d102f38bedc6d2069959c262608a
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.
@@ -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
- def search(word, api=false)
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.select do |v|
91
- (v.title =~ word) | (v.description =~ word)
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 |record|
99
- resources = database.resources.select do |v|
100
- v.xmlUrl == record.resource
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 = record.title.gsub(/\n/, " ")
121
+ title = feed.title.gsub(/\n/, " ")
106
122
  if options[:long]
107
- date = record.date.strftime("%Y/%m/%d %H:%M")
123
+ date = feed.date.strftime("%Y/%m/%d %H:%M")
108
124
  resource = resources.first.title
109
- puts "#{date} #{title} - #{resource} / #{record.link}"
125
+ puts "#{date} #{title} - #{resource} / #{feed.link}"
110
126
  else
111
- date = record.date.strftime("%Y/%m/%d")
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(record.link) if browser_available?
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 "WARNNING: Sorry, browser option required \"gtk2\"."
144
+ $stderr.puts "WARNING: Sorry, browser option required \"gtk2\"."
129
145
  @browser = false
130
146
  else
131
147
  @browser = true
@@ -19,11 +19,11 @@ module Feedcellar
19
19
  begin
20
20
  rss = RSS::Parser.parse(feed_url, false)
21
21
  rescue
22
- $stderr.puts "WARNNING: #{$!} (#{feed_url})"
22
+ $stderr.puts "WARNING: #{$!} (#{feed_url})"
23
23
  return nil
24
24
  end
25
25
  rescue
26
- $stderr.puts "WARNNING: #{$!} (#{feed_url})"
26
+ $stderr.puts "WARNING: #{$!} (#{feed_url})"
27
27
  return nil
28
28
  end
29
29
  return nil unless rss
@@ -8,7 +8,7 @@ module Feedcellar
8
8
  rescue RSS::InvalidRSSError
9
9
  rss = RSS::Parser.parse(url, false)
10
10
  rescue
11
- $stderr.puts "WARNNING: #{$!} (#{url})"
11
+ $stderr.puts "WARNING: #{$!} (#{url})"
12
12
  return nil
13
13
  end
14
14
 
@@ -1,3 +1,3 @@
1
1
  module Feedcellar
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.1
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-10 00:00:00.000000000 Z
11
+ date: 2013-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rroonga