Skip to content

Commit 99c7ab9

Browse files
committed
#70 Plugin Store::File rewrite link to file URI scheme
1 parent 27656a7 commit 99c7ab9

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

lib/automatic/feed_maker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def self.create_pipeline(feeds = [])
3737
RSS::Maker.make("2.0") {|maker|
3838
xss = maker.xml_stylesheets.new_xml_stylesheet
3939
maker.channel.title = "Automatic Ruby"
40-
maker.channel.description = "Automatic Ruby"
40+
maker.channel.description = "Automatic::FeedMaker"
4141
maker.channel.link = "https://github.com/automaticruby/automaticruby"
4242
maker.items.do_sort = true
4343

@@ -66,7 +66,7 @@ def self.content_provide(url, data)
6666
RSS::Maker.make("2.0") {|maker|
6767
xss = maker.xml_stylesheets.new_xml_stylesheet
6868
maker.channel.title = "Automatic Ruby"
69-
maker.channel.description = "Automatic Ruby"
69+
maker.channel.description = "Automatic::FeedMaker"
7070
maker.channel.link = "https://github.com/automaticruby/automaticruby"
7171
maker.items.do_sort = true
7272
item = maker.items.new_item

lib/automatic/feed_parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def self.parse_html(html)
3131
RSS::Maker.make("2.0") {|maker|
3232
xss = maker.xml_stylesheets.new_xml_stylesheet
3333
maker.channel.title = "Automatic Ruby"
34-
maker.channel.description = "Automatic Ruby"
34+
maker.channel.description = "Automatic::FeedParser"
3535
maker.channel.link = "https://github.com/automaticruby/automaticruby"
3636
maker.items.do_sort = true
3737

plugins/store/file.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class StoreFile
1515
def initialize(config, pipeline=[])
1616
@config = config
1717
@pipeline = pipeline
18+
@return_feeds = []
1819
end
1920

2021
def run
@@ -28,8 +29,9 @@ def run
2829
retry_max = @config['retry'].to_i || 0
2930
begin
3031
retries += 1
31-
wget(feed.link)
32+
feed.link = wget(feed.link)
3233
sleep ||= @config['interval'].to_i
34+
@return_feeds << Automatic::FeedMaker.generate_feed(feed)
3335
rescue
3436
Automatic::Log.puts("error", "ErrorCount: #{retries}, Fault during file download.")
3537
sleep ||= @config['interval'].to_i
@@ -39,17 +41,22 @@ def run
3941
}
4042
end
4143
}
44+
@pipeline << Automatic::FeedMaker.create_pipeline(@return_feeds) if @return_feeds.length > 0
4245
@pipeline
4346
end
4447

4548
private
4649
def wget(url)
4750
filename = url.split(/\//).last
51+
filepath = File.join(@config['path'], filename)
4852
open(url) {|source|
49-
open(File.join(@config['path'], filename), "w+b") { |o|
53+
open(filepath, "w+b") { |o|
5054
o.print source.read
5155
}
5256
}
57+
uri_scheme = "file://" + filepath
58+
Automatic::Log.puts("info", "Saved: #{uri_scheme}")
59+
uri_scheme
5360
end
5461
end
5562
end

plugins/subscription/text.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def initialize(config, pipeline=[])
1717

1818
def run
1919
create_feed
20-
@pipeline << Automatic::FeedMaker.create_pipeline(@return_feeds) unless @return_feeds.length == 0
20+
@pipeline << Automatic::FeedMaker.create_pipeline(@return_feeds) if @return_feeds.length > 0
2121
@pipeline
2222
end
2323

@@ -30,7 +30,7 @@ def create_feed
3030
@config['titles'].each {|title|
3131
feed = {}
3232
feed['title'] = title
33-
@return_feeds << Automatic::FeedParser.generate_feed(feed)
33+
@return_feeds << Automatic::FeedMaker.generate_feed(feed)
3434
}
3535
end
3636

test/integration/test_image2local.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,15 @@ plugins:
1919
config:
2020
db: test_image.db
2121

22-
- module: StoreTargetLink
22+
- module: StoreFile
2323
config:
2424
path: /tmp
2525
retry: 2
2626
interval: 2
2727

28-
#- module: PublishConsole
28+
- module: StorePermalink
29+
config:
30+
db: test_image2.db
31+
32+
# - module: PublishConsole
2933

test/integration/test_tumblr2local.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ plugins:
3333
config:
3434
db: test_tumblr.db
3535

36+
- module: StoreFile
37+
config:
38+
path: /tmp
39+
retry: 2
40+
interval: 2
41+
3642
#- module: PublishConsole
3743

0 commit comments

Comments
 (0)