feedcellar 0.1.2 → 0.1.3

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: eca1aa81de6be510b032bdd1873c9a5d20c691bb
4
- data.tar.gz: f95eb0515ced32e51dae2d726626036184376064
3
+ metadata.gz: 99485cd81b7d2ccc7e871f93c89f54d484c1a725
4
+ data.tar.gz: acf336156d13924926fe66805a457d7f6c574520
5
5
  SHA512:
6
- metadata.gz: 4580cb6be3f40757e10f664b3e595d725a478c76aae834ab8b990a279a434463204a2d08d8ffdeb25686f5e37bf5ece2dc84bb2a6bff480e25494f35bf939e9c
7
- data.tar.gz: 93c3d94eb452934dad54787d1437453f19fce4ae51de5dd07dac47655cebf9dd4fb6ffe58f64f729437f64b38a4dbcadb43c534ae24233ecb8ed70b121f10f77
6
+ metadata.gz: ce6bbda93db793f7c36e82f6461890128dbb01031a2759ca2d8491a7bcae746e71329a3b01a9eb6218b2e2dcc0508104112d8e8ea0cf0fbe3419877b844c0266
7
+ data.tar.gz: 05daf037e95a72d01b876f20a8830f38d361c1cbc99bd63dc435715d84d42113473f53017964c46afb77bf8059fd79fb287fa90f1f1e6a44a1d011dcabdd492b
data/NEWS.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # NEWS
2
2
 
3
+ ## 0.1.3: 2013-06-06
4
+
5
+ Experimental functions release!
6
+
7
+ ### Changes
8
+
9
+ * Improvements
10
+ * Add browser option to search command
11
+ * Improve search order sort by date ascending
12
+ * Add simple format to search command
13
+ * gemspec: change homepage to myokoym.net
14
+ * Add version command
15
+
3
16
  ## 0.1.2: 2013-06-04
4
17
 
5
18
  Bug fixes release!
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
- # Feedcellar - Searchable Storage
1
+ # feedcellar - Searchable Storage
2
2
 
3
- A searchable storage for RSS feed reader. Powered by rroonga.
3
+ Searchable storage for RSS feed reader.
4
+
5
+ Powered by rroonga with groonga!
4
6
 
5
7
  ## Installation
6
8
 
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Feedcellar::VERSION
9
9
  spec.authors = ["Masafumi Yokoyama"]
10
10
  spec.email = ["myokoym@gmail.com"]
11
- spec.description = %q{A searchable storage for RSS feed reader by rroonga.}
11
+ spec.description = %q{Searchable storage for RSS feed reader by rroonga with groonga!}
12
12
  spec.summary = %q{Searchable Storage for Feed Reader}
13
- spec.homepage = "https://github.com/myokoym/feedcellar"
13
+ spec.homepage = "http://myokoym.net/feedcellar/"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
@@ -1,5 +1,6 @@
1
1
  require "thor"
2
2
  require "rss"
3
+ require "feedcellar/version"
3
4
  require "feedcellar/groonga_database"
4
5
  require "feedcellar/opml"
5
6
 
@@ -10,6 +11,11 @@ module Feedcellar
10
11
  @work_dir = File.join(File.expand_path("~"), ".feedcellar")
11
12
  end
12
13
 
14
+ desc "version", "Show version number."
15
+ def version
16
+ puts Feedcellar::VERSION
17
+ end
18
+
13
19
  desc "register URL", "Register a URL."
14
20
  def register(url)
15
21
  @database = GroongaDatabase.new
@@ -19,12 +25,12 @@ module Feedcellar
19
25
  rescue RSS::InvalidRSSError
20
26
  rss = RSS::Parser.parse(url, false)
21
27
  rescue
22
- $stderr.puts "Warnning: #{$!} (#{url})"
28
+ $stderr.puts "WARNNING: #{$!} (#{url})"
23
29
  return 1
24
30
  end
25
31
 
26
32
  unless rss
27
- $stderr.puts "Error: Invalid URL"
33
+ $stderr.puts "ERROR: Invalid URL"
28
34
  return 1
29
35
  end
30
36
 
@@ -83,11 +89,11 @@ module Feedcellar
83
89
  begin
84
90
  rss = RSS::Parser.parse(feed_url, false)
85
91
  rescue
86
- $stderr.puts "Warnning: #{$!} (#{feed_url})"
92
+ $stderr.puts "WARNNING: #{$!} (#{feed_url})"
87
93
  next
88
94
  end
89
95
  rescue
90
- $stderr.puts "Warnning: #{$!} (#{feed_url})"
96
+ $stderr.puts "WARNNING: #{$!} (#{feed_url})"
91
97
  next
92
98
  end
93
99
  next unless rss
@@ -106,7 +112,7 @@ module Feedcellar
106
112
  end
107
113
 
108
114
  unless link
109
- $stderr.puts "Warnning: missing link (#{title})"
115
+ $stderr.puts "WARNNING: missing link (#{title})"
110
116
  next
111
117
  end
112
118
 
@@ -118,24 +124,57 @@ module Feedcellar
118
124
 
119
125
  desc "search WORD", "Search feeds."
120
126
  option :desc, :type => :boolean, :aliases => "-d", :desc => "show description"
127
+ option :simple, :type => :boolean, :desc => "simple format as one liner"
128
+ option :browser, :type => :boolean, :desc => "open *ALL* links in browser"
121
129
  def search(word)
122
130
  @database = GroongaDatabase.new
123
131
  @database.open(@work_dir) do |database|
124
132
  feeds = @database.feeds
125
133
  resources = @database.resources
126
134
 
127
- feeds.select {|v| (v.title =~ word) |
128
- (v.description =~ word) }.each do |record|
135
+ records = feeds.select do |v|
136
+ (v.title =~ word) | (v.description =~ word)
137
+ end
138
+
139
+ records.sort([{:key => "date", :order => "ascending"}]).each do |record|
129
140
  feed_resources = resources.select {|v| v.xmlUrl =~ record.resource }
130
141
  next unless feed_resources
131
- puts feed_resources.first.title
132
- puts " #{record.title}"
133
- puts " #{record.date}"
134
- puts " #{record.link}"
135
- puts " #{record.description}" if options[:desc]
136
- puts
142
+ if options[:simple]
143
+ # TODO This format will be to default from 0.2.0
144
+ date = record.date.strftime("%Y/%m/%d")
145
+ title= record.title
146
+ resource = feed_resources.first.title
147
+ link = record.link
148
+ puts "#{date} #{title} - #{resource}"
149
+ else
150
+ puts feed_resources.first.title
151
+ puts " #{record.title}"
152
+ puts " #{record.date}"
153
+ puts " #{record.link}"
154
+ puts " #{record.description}" if options[:desc]
155
+ puts
156
+ end
157
+
158
+ if options[:browser]
159
+ Gtk.show_uri(record.link) if browser_available?
160
+ end
161
+ end
162
+ end
163
+ end
164
+
165
+ private
166
+ def browser_available?
167
+ if @browser.nil?
168
+ begin
169
+ require "gtk2"
170
+ rescue LoadError
171
+ $stderr.puts "WARNNING: Sorry, browser option required \"gtk2\"."
172
+ @browser = false
173
+ else
174
+ @browser = true
137
175
  end
138
176
  end
177
+ @browser
139
178
  end
140
179
  end
141
180
  end
@@ -1,3 +1,3 @@
1
1
  module Feedcellar
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "fileutils"
2
2
  require "stringio"
3
+ require "feedcellar/version"
3
4
  require "feedcellar/command"
4
5
  require "feedcellar/groonga_database"
5
6
 
@@ -12,11 +13,18 @@ class CommandTest < Test::Unit::TestCase
12
13
  end
13
14
 
14
15
  def test_command
16
+ s = ""
17
+ io = StringIO.new(s)
18
+ $stdout = io
19
+ @command.version
20
+ assert_equal("#{Feedcellar::VERSION}\n", s)
21
+ $stdout = STDOUT
22
+
15
23
  s = ""
16
24
  io = StringIO.new(s)
17
25
  $stderr = io
18
26
  assert_equal(1, @command.register("hoge"))
19
- assert_equal("Error: Invalid URL\n", s)
27
+ assert_equal("ERROR: Invalid URL\n", s)
20
28
  $stderr = STDERR
21
29
 
22
30
  @command.register("http://myokoym.github.io/entries.rss")
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.1.2
4
+ version: 0.1.3
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-04 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rroonga
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description: A searchable storage for RSS feed reader by rroonga.
111
+ description: Searchable storage for RSS feed reader by rroonga with groonga!
112
112
  email:
113
113
  - myokoym@gmail.com
114
114
  executables:
@@ -134,7 +134,7 @@ files:
134
134
  - test/run-test.rb
135
135
  - test/test-command.rb
136
136
  - test/test-opml.rb
137
- homepage: https://github.com/myokoym/feedcellar
137
+ homepage: http://myokoym.net/feedcellar/
138
138
  licenses:
139
139
  - MIT
140
140
  metadata: {}