livedoor-feeddiscover 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -1
- data/Manifest.txt +1 -0
- data/README.txt +7 -2
- data/Rakefile +14 -16
- data/examples/mkopml.rb +5 -2
- data/lib/livedoor/api/feed_discover/client.rb +5 -1
- data/lib/livedoor/api/feed_discover/version.rb +1 -1
- data/spec/livedoor/api/feed_discover/client_spec.rb +42 -0
- data/spec/spec_helper.rb +23 -18
- data/test/spec_runner.rb +26 -0
- metadata +5 -7
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -19,7 +19,7 @@ So, livedoor-feeddiscover do not access the target URL.
|
|
19
19
|
# find feed of matz blog.
|
20
20
|
matzblog = Livedoor::API::FeedDiscover.find(
|
21
21
|
"http://www.rubyist.net/~matz/",
|
22
|
-
"User-Agent" => "
|
22
|
+
"User-Agent" => "YourCoolApp/1.0 (+http://your.cool.app)")
|
23
23
|
if matzblog.feeds?
|
24
24
|
puts matzblog.feed.source # specified argument
|
25
25
|
puts matzblog.feed.link # blog link
|
@@ -52,11 +52,16 @@ So, livedoor-feeddiscover do not access the target URL.
|
|
52
52
|
end
|
53
53
|
|
54
54
|
|
55
|
+
=== DEFAULT USERAGENT
|
56
|
+
|
57
|
+
livedoor-feeddiscover/x.y.z (+http://feeddiscoverapi.rubyforge.org)
|
58
|
+
|
59
|
+
|
55
60
|
=== BENCHMARK
|
56
61
|
|
57
62
|
vs feed-discover[http://rubyforge.org/projects/feed-discover/].
|
58
63
|
|
59
|
-
> ruby examples
|
64
|
+
> ruby examples/benchmark.rb
|
60
65
|
Start auto-discover for 4 blogs ------------------------------------
|
61
66
|
http://www.rubyist.net/~matz/
|
62
67
|
http://rubyforge.org/
|
data/Rakefile
CHANGED
@@ -75,7 +75,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
75
75
|
p.url = HOMEPATH
|
76
76
|
|
77
77
|
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
78
|
-
p.test_globs = ["
|
78
|
+
p.test_globs = ["test/spec_runner.rb"]
|
79
79
|
p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
|
80
80
|
|
81
81
|
p.summary = p.paragraphs_of('README.txt', 2..2)[0]
|
@@ -87,15 +87,8 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
87
87
|
p.need_tar = true
|
88
88
|
end
|
89
89
|
|
90
|
-
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
|
91
90
|
desc 'Release the website and new gem version'
|
92
|
-
task :deploy => [:check_manifest!, :check_version, :publish_docs, :release]
|
93
|
-
puts "Remember to create SVN tag:"
|
94
|
-
puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
|
95
|
-
"svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/#{VERS} "
|
96
|
-
puts "Suggested comment:"
|
97
|
-
puts "Tagging release #{CHANGES}"
|
98
|
-
end
|
91
|
+
task :deploy => [:check_manifest!, :check_version, :publish_docs, :release]
|
99
92
|
|
100
93
|
task :check_manifest! => [:check_manifest] do
|
101
94
|
unless $?.success?
|
@@ -114,13 +107,22 @@ task :check_version do
|
|
114
107
|
puts "Please update your version.rb to match the release version, currently #{VERS}"
|
115
108
|
exit
|
116
109
|
end
|
110
|
+
histver = File.read("History.txt")[/^== (\d+\.\d+\.\d+)/, 1]
|
111
|
+
unless ENV['VERSION'] == histver
|
112
|
+
puts "Please update your History.txt to match the release version, currently #{histver}"
|
113
|
+
exit
|
114
|
+
end
|
117
115
|
end
|
118
116
|
|
117
|
+
# remove :test task defined by Hoe.
|
118
|
+
remove_tasks :test, :test_deps, :default
|
119
|
+
|
119
120
|
desc "Run the specs under spec/models"
|
120
121
|
Spec::Rake::SpecTask.new do |t|
|
121
122
|
t.spec_opts = ['--options', "spec/spec.opts"]
|
122
123
|
t.spec_files = FileList['spec/**/*_spec.rb']
|
123
124
|
end
|
125
|
+
task :test => [:spec]
|
124
126
|
|
125
127
|
desc "Default task is to run specs"
|
126
128
|
task :default => :spec
|
@@ -131,7 +133,7 @@ task :default => :spec
|
|
131
133
|
|
132
134
|
desc 'Uninstall the gem package'
|
133
135
|
task_for_windows :uninstall_gem do
|
134
|
-
sh "gem.bat uninstall #{GEM_NAME}"
|
136
|
+
sh "gem.bat uninstall #{ENV['GEMOPTS']} #{GEM_NAME}"
|
135
137
|
end
|
136
138
|
|
137
139
|
|
@@ -140,7 +142,7 @@ end
|
|
140
142
|
#
|
141
143
|
|
142
144
|
task_for_windows :install_gem do
|
143
|
-
sh "gem.bat install pkg/*.gem"
|
145
|
+
sh "gem.bat install #{ENV['GEMOPTS']} pkg/*.gem"
|
144
146
|
end
|
145
147
|
|
146
148
|
task_for_windows :ridocs do
|
@@ -158,9 +160,8 @@ task :docs do
|
|
158
160
|
end
|
159
161
|
|
160
162
|
task_for_windows :publish_docs do
|
161
|
-
config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
|
162
163
|
with_temporary_rename("doc", "html") {
|
163
|
-
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT,
|
164
|
+
Rake::RubyForgePublisher.new(RUBYFORGE_PROJECT, @rubyforge_username).upload
|
164
165
|
}
|
165
166
|
end
|
166
167
|
|
@@ -195,8 +196,5 @@ override_task :post_news do
|
|
195
196
|
puts "Posted to rubyforge `#{subject}'."
|
196
197
|
rm_f NEWS_FILE
|
197
198
|
end
|
198
|
-
task :clean do
|
199
|
-
rm_f NEWS_FILE
|
200
|
-
end
|
201
199
|
|
202
200
|
# vim: syntax=Ruby
|
data/examples/mkopml.rb
CHANGED
@@ -36,10 +36,13 @@ def main
|
|
36
36
|
exit 1
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
nofeed = ARGV - feedlist.map{|e| e.source }
|
40
|
+
nofeed.each do |e|
|
41
|
+
$stderr.puts "feed not found: #{e}"
|
41
42
|
end
|
42
43
|
|
44
|
+
exit 2 unless feedlist.feeds?
|
45
|
+
|
43
46
|
with_output_stream(output) do |w|
|
44
47
|
w.puts feedlist.opml
|
45
48
|
end
|
@@ -18,9 +18,13 @@ module Livedoor::API::FeedDiscover
|
|
18
18
|
class Client
|
19
19
|
|
20
20
|
BASE_URI = URI("http://rpc.reader.livedoor.com/feed/discover").freeze
|
21
|
+
DEFAULT_USERAGENT = "livedoor-feeddiscover/#{Livedoor::API::FeedDiscover::VERSION::STRING} (+http://feeddiscoverapi.rubyforge.org)"
|
21
22
|
|
22
23
|
def initialize(header = nil)
|
23
|
-
@http_header =
|
24
|
+
@http_header = {
|
25
|
+
"User-Agent" => DEFAULT_USERAGENT,
|
26
|
+
}
|
27
|
+
@http_header.update(header) if header
|
24
28
|
end
|
25
29
|
|
26
30
|
def http_header
|
@@ -5,6 +5,48 @@ describe Livedoor::API::FeedDiscover::Client do |*arg|
|
|
5
5
|
@client = Livedoor::API::FeedDiscover::Client.new
|
6
6
|
end
|
7
7
|
|
8
|
+
it "#initialize take http header" do
|
9
|
+
client = Livedoor::API::FeedDiscover::Client.new(
|
10
|
+
"User-Agent" => "foo/1.0",
|
11
|
+
"X-FooBar" => "foobarbaz"
|
12
|
+
)
|
13
|
+
client.http_header.should be_an_instance_of(Hash)
|
14
|
+
client.http_header.keys.length.should eql(2)
|
15
|
+
|
16
|
+
client.http_header.should be_has_key("User-Agent")
|
17
|
+
client.http_header["User-Agent"].should eql("foo/1.0")
|
18
|
+
|
19
|
+
client.http_header.should be_has_key("X-FooBar")
|
20
|
+
client.http_header["X-FooBar"].should eql("foobarbaz")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "#initialize can take Hash" do
|
24
|
+
client = Livedoor::API::FeedDiscover::Client.new({
|
25
|
+
"User-Agent" => "foo/1.0",
|
26
|
+
"X-FooBar" => "foobarbaz",
|
27
|
+
});
|
28
|
+
client.http_header.should be_an_instance_of(Hash)
|
29
|
+
client.http_header.keys.length.should eql(2)
|
30
|
+
|
31
|
+
client.http_header.should be_has_key("User-Agent")
|
32
|
+
client.http_header["User-Agent"].should eql("foo/1.0")
|
33
|
+
|
34
|
+
client.http_header.should be_has_key("X-FooBar")
|
35
|
+
client.http_header["X-FooBar"].should eql("foobarbaz")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should set DEFAULT_USERAGENT to http header" do
|
39
|
+
client = Livedoor::API::FeedDiscover::Client.new
|
40
|
+
client.http_header.should be_an_instance_of(Hash)
|
41
|
+
client.http_header.keys.length.should eql(1)
|
42
|
+
|
43
|
+
client.http_header.should be_has_key("User-Agent")
|
44
|
+
client.http_header["User-Agent"].should eql(client.class::DEFAULT_USERAGENT)
|
45
|
+
|
46
|
+
client = Livedoor::API::FeedDiscover::Client.new(nil)
|
47
|
+
client.http_header["User-Agent"].should eql(client.class::DEFAULT_USERAGENT)
|
48
|
+
end
|
49
|
+
|
8
50
|
it "#find should find feed from specified URL" do
|
9
51
|
feedlist = @client.find("http://rubyforge.org/")
|
10
52
|
feedlist.should be_an_instance_of(Livedoor::API::FeedDiscover::FeedList)
|
data/spec/spec_helper.rb
CHANGED
@@ -1,28 +1,33 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'spec'
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
under_gem = Gem.path.any?{|path| /\A#{Regexp.quote(path)}/i =~ Dir.pwd }
|
5
|
+
if under_gem
|
6
|
+
require "livedoor/api/feed_discover"
|
7
|
+
else
|
8
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), "../lib")
|
9
|
+
require "livedoor/api/feed_discover"
|
6
10
|
|
11
|
+
require "open-uri"
|
12
|
+
require "tempfile"
|
13
|
+
require "digest"
|
14
|
+
require "fileutils"
|
7
15
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
File.open(cache, "wb") do |w|
|
21
|
-
OpenURI.open_uri(self, *rest) do |r|
|
22
|
-
w.write r.read
|
16
|
+
# local cache for test.
|
17
|
+
class URI::HTTP
|
18
|
+
def open(*rest, &block)
|
19
|
+
cachedir = File.join(File.dirname(__FILE__), ".cache")
|
20
|
+
cache = File.join(cachedir, Digest::MD5.hexdigest(self.to_s))
|
21
|
+
FileUtils.mkdir_p(cachedir)
|
22
|
+
unless File.exist?(cache)
|
23
|
+
puts "fetch #{self}"
|
24
|
+
File.open(cache, "wb") do |w|
|
25
|
+
OpenURI.open_uri(self, *rest) do |r|
|
26
|
+
w.write r.read
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
30
|
+
File.open(cache, "rb", &block)
|
25
31
|
end
|
26
|
-
File.open(cache, "rb", &block)
|
27
32
|
end
|
28
33
|
end
|
data/test/spec_runner.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.join(File.dirname(__FILE__), '../spec/spec_helper.rb')
|
3
|
+
|
4
|
+
class SpecRunner < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def with_save_behaviour_runner
|
7
|
+
old_behaviour_runner = defined?($behaviour_runner) ? $behaviour_runner : nil
|
8
|
+
begin
|
9
|
+
yield
|
10
|
+
ensure
|
11
|
+
$behaviour_runner = old_behaviour_runner if old_behaviour_runner
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_spec
|
16
|
+
argv = Dir.glob(File.join(File.dirname(__FILE__), '../spec/**/*_spec.rb'))
|
17
|
+
failures = with_save_behaviour_runner {
|
18
|
+
$behaviour_runner = Spec::Runner::OptionParser.new.create_behaviour_runner(argv, $stdout, $stderr, true)
|
19
|
+
$behaviour_runner.run(argv, false)
|
20
|
+
}
|
21
|
+
unless failures.zero?
|
22
|
+
fail "#{failures} failure(s)."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: livedoor-feeddiscover
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.
|
7
|
-
date: 2007-06-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2007-06-24 00:00:00 +09:00
|
8
8
|
summary: livedoor-feeddiscover performs feed autodiscovery using the livedoor Feed Discover API.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -52,11 +52,9 @@ files:
|
|
52
52
|
- spec/livedoor/api/feed_discover/version_spec.rb
|
53
53
|
- spec/spec.opts
|
54
54
|
- spec/spec_helper.rb
|
55
|
+
- test/spec_runner.rb
|
55
56
|
test_files:
|
56
|
-
-
|
57
|
-
- spec/livedoor/api/feed_discover/feed_list_spec.rb
|
58
|
-
- spec/livedoor/api/feed_discover/feed_spec.rb
|
59
|
-
- spec/livedoor/api/feed_discover/version_spec.rb
|
57
|
+
- test/spec_runner.rb
|
60
58
|
rdoc_options:
|
61
59
|
- --main
|
62
60
|
- README.txt
|