spidy 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/spidy/binder/json.rb +4 -5
- data/lib/spidy/binder/xml.rb +4 -4
- data/lib/spidy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 325acf19ee696f081052597f6e7bc327d7f57b024340661ceb314f2c86501963
|
4
|
+
data.tar.gz: f83f4cbb62b5d09ed3707711ed9ab9dd273e71966a4fff40cef481225ed9f473
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed3bfa6b4868a1603bec5bba17affeb6f6674e606a25cd0f84cbf56cfcf7bd4fba11b01cfc20532dc64cbffb8fa648c87a34b03f888e11545cf92171d0d40f0d
|
7
|
+
data.tar.gz: c37322aaa95e33a3697233c66245965fd9690329f678ba9e509c31117984318c5a8aaf5145d08f713c05b8d53b0129488347da9acec7cc97a16d0e8d3e9eef96
|
data/lib/spidy/binder/json.rb
CHANGED
@@ -5,12 +5,11 @@
|
|
5
5
|
#
|
6
6
|
class Spidy::Binder::Json
|
7
7
|
class << self
|
8
|
-
attr_reader :
|
9
|
-
|
10
|
-
@names = []
|
8
|
+
attr_reader :attribute_names
|
11
9
|
|
12
10
|
def let(name, *query, &block)
|
13
|
-
@
|
11
|
+
@attribute_names ||= []
|
12
|
+
@attribute_names << name
|
14
13
|
define_method(name) do
|
15
14
|
result = json.dig(*query) if query.present?
|
16
15
|
return result if block.nil?
|
@@ -33,6 +32,6 @@ class Spidy::Binder::Json
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def to_h
|
36
|
-
self.class.
|
35
|
+
self.class.attribute_names.map { |name| [name, send(name)] }.to_h
|
37
36
|
end
|
38
37
|
end
|
data/lib/spidy/binder/xml.rb
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
#
|
6
6
|
class Spidy::Binder::Xml
|
7
7
|
class << self
|
8
|
-
attr_reader :
|
9
|
-
@names = []
|
8
|
+
attr_reader :attribute_names
|
10
9
|
|
11
10
|
def self.let(name, query = nil, &block)
|
12
|
-
@
|
11
|
+
@attribute_names ||= []
|
12
|
+
@attribute_names << name
|
13
13
|
define_method(name) do
|
14
14
|
return xml.at(query)&.text if block.nil?
|
15
15
|
return instance_exec(&block) if query.blank?
|
@@ -34,6 +34,6 @@ class Spidy::Binder::Xml
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def to_h
|
37
|
-
self.class.
|
37
|
+
self.class.attribute_names.map { |name| [name, send(name)] }.to_h
|
38
38
|
end
|
39
39
|
end
|
data/lib/spidy/version.rb
CHANGED