ero_getter 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/ero_getter.gemspec +1 -1
- data/lib/ero_getter.rb +5 -0
- data/lib/ero_getter/downloader.rb +5 -3
- data/lib/ero_getter/downloader/base.rb +9 -3
- data/spec/downloader/base_spec.rb +3 -8
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/ero_getter.gemspec
CHANGED
data/lib/ero_getter.rb
CHANGED
@@ -12,9 +12,11 @@ class EroGetter::Downloader
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def mkdir(path)
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
unless File.exists?(path)
|
16
|
+
basedir = File.dirname(path)
|
17
|
+
mkdir(basedir) unless File.exists?(basedir)
|
18
|
+
Dir.mkdir(path)
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def unzip(zip_data)
|
@@ -13,6 +13,14 @@ class EroGetter::Downloader::Base
|
|
13
13
|
self.class.to_s.underscore
|
14
14
|
end
|
15
15
|
|
16
|
+
def directory
|
17
|
+
unless @dir
|
18
|
+
@dir = File.join(EroGetter.directory, base_dir, sub_directory)
|
19
|
+
EroGetter::Downloader.mkdir(@dir)
|
20
|
+
end
|
21
|
+
@dir
|
22
|
+
end
|
23
|
+
|
16
24
|
def http_client
|
17
25
|
@http_client ||= HTTPClient.new
|
18
26
|
end
|
@@ -58,9 +66,7 @@ class EroGetter::Downloader::Base
|
|
58
66
|
def sub_directory(&block)
|
59
67
|
define_method(:sub_directory) do
|
60
68
|
unless instance_variable_defined?(:@sub_directory)
|
61
|
-
|
62
|
-
EroGetter::Downloader.mkdir(dir)
|
63
|
-
instance_variable_set(:@sub_directory, dir)
|
69
|
+
instance_variable_set(:@sub_directory, self.instance_eval(&block))
|
64
70
|
end
|
65
71
|
instance_variable_get(:@sub_directory)
|
66
72
|
end
|
@@ -31,6 +31,7 @@ describe EroGetter::Downloader::Base do
|
|
31
31
|
@dl = @klazz.new('http://example.net/10101010.html')
|
32
32
|
@dl.stub(:open).and_return(File.open(sample_path('sample.html')))
|
33
33
|
EroGetter::Downloader.stub(:mkdir).and_return(true)
|
34
|
+
EroGetter.stub('directory').and_return('/tmp')
|
34
35
|
end
|
35
36
|
its(:name) { should == 'NijiEro BBS' }
|
36
37
|
its(:url_regex) { should == regex }
|
@@ -41,14 +42,8 @@ describe EroGetter::Downloader::Base do
|
|
41
42
|
its(:url) { should == 'http://example.net/10101010.html' }
|
42
43
|
its(:targets) { should == ['https://github.com/masarakki/ero_getter_server',
|
43
44
|
'https://github.com/masarakki/ero_getter_chrome_extension'] }
|
44
|
-
|
45
|
-
|
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
|
45
|
+
its(:sub_directory) { should == 'ero_getter_server/ero_getter_chrome_extension' }
|
46
|
+
its(:directory) { should == '/tmp/test_class/ero_getter_server/ero_getter_chrome_extension' }
|
52
47
|
end
|
53
48
|
context :url_mismatch do
|
54
49
|
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.
|
4
|
+
version: 0.1.3
|
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:
|
183
|
+
hash: 4601793703788942628
|
184
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
185
|
none: false
|
186
186
|
requirements:
|