validate_page 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bdeaba8274a2cde5b7d63d3cd2741a7080857823
4
+ data.tar.gz: 38007f19b0dc7c34e691d281d67875bca7abd22b
5
+ SHA512:
6
+ metadata.gz: ab4687fe956fbaf817dd9c8a07da449d02831f3516f450a232e6816a81c6fee22ab99b8c1fc25fc283753376d2693abe487da4198ea96eb93fb4cd366f406f66
7
+ data.tar.gz: 314400d1f9e18496a1e0a45ecf5cd817090550067bab7425cd750ecbd08b6a7518639b13f90fd368a580bec9d3b7e3cd321091bfb72cde4690fe9b913ae07c34
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'railties'
4
+
5
+ group :development do
6
+ gem "rspec", '~> 2.10', '> 2.10.0'
7
+ gem "rdoc", '~> 4.0', '> 4.0.0'
8
+ gem "bundler", '~> 1.2', '> 1.2.0'
9
+ gem "jeweler", '~> 1.8', '> 1.8.4'
10
+ gem "simplecov",'~> 0.5'
11
+ end
12
+
13
+ gem 'capybara'
14
+ gem 'selenium-webdriver'
data/Gemfile.lock ADDED
@@ -0,0 +1,99 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionpack (3.0.8)
6
+ activemodel (= 3.0.8)
7
+ activesupport (= 3.0.8)
8
+ builder (~> 2.1.2)
9
+ erubis (~> 2.6.6)
10
+ i18n (~> 0.5.0)
11
+ rack (~> 1.2.1)
12
+ rack-mount (~> 0.6.14)
13
+ rack-test (~> 0.5.7)
14
+ tzinfo (~> 0.3.23)
15
+ activemodel (3.0.8)
16
+ activesupport (= 3.0.8)
17
+ builder (~> 2.1.2)
18
+ i18n (~> 0.5.0)
19
+ activesupport (3.0.8)
20
+ addressable (2.3.5)
21
+ builder (2.1.2)
22
+ diff-lcs (1.2.5)
23
+ erubis (2.6.6)
24
+ abstract (>= 1.0.0)
25
+ faraday (0.8.7)
26
+ multipart-post (~> 1.1)
27
+ git (1.2.5)
28
+ github_api (0.10.1)
29
+ addressable
30
+ faraday (~> 0.8.1)
31
+ hashie (>= 1.2)
32
+ multi_json (~> 1.4)
33
+ nokogiri (~> 1.5.2)
34
+ oauth2
35
+ hashie (2.0.5)
36
+ highline (1.6.19)
37
+ httpauth (0.2.0)
38
+ i18n (0.5.0)
39
+ jeweler (1.8.6)
40
+ builder
41
+ bundler (~> 1.0)
42
+ git (>= 1.2.5)
43
+ github_api (= 0.10.1)
44
+ highline (>= 1.6.15)
45
+ nokogiri (= 1.5.10)
46
+ rake
47
+ rdoc
48
+ json (1.8.1)
49
+ jwt (0.1.8)
50
+ multi_json (>= 1.5)
51
+ multi_json (1.10.1)
52
+ multi_xml (0.5.4)
53
+ multipart-post (1.2.0)
54
+ nokogiri (1.5.10)
55
+ oauth2 (0.9.2)
56
+ faraday (~> 0.8)
57
+ httpauth (~> 0.2)
58
+ jwt (~> 0.1.4)
59
+ multi_json (~> 1.0)
60
+ multi_xml (~> 0.5)
61
+ rack (~> 1.2)
62
+ rack (1.2.8)
63
+ rack-mount (0.6.14)
64
+ rack (>= 1.0.0)
65
+ rack-test (0.5.7)
66
+ rack (>= 1.0)
67
+ railties (3.0.8)
68
+ actionpack (= 3.0.8)
69
+ activesupport (= 3.0.8)
70
+ rake (>= 0.8.7)
71
+ thor (~> 0.14.4)
72
+ rake (10.1.1)
73
+ rdoc (4.1.2)
74
+ json (~> 1.4)
75
+ rspec (2.13.0)
76
+ rspec-core (~> 2.13.0)
77
+ rspec-expectations (~> 2.13.0)
78
+ rspec-mocks (~> 2.13.0)
79
+ rspec-core (2.13.1)
80
+ rspec-expectations (2.13.0)
81
+ diff-lcs (>= 1.1.3, < 2.0)
82
+ rspec-mocks (2.13.0)
83
+ simplecov (0.7.1)
84
+ multi_json (~> 1.0)
85
+ simplecov-html (~> 0.7.1)
86
+ simplecov-html (0.7.1)
87
+ thor (0.14.6)
88
+ tzinfo (0.3.37)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ bundler (~> 1.2, > 1.2.0)
95
+ jeweler (~> 1.8, > 1.8.4)
96
+ railties
97
+ rdoc (~> 4.0, > 4.0.0)
98
+ rspec (~> 2.10, > 2.10.0)
99
+ simplecov (~> 0.5)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dileep Nandanam
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,43 @@
1
+ class ValidatePage
2
+ require 'capybara/dsl'
3
+ include Capybara::DSL
4
+ Capybara.register_driver :selenium do |app|
5
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
6
+ end
7
+ Capybara.current_driver = Capybara.javascript_driver
8
+
9
+ @@parser = nil
10
+
11
+ def self.set_parser(name)
12
+ @@parser = name
13
+ end
14
+
15
+ def self.validator
16
+ @@parser
17
+ end
18
+
19
+ def self.on(attrib, content, message)
20
+ @@attrib = attrib
21
+ @@content = content
22
+ @@message = message
23
+ return self
24
+ end
25
+
26
+ def validate(record)
27
+ if(present record[@@attrib])
28
+ record.errors.add @@attrib, (@@message.present? ? @@message : 'page contains inappropriate content')
29
+ end
30
+ end
31
+
32
+ def present(url)
33
+ if @@parser == :text_parser
34
+ page = Net::HTTP.get_response(URI.parse(url)).response.body
35
+ @@content.split(/[;,\s\.]+/).any?{|c| page.include?(c)}
36
+ else
37
+ uri = URI.parse(url.chomp)
38
+ Capybara.app_host = uri.scheme + '://' + uri.host
39
+ visit uri.path
40
+ @@content.split(/[;,\s\.]+/).any?{|c| page.has_text?(c)}
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "validate_page"
3
+ s.version = "0.1.0"
4
+
5
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.require_paths = ["lib"]
7
+ s.authors = ["Dileep Nandanam"]
8
+ s.date = "2014-11-20"
9
+ s.description = "imogee gem"
10
+ s.email = "dileepsnandanam@gmail.com"
11
+ s.extra_rdoc_files = [
12
+ "LICENSE.txt"
13
+ ]
14
+ s.files = [
15
+ "Gemfile",
16
+ "Gemfile.lock",
17
+ "LICENSE.txt",
18
+ "VERSION",
19
+ "lib/validate_page.rb",
20
+ "validate_page.gemspec",
21
+ ]
22
+ s.homepage = "http://github.com/dileepnandanam/validate_page"
23
+ s.licenses = ["MIT"]
24
+ s.rubygems_version = "2.2.2"
25
+ s.summary = "rails gem for validating url by crawling page for specific unwanted content"
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: validate_page
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dileep Nandanam
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: imogee gem
14
+ email: dileepsnandanam@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files:
18
+ - LICENSE.txt
19
+ files:
20
+ - Gemfile
21
+ - Gemfile.lock
22
+ - LICENSE.txt
23
+ - VERSION
24
+ - lib/validate_page.rb
25
+ - validate_page.gemspec
26
+ homepage: http://github.com/dileepnandanam/validate_page
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.5.2
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: rails gem for validating url by crawling page for specific unwanted content
50
+ test_files: []