scraped 0.1.0 → 0.2.0
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/CHANGELOG.md +8 -0
- data/lib/scraped/document.rb +42 -0
- data/lib/scraped/html.rb +2 -2
- data/lib/scraped/request/strategy/live_request.rb +1 -1
- data/lib/scraped/request/strategy.rb +1 -1
- data/lib/scraped/request.rb +1 -1
- data/lib/scraped/response/decorator/absolute_urls.rb +1 -1
- data/lib/scraped/response/decorator.rb +1 -1
- data/lib/scraped/response.rb +1 -1
- data/lib/scraped/response_decorator.rb +1 -1
- data/lib/scraped/version.rb +2 -2
- data/lib/scraped.rb +1 -37
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf5c0cab0f1d7991d8e20be4a18742d523dee613
|
4
|
+
data.tar.gz: 43a801257aace7d860415183fb8b936db92cea2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07ff312f45e7a43ebd88d0894efa224324f0d433212d360c89a268ae121746d236587c16193e1f6bc6474550f8a8110017931fb3958b9ed434e3c4550cfea54
|
7
|
+
data.tar.gz: 281394ecbcb4ce1d9563963b311256b498770c3b18a26039b1c0622e9acace957ff81de9806379021f2a9f668ba80fb6a428b72afc3ccad8ae64d7080192c079
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
7
7
|
|
8
|
+
## 0.2.0 - 2017-01-04
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
- The logic that was in the `Scraped` class is now in `Scraped::Document`.
|
13
|
+
- `Scraped::HTML` now inherits from `Scraped::Document` rather than `Scraped`.
|
14
|
+
- The top level `Scraped` constant is now a `module` instead of a `class`.
|
15
|
+
|
8
16
|
## 0.1.0 - 2017-01-04
|
9
17
|
|
10
18
|
### Added
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'field_serializer'
|
4
|
+
|
5
|
+
module Scraped
|
6
|
+
# Abstract class which scrapers can extend to implement their functionality.
|
7
|
+
class Document
|
8
|
+
include FieldSerializer
|
9
|
+
|
10
|
+
def self.decorator(klass, config = {})
|
11
|
+
decorators << config.merge(decorator: klass)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.decorators
|
15
|
+
@decorators ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.inherited(klass)
|
19
|
+
klass.decorators.concat(decorators)
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(response:)
|
24
|
+
@original_response = response
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :original_response
|
30
|
+
|
31
|
+
def response
|
32
|
+
@response ||= ResponseDecorator.new(
|
33
|
+
response: original_response,
|
34
|
+
decorators: self.class.decorators
|
35
|
+
).response
|
36
|
+
end
|
37
|
+
|
38
|
+
def url
|
39
|
+
response.url
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/scraped/html.rb
CHANGED
data/lib/scraped/request.rb
CHANGED
data/lib/scraped/response.rb
CHANGED
data/lib/scraped/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.
|
1
|
+
module Scraped
|
2
|
+
VERSION = '0.2.0'.freeze
|
3
3
|
end
|
data/lib/scraped.rb
CHANGED
@@ -1,42 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'field_serializer'
|
4
2
|
require 'require_all'
|
5
3
|
require_rel 'scraped'
|
6
4
|
|
7
|
-
|
8
|
-
class Scraped
|
9
|
-
include FieldSerializer
|
10
|
-
|
11
|
-
def self.decorator(klass, config = {})
|
12
|
-
decorators << config.merge(decorator: klass)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.decorators
|
16
|
-
@decorators ||= []
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.inherited(klass)
|
20
|
-
klass.decorators.concat(decorators)
|
21
|
-
super
|
22
|
-
end
|
23
|
-
|
24
|
-
def initialize(response:)
|
25
|
-
@original_response = response
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
attr_reader :original_response
|
31
|
-
|
32
|
-
def response
|
33
|
-
@response ||= ResponseDecorator.new(
|
34
|
-
response: original_response,
|
35
|
-
decorators: self.class.decorators
|
36
|
-
).response
|
37
|
-
end
|
38
|
-
|
39
|
-
def url
|
40
|
-
response.url
|
41
|
-
end
|
5
|
+
module Scraped
|
42
6
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scraped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- EveryPolitician
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- bin/setup
|
142
142
|
- lib/scraped.rb
|
143
143
|
- lib/scraped/core_ext.rb
|
144
|
+
- lib/scraped/document.rb
|
144
145
|
- lib/scraped/html.rb
|
145
146
|
- lib/scraped/request.rb
|
146
147
|
- lib/scraped/request/strategy.rb
|