webinspector 0.4.0 → 0.5.0

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
  SHA1:
3
- metadata.gz: c9168c8258b2cc38cad1e30e12d1f42c07d2e0ce
4
- data.tar.gz: 302adea791b1d4a4afd03a3fa36e5220244a9896
3
+ metadata.gz: 943a718d012d5b472e7ecdb96d1eb4e6e178bc4a
4
+ data.tar.gz: c600d322e258a2efd527bde502875655f2819f86
5
5
  SHA512:
6
- metadata.gz: d43248b9c86fb8da996fa874a8ae3202ce9b033cc0d38c015ece9d55b65576a5e55a778929a8afa950feb3db4a51d2637dbbbf2ca6a1de5c460f433ccb1356a5
7
- data.tar.gz: c5364539ff2f5701f01feff1d931bef49e27abeeeba5cbfc959c1d932a91e3e8276482cd7b7ed7b64d2f3c8ad83d2f174d91c830e462d840657ea670e490f89a
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'] # 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
- * Sam Nissen ([@samnissen](https://github.com/samnissen))
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|
@@ -43,6 +43,10 @@ module WebInspector
43
43
  @inspector.meta
44
44
  end
45
45
 
46
+ def find(words)
47
+ @inspector.find(words)
48
+ end
49
+
46
50
  def url
47
51
  @request.url
48
52
  end
@@ -1,3 +1,3 @@
1
1
  module WebInspector
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.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-09 00:00:00.000000000 Z
11
+ date: 2015-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler