macaroni 0.0.3 → 0.0.4

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: de6f5db96d312d5132b0c488126d6e79c71c9d06
4
- data.tar.gz: f5674e1459d23c79573b8426951242998f8f16a7
3
+ metadata.gz: e184629ede012d3822209c5c9c7b158d2ee56b30
4
+ data.tar.gz: 136c876209f9efe268739f7aab34919e7f259f63
5
5
  SHA512:
6
- metadata.gz: 5d09ede84f48871a395cffcd84a33f0d6b9e5d966e729371c5bb7d217288cfbf3a059c31689846403c2abd3c213015078dcde31c0b4fe8df47a658de26943d05
7
- data.tar.gz: c5c894adb9f10f1d44abc27cae1ee95bc6b2378fa816ba48694a520feadbbafad9f9557b334960294728f3fd2eba38d8e8c3a0d65a65081f4debc727ffeaf2e2
6
+ metadata.gz: fa5f131dc46eadbf5f158e8f581e1960cffb09ffcc73103be52db06aac1fe9e24ef854beba956878aa66fcae806b75c69ceb62d88e54020edcef7d18812e1aa5
7
+ data.tar.gz: 52d067230af56c926db90e811b0966ce16ecba32cf8e13c731f58bbf0406c64cb22a413c3e8c628127523d2dbe65420b8a794662e38a1676328f939d929b8a41
@@ -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
@@ -8,6 +8,7 @@ require 'macaroni/plugin/filter/deduped'
8
8
  require 'macaroni/plugin/output/stdout'
9
9
  require 'macaroni/plugin/output/im_kayac'
10
10
  require 'macaroni/plugin/output/ikachan'
11
+ require 'macaroni/plugin/output/wget'
11
12
  require 'optparse'
12
13
 
13
14
  module Macaroni
@@ -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
+
@@ -1,3 +1,3 @@
1
1
  module Macaroni
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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.3
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-05 00:00:00.000000000 Z
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