macaroni 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/example/example.rb +8 -0
- data/lib/macaroni.rb +1 -0
- data/lib/macaroni/plugin/output/wget.rb +30 -0
- data/lib/macaroni/version.rb +1 -1
- data/spec/macaroni/plugin/output/wget_spec.rb +26 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e184629ede012d3822209c5c9c7b158d2ee56b30
|
4
|
+
data.tar.gz: 136c876209f9efe268739f7aab34919e7f259f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa5f131dc46eadbf5f158e8f581e1960cffb09ffcc73103be52db06aac1fe9e24ef854beba956878aa66fcae806b75c69ceb62d88e54020edcef7d18812e1aa5
|
7
|
+
data.tar.gz: 52d067230af56c926db90e811b0966ce16ecba32cf8e13c731f58bbf0406c64cb22a413c3e8c628127523d2dbe65420b8a794662e38a1676328f939d929b8a41
|
data/example/example.rb
CHANGED
@@ -71,3 +71,11 @@ pipe :im_kayac_sample do
|
|
71
71
|
plug Output::ImKayac, :username => ENV['IM_KAYAC_USERNAME'], :secret_key => ENV['IM_KAYAC_SECRET_KEY']
|
72
72
|
end
|
73
73
|
|
74
|
+
pipe :wget do
|
75
|
+
plug Input::HTML, 'http://ffffound.com/'
|
76
|
+
plug Filter::Css, 'blockquote td:first-child img'
|
77
|
+
plug Filter::Map do |row|
|
78
|
+
row.attribute('src').to_s
|
79
|
+
end
|
80
|
+
plug Output::Wget, '/tmp/ffffound'
|
81
|
+
end
|
data/lib/macaroni.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Macaroni
|
5
|
+
module Plugin
|
6
|
+
module Output
|
7
|
+
class Wget
|
8
|
+
def initialize(dirpath='.')
|
9
|
+
@dirpath = dirpath
|
10
|
+
end
|
11
|
+
|
12
|
+
def exec(data)
|
13
|
+
FileUtils.mkdir_p(@dirpath) if !File.exists?(@dirpath)
|
14
|
+
data.each do |url|
|
15
|
+
uri = URI.parse(url)
|
16
|
+
filename = (uri.path =~ %r[/$]) ? \
|
17
|
+
'index.html' : File.basename(uri.path)
|
18
|
+
filepath = File.join(@dirpath, filename)
|
19
|
+
File.open filepath, 'wb' do |dst|
|
20
|
+
open(url) do |src|
|
21
|
+
dst.write(src.read)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/lib/macaroni/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Macaroni::Plugin::Output::Wget do
|
5
|
+
before do
|
6
|
+
@response_body = 'Hello World'
|
7
|
+
@dirpath = './tmp'
|
8
|
+
@wget = described_class.new(@dirpath)
|
9
|
+
end
|
10
|
+
|
11
|
+
it do
|
12
|
+
FileUtils.stub(:mkdir_p)
|
13
|
+
FileUtils.should_receive(:mkdir_p).with(@dirpath)
|
14
|
+
|
15
|
+
resource = double 'resource'
|
16
|
+
resource.stub(:read).and_return(@response_body)
|
17
|
+
OpenURI.stub(:open_uri).and_yield(resource)
|
18
|
+
|
19
|
+
file = StringIO.new
|
20
|
+
File.stub(:open).and_yield(file)
|
21
|
+
|
22
|
+
@wget.exec ['http://example.com/']
|
23
|
+
expect(file.string).to eq @response_body
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macaroni
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mizoR
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: feed-normalizer
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/macaroni/plugin/output/ikachan.rb
|
110
110
|
- lib/macaroni/plugin/output/im_kayac.rb
|
111
111
|
- lib/macaroni/plugin/output/stdout.rb
|
112
|
+
- lib/macaroni/plugin/output/wget.rb
|
112
113
|
- lib/macaroni/version.rb
|
113
114
|
- macaroni.gemspec
|
114
115
|
- spec/macaroni/core/application_spec.rb
|
@@ -119,6 +120,7 @@ files:
|
|
119
120
|
- spec/macaroni/plugin/output/ikachan_spec.rb
|
120
121
|
- spec/macaroni/plugin/output/im_kayac_spec.rb
|
121
122
|
- spec/macaroni/plugin/output/stdout_spec.rb
|
123
|
+
- spec/macaroni/plugin/output/wget_spec.rb
|
122
124
|
- spec/macaroni_spec.rb
|
123
125
|
- spec/spec_helper.rb
|
124
126
|
homepage: https://github.com/mizoR/macaroni
|
@@ -153,5 +155,6 @@ test_files:
|
|
153
155
|
- spec/macaroni/plugin/output/ikachan_spec.rb
|
154
156
|
- spec/macaroni/plugin/output/im_kayac_spec.rb
|
155
157
|
- spec/macaroni/plugin/output/stdout_spec.rb
|
158
|
+
- spec/macaroni/plugin/output/wget_spec.rb
|
156
159
|
- spec/macaroni_spec.rb
|
157
160
|
- spec/spec_helper.rb
|