hatebu_entry 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hatebu_entry/command.rb +2 -2
- data/lib/hatebu_entry/version.rb +1 -1
- data/sample/sample.rb +11 -16
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfc791c59fc9c6d54a195faabf92c4ba1e0e975f
|
4
|
+
data.tar.gz: cefb430f9a0c13c15091c68623a71ec88ad425b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d180e72f0c58a6cc784aace4e863c6b7e987d168e04e5770bc5a40d4ccb2743e54dd6eddaf51dad4fbd34fe3c15f00ebb5e557c56570939496996fa12ebdfd
|
7
|
+
data.tar.gz: 64cdf4b601d521e24a91b74599e91f0abe17d7f1824bc9827d44ccedbd4736f7c3218a9632c7b3ea8837c21657191ee25106ca0d2c03aa6b8dcec81dd7abe2c8
|
data/lib/hatebu_entry/command.rb
CHANGED
@@ -2,8 +2,8 @@ require 'thor'
|
|
2
2
|
|
3
3
|
class HatebuEntry::Command < Thor
|
4
4
|
desc "get URL", "Get Hatena bookmark entries for URL"
|
5
|
-
option :pages, aliases:"-p", default:0
|
6
|
-
option :sort, aliases:"-s", default:"count"
|
5
|
+
option :pages, aliases:"-p", default:0, desc:"10 entries in default, takes 20 each by 1 or more"
|
6
|
+
option :sort, aliases:"-s", default:"count", desc:"count, hot or eid are acceptable"
|
7
7
|
def get(url)
|
8
8
|
entries = HatebuEntry.new(url, options[:sort])
|
9
9
|
.entries(options[:pages].to_i)
|
data/lib/hatebu_entry/version.rb
CHANGED
data/sample/sample.rb
CHANGED
@@ -4,26 +4,21 @@ githubio = 'http://melborne.github.io'
|
|
4
4
|
githubcom = 'http://melborne.github.com'
|
5
5
|
hatena = 'http://d.hatena.ne.jp/keyesberry'
|
6
6
|
|
7
|
-
def get_entries(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
puts "#{s.size} entries retrieved."
|
12
|
-
end
|
7
|
+
def get_entries(url, pages=1)
|
8
|
+
puts "Bookmark entries retrieving from #{url}..."
|
9
|
+
HatebuEntry.new(url).entries(pages).tap do |s|
|
10
|
+
puts "#{s.size} entries retrieved."
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
|
14
|
+
entries = [githubio, githubcom, hatena].map { |url| get_entries url, 2 }
|
17
15
|
|
18
16
|
puts "\nMerging entries..."
|
17
|
+
merged = entries.inject { |mem, ent| HatebuEntry::Entry.merge mem, ent }
|
19
18
|
|
20
|
-
entries
|
21
|
-
entries = HatebuEntry::Entry.merge(entries, hatena_ent)
|
22
|
-
|
23
|
-
puts "\nFollowing is top 20 entries."
|
19
|
+
puts "\nFollowing is top 20 entries from 3 sites."
|
24
20
|
puts
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.take(20)
|
21
|
+
puts merged.lazy
|
22
|
+
.sort_by{ |e| -e.count }
|
23
|
+
.map { |h| "%i: %s (%s)" % [h.count, h.title, h.link] }
|
24
|
+
.take(20)
|