ero_getter 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/ero_getter.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ero_getter"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["masarakki"]
@@ -54,6 +54,17 @@ class EroGetter::Downloader::Base
54
54
  instance_variable_get(:@targets)
55
55
  end
56
56
  end
57
+
58
+ def sub_directory(&block)
59
+ define_method(:sub_directory) do
60
+ unless instance_variable_defined?(:@sub_directory)
61
+ dir = self.instance_eval(&block)
62
+ EroGetter::Downloader.mkdir(dir)
63
+ instance_variable_set(:@sub_directory, dir)
64
+ end
65
+ instance_variable_get(:@sub_directory)
66
+ end
67
+ end
57
68
  end
58
69
 
59
70
  end
@@ -7,9 +7,14 @@ describe EroGetter::Downloader::Base do
7
7
  @klazz = Class.new(EroGetter::Downloader::Base) do
8
8
  name 'NijiEro BBS'
9
9
  url _regex
10
+
10
11
  target "ul#sources li a" do |elm|
11
12
  elm[:href]
12
13
  end
14
+
15
+ sub_directory do
16
+ targets.map{|x| x.split(%r{/}).last }.join('/')
17
+ end
13
18
  end
14
19
  @klazz.stub(:to_s).and_return('TestClass')
15
20
  end
@@ -25,6 +30,7 @@ describe EroGetter::Downloader::Base do
25
30
  before do
26
31
  @dl = @klazz.new('http://example.net/10101010.html')
27
32
  @dl.stub(:open).and_return(File.open(sample_path('sample.html')))
33
+ EroGetter::Downloader.stub(:mkdir).and_return(true)
28
34
  end
29
35
  its(:name) { should == 'NijiEro BBS' }
30
36
  its(:url_regex) { should == regex }
@@ -35,6 +41,14 @@ describe EroGetter::Downloader::Base do
35
41
  its(:url) { should == 'http://example.net/10101010.html' }
36
42
  its(:targets) { should == ['https://github.com/masarakki/ero_getter_server',
37
43
  'https://github.com/masarakki/ero_getter_chrome_extension'] }
44
+ describe :sub_directory do
45
+ its(:sub_directory) { should == 'ero_getter_server/ero_getter_chrome_extension' }
46
+ it "mkdir only once" do
47
+ EroGetter::Downloader.should_receive(:mkdir).with('ero_getter_server/ero_getter_chrome_extension').exactly(1)
48
+ @dl.sub_directory
49
+ @dl.sub_directory
50
+ end
51
+ end
38
52
  end
39
53
  context :url_mismatch do
40
54
  it {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ero_getter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -180,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
180
  version: '0'
181
181
  segments:
182
182
  - 0
183
- hash: -3104763422106775519
183
+ hash: 1155287302627282076
184
184
  required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements: