webinspector 0.4.0 → 0.5.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/README.md +8 -2
- data/lib/web_inspector/inspector.rb +17 -0
- data/lib/web_inspector/page.rb +4 -0
- data/lib/web_inspector/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 943a718d012d5b472e7ecdb96d1eb4e6e178bc4a
|
4
|
+
data.tar.gz: c600d322e258a2efd527bde502875655f2819f86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 253f5907d503c96fc19485c58ddd59ec0373a9d4c755ffd5189bfd02bf0851692ffda30c25a7e44c7b2263f6dc300049bdd59b56fcc4f4970aca22d7d6ecb700
|
7
|
+
data.tar.gz: 630e4c3c60de4ef1d057180cea7e09d030de573a4d9dc248d0a61657a7f44049f54b60c633d0f7ebfbe54ee70863f8d615095a4335376d2d6a8ed86527d9ff49
|
data/README.md
CHANGED
@@ -59,13 +59,19 @@ page.meta # metatags of the page
|
|
59
59
|
```ruby
|
60
60
|
page.meta # metatags of the page
|
61
61
|
page.meta['description'] # meta description
|
62
|
-
page.meta['keywords']
|
62
|
+
page.meta['keywords'] # meta keywords
|
63
63
|
```
|
64
64
|
|
65
|
+
## Find words (as array)
|
66
|
+
```ruby
|
67
|
+
page.find(["word1, word2"]) # return {"word1"=>3, "word2"=>1}
|
68
|
+
```
|
69
|
+
|
70
|
+
|
65
71
|
## Contributors
|
66
72
|
|
67
73
|
* Steven Shelby ([@stevenshelby](https://github.com/stevenshelby))
|
68
|
-
|
74
|
+
* Sam Nissen ([@samnissen](https://github.com/samnissen))
|
69
75
|
|
70
76
|
## License
|
71
77
|
The webinspector GEM is released under the MIT License.
|
@@ -24,6 +24,11 @@ module WebInspector
|
|
24
24
|
@meta
|
25
25
|
end
|
26
26
|
|
27
|
+
def find(words)
|
28
|
+
text = @page.at('html').inner_text
|
29
|
+
counter(text.downcase, words)
|
30
|
+
end
|
31
|
+
|
27
32
|
def links
|
28
33
|
get_new_links unless @links
|
29
34
|
return @links
|
@@ -105,6 +110,18 @@ module WebInspector
|
|
105
110
|
|
106
111
|
private
|
107
112
|
|
113
|
+
def counter(text, words)
|
114
|
+
results = []
|
115
|
+
hash = Hash.new
|
116
|
+
|
117
|
+
words.each do |word|
|
118
|
+
hash[word] = text.scan(/#{word.downcase}/).size
|
119
|
+
results.push(hash)
|
120
|
+
hash = Hash.new
|
121
|
+
end
|
122
|
+
return results
|
123
|
+
end
|
124
|
+
|
108
125
|
def get_new_images
|
109
126
|
@images = []
|
110
127
|
@page.css("img").each do |img|
|
data/lib/web_inspector/page.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webinspector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Santangelo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|