cut 0.0.2 → 0.0.3
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.
- data/lib/cut/class_methods.rb +5 -5
- data/lib/cut/version.rb +1 -1
- metadata +2 -2
data/lib/cut/class_methods.rb
CHANGED
@@ -2,11 +2,11 @@ module Cut
|
|
2
2
|
module ClassMethods
|
3
3
|
|
4
4
|
def url(new_url)
|
5
|
-
|
5
|
+
@url = new_url
|
6
6
|
end
|
7
7
|
|
8
8
|
def selector(new_selector)
|
9
|
-
|
9
|
+
@selector = new_selector
|
10
10
|
end
|
11
11
|
|
12
12
|
def map(*args)
|
@@ -14,7 +14,7 @@ module Cut
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def all(options = {})
|
17
|
-
endpoint =
|
17
|
+
endpoint = @url.dup
|
18
18
|
options.each {|key,value| endpoint.gsub!("{{#{key}}}", CGI.escape(value)) }
|
19
19
|
response = Client.get(endpoint)
|
20
20
|
|
@@ -24,7 +24,7 @@ module Cut
|
|
24
24
|
private
|
25
25
|
|
26
26
|
def mappings
|
27
|
-
|
27
|
+
@mappings ||= []
|
28
28
|
end
|
29
29
|
|
30
30
|
def add_mapping(name, type, options)
|
@@ -33,7 +33,7 @@ module Cut
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def parse(response)
|
36
|
-
response.css(
|
36
|
+
response.css(@selector).map do |node|
|
37
37
|
new.tap do |instance|
|
38
38
|
mappings.each do |mapping|
|
39
39
|
instance.send("#{mapping.name}=", node.at_css(mapping.selector).value)
|
data/lib/cut/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cut
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|