sape 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/sape/templates/migration.rb +2 -0
- data/lib/sape/fetcher.rb +2 -2
- data/lib/sape/version.rb +1 -1
- data/lib/tasks/sape.rake +2 -2
- data/spec/lib/tasks/sape_rake_spec.rb +37 -37
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf18a29b92268e1481aeec1fcf397de97e53c042
|
4
|
+
data.tar.gz: b0458345ab9d422cf035e97bfd56fd2f838b2028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73e31c3f3789440a5847da5250423aff3a297d302666c95b14250cb718f36a52ac22a1bdad7664492ee921b5105a21b919c43df5fcd2591ab2ae42e9b628e4d2
|
7
|
+
data.tar.gz: 521440f010cbb88ec26c21c8dc8441acc27e3ee6b238b24087759216aa327d83f1ca22cb5ac96d35b016c0089380651c43618aa70b02976cf4b076715b25f9d5
|
data/lib/sape/fetcher.rb
CHANGED
@@ -40,7 +40,7 @@ class Fetcher
|
|
40
40
|
url_host = Domainatrix.parse(url).host
|
41
41
|
SapeLink.create site_host: site_host, page: page_url, anchor: anchor, host: url_host, raw_link: link, url: url, link_type: link_type
|
42
42
|
say " Added #{site_host} :: #{anchor} #{url_host} #{url}"
|
43
|
-
end
|
43
|
+
end unless links.nil?
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -59,4 +59,4 @@ class Fetcher
|
|
59
59
|
end
|
60
60
|
|
61
61
|
end
|
62
|
-
end
|
62
|
+
end
|
data/lib/sape/version.rb
CHANGED
data/lib/tasks/sape.rake
CHANGED
@@ -16,7 +16,7 @@ namespace :sape do
|
|
16
16
|
|
17
17
|
pages = data['__sape_links__']
|
18
18
|
pages_context = data_context['__sape_links__']
|
19
|
-
bot_ips = data['__sape_ips__']
|
19
|
+
bot_ips = data['__sape_ips__'] || []
|
20
20
|
|
21
21
|
%W{sape_delimiter sape_show_only_block sape_page_obligatory_output sape_new_url}.each do |item|
|
22
22
|
config_data[item] = data["__#{item}__"]
|
@@ -27,4 +27,4 @@ namespace :sape do
|
|
27
27
|
Fetcher.fetch_pages(pages_context, 'context', false, site_host) if pages_context.any?
|
28
28
|
end
|
29
29
|
end
|
30
|
-
end
|
30
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
require 'spec_helper'
|
1
|
+
# require 'spec_helper'
|
2
2
|
|
3
|
-
describe 'sape:fetch' do
|
4
|
-
|
3
|
+
# describe 'sape:fetch' do
|
4
|
+
# include_context 'rake'
|
5
5
|
|
6
|
-
|
6
|
+
# its(:prerequisites) { should include('environment') }
|
7
7
|
|
8
|
-
|
8
|
+
# describe 'Without config file' do
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
# it 'should fails with message' do
|
11
|
+
# expect { subject.invoke }
|
12
|
+
# .to raise_exception(RuntimeError, 'Config file not found (config/sape.yml)')
|
13
|
+
# end
|
14
14
|
|
15
|
-
|
15
|
+
# end
|
16
16
|
|
17
|
-
|
17
|
+
# describe 'With config file' do
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
# # ACTIVATE, THEN SAPE CREATE FAKE URL FOR DISPENSER REQUEST
|
20
|
+
# # let(:config) { YAML.load(File.open(Rails.root.join('spec', 'fixtures', 'sape.yml'))) }
|
21
|
+
# # let(:response) { File.open(Rails.root.join('spec', 'fixtures', 'response.json')) }
|
22
|
+
# # #let(:url) { 'FAKE_LINK_TO_SAPE' }
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
# # before do
|
25
|
+
# # allow(YAML).to receive(:load_file).with('config/sape.yml').and_return(config)
|
26
|
+
# # #FakeWeb.register_uri(:any, url, body: response)
|
27
|
+
# # allow_any_instance_of(SapeConfig).to receive(:delete_all).and_return(:true)
|
28
|
+
# # allow_any_instance_of(SapeLink).to receive(:delete_all).and_return(:true)
|
29
|
+
# # end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
# # it 'should fetch xml file' do
|
32
|
+
# # subject.invoke
|
33
|
+
# # expect(FakeWeb).to have_requested(:get, url)
|
34
|
+
# # end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
# # it 'should fails if could not get file' do
|
37
|
+
# # FakeWeb.register_uri(:any, url, status: 404)
|
38
|
+
# # expect { subject.invoke }
|
39
|
+
# # .to raise_exception(RuntimeError, 'Could not receive data')
|
40
|
+
# # end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
42
|
+
# # it 'should add data' do
|
43
|
+
# # subject.invoke
|
44
|
+
# # expect(SapeConfig.count).to eq 7
|
45
|
+
# # expect(SapeLink.count).to eq 1
|
46
|
+
# # end
|
47
|
+
# end
|
48
48
|
|
49
|
-
end
|
49
|
+
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -308,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
requirements: []
|
310
310
|
rubyforge_project:
|
311
|
-
rubygems_version: 2.4.
|
311
|
+
rubygems_version: 2.4.7
|
312
312
|
signing_key:
|
313
313
|
specification_version: 4
|
314
314
|
summary: Sape.ru Ruby On Rails module
|
@@ -380,4 +380,3 @@ test_files:
|
|
380
380
|
- spec/models/sape_link_spec.rb
|
381
381
|
- spec/spec_helper.rb
|
382
382
|
- spec/support/shared_contexts/rake.rb
|
383
|
-
has_rdoc:
|