scrap_kit 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d30e6aebb388e92e31b33c920619fefec3a1a5ac2e6c44d1dd14c7f865cdc816
4
- data.tar.gz: 17ad0fdd2fcff8f8f11f6000cfa4a34c90243d14012b919cbc243dddde6b7495
3
+ metadata.gz: f6878a6c8316fe369d5db4422d09a532fc665a8d256e326c200fca2a2efe7994
4
+ data.tar.gz: c764d98eae73e80fc3f1027844bce80a8842ec0979786727fad37cad21224e42
5
5
  SHA512:
6
- metadata.gz: 9c427bc98598612c53cb75e355d101c37f998642d75fc4daf11de4cacdc337b6099a588b884c43813d268d38fcffd78178114d0a07fe0589ec4f5e670a06d81a
7
- data.tar.gz: 7b825d7e22ac8bcbb8b1cd3131f9c4a893f86ae6ae8874bf6bfc6ab1bb0499d33da1906632a8c811cb726c60e6d8c5f3e76035aecb93745632759fe19531667c
6
+ metadata.gz: d9fa5af8f21411180b93979ebe6f4a61109bd1b33788606d4517312a2411a2b8d0c0f24c85e9067215efdbe16317b7ec8ce8e650f3ac5d359a6f04290cd28510
7
+ data.tar.gz: 756ec242ad61959651c28011c60f8acf065e82493d439eb67b89639128a20d7ece4bfcaec535291573236a6dc98cd5bb655f2d94d996c79415cd107413f52ecf
data/.gitignore CHANGED
@@ -9,4 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
12
13
  .DS_Store
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.2] 2020-06-18
4
+
5
+ ### Changed/Added
6
+ - Add support for selector arrays to filter elements based on conditions
7
+
8
+ ## [0.1.1] 2020-05-18
9
+
10
+ ### Changed/Added
11
+ - Update activesupport requirement from = 6.0.2.1 to = 6.0.3.1
12
+
3
13
  ## [0.1.0] 2020-02-09
4
14
 
5
15
  ### Changed/Added
@@ -1,23 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- scrap_kit (0.1.0)
4
+ scrap_kit (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activesupport (6.0.2.1)
9
+ activesupport (6.0.3.1)
10
10
  concurrent-ruby (~> 1.0, >= 1.0.2)
11
11
  i18n (>= 0.7, < 2)
12
12
  minitest (~> 5.1)
13
13
  tzinfo (~> 1.1)
14
- zeitwerk (~> 2.2)
14
+ zeitwerk (~> 2.2, >= 2.2.2)
15
15
  childprocess (3.0.0)
16
- concurrent-ruby (1.1.5)
16
+ concurrent-ruby (1.1.6)
17
17
  diff-lcs (1.3)
18
18
  i18n (1.8.2)
19
19
  concurrent-ruby (~> 1.0)
20
- minitest (5.14.0)
20
+ minitest (5.14.1)
21
21
  rake (13.0.1)
22
22
  regexp_parser (1.6.0)
23
23
  rspec (3.9.0)
@@ -38,18 +38,18 @@ GEM
38
38
  childprocess (>= 0.5, < 4.0)
39
39
  rubyzip (>= 1.2.2)
40
40
  thread_safe (0.3.6)
41
- tzinfo (1.2.6)
41
+ tzinfo (1.2.7)
42
42
  thread_safe (~> 0.1)
43
43
  watir (6.16.5)
44
44
  regexp_parser (~> 1.2)
45
45
  selenium-webdriver (~> 3.6)
46
- zeitwerk (2.2.2)
46
+ zeitwerk (2.3.0)
47
47
 
48
48
  PLATFORMS
49
49
  ruby
50
50
 
51
51
  DEPENDENCIES
52
- activesupport (= 6.0.2.1)
52
+ activesupport (= 6.0.3.1)
53
53
  bundler (~> 2.0)
54
54
  rake (~> 13.0)
55
55
  rspec (~> 3.0)
@@ -57,4 +57,4 @@ DEPENDENCIES
57
57
  watir (~> 6.16.5)
58
58
 
59
59
  BUNDLED WITH
60
- 2.0.2
60
+ 2.1.4
@@ -32,6 +32,26 @@ module ScrapKit
32
32
  def run_step(browser, step)
33
33
  end
34
34
 
35
+ def elements_from_selector(browser_or_element, selector)
36
+ if selector.is_a?(String)
37
+ browser_or_element.elements(css: selector)
38
+ elsif selector.is_a?(Array)
39
+ *remainder, condition = selector
40
+ elements = browser_or_element
41
+
42
+ remainder.each do |item|
43
+ elements = elements.elements(css: item)
44
+ end
45
+
46
+ elements.filter do |element|
47
+ condition_key = condition.keys[0].to_s
48
+ condition_value = condition.values[0]
49
+ found_element = element.element(css: condition_key)
50
+ found_element&.text_content&.match(condition_value)
51
+ end
52
+ end
53
+ end
54
+
35
55
  def extract_attribute(browser_or_element, selector_or_hash)
36
56
  if selector_or_hash.is_a?(String)
37
57
  browser_or_element.element(css: selector_or_hash)&.text_content
@@ -39,7 +59,7 @@ module ScrapKit
39
59
  selector = selector_or_hash[:selector]
40
60
  selector_for_children_attributes = selector_or_hash[:children_attributes]
41
61
 
42
- browser_or_element.elements(css: selector).map do |element|
62
+ elements_from_selector(browser_or_element, selector).map do |element|
43
63
  output = {}
44
64
 
45
65
  selector_for_children_attributes.each do |child_attribute_name, child_selector|
@@ -1,3 +1,3 @@
1
1
  module ScrapKit
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "bundler", "~> 2.0"
32
32
  spec.add_development_dependency "rake", "~> 13.0"
33
33
  spec.add_development_dependency "rspec", "~> 3.0"
34
- spec.add_development_dependency "activesupport", "6.0.2.1"
34
+ spec.add_development_dependency "activesupport", "6.0.3.1"
35
35
  spec.add_development_dependency "watir", "~> 6.16.5"
36
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrap_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gustavo Leon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 6.0.2.1
61
+ version: 6.0.3.1
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 6.0.2.1
68
+ version: 6.0.3.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: watir
71
71
  requirement: !ruby/object:Gem::Requirement