page_source 0.0.1

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: 389560ca8a8aef3866e3ba9d658ac90449b9a910
4
+ data.tar.gz: fe2509b6365d5d02639e157db2e0cd0566afbe70
5
+ SHA512:
6
+ metadata.gz: c1f5124ab71dd3effbc90f00e7b16ac5a4b1bb75eb52545249c5462356120c7b4f6a95d0cdd4d001c2e83b3fb349b6daa657caf0ce4a109f7424744e8cefeb6d
7
+ data.tar.gz: 686b222de4dc1069b19b645adc04adcea3b29bc8e8aebce3b561705356b2e40eb9f8fa2dfb5ffd2bfdc4a43a5fd14c223f93cd1c3aff39f2bb456f08175b16d1
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+ group :test do
3
+ gem "rspec"
4
+ gem 'coveralls', '>=0.5.7', :require => false
5
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,59 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionpack (4.1.6)
5
+ actionview (= 4.1.6)
6
+ activesupport (= 4.1.6)
7
+ rack (~> 1.5.2)
8
+ rack-test (~> 0.6.2)
9
+ actionview (4.1.6)
10
+ activesupport (= 4.1.6)
11
+ builder (~> 3.1)
12
+ erubis (~> 2.7.0)
13
+ activesupport (4.1.6)
14
+ i18n (~> 0.6, >= 0.6.9)
15
+ json (~> 1.7, >= 1.7.7)
16
+ minitest (~> 5.1)
17
+ thread_safe (~> 0.1)
18
+ tzinfo (~> 1.1)
19
+ builder (3.2.2)
20
+ diff-lcs (1.2.5)
21
+ erubis (2.7.0)
22
+ i18n (0.6.11)
23
+ json (1.8.1)
24
+ minitest (5.4.1)
25
+ rack (1.5.2)
26
+ rack-test (0.6.2)
27
+ rack (>= 1.0)
28
+ railties (4.1.6)
29
+ actionpack (= 4.1.6)
30
+ activesupport (= 4.1.6)
31
+ rake (>= 0.8.7)
32
+ thor (>= 0.18.1, < 2.0)
33
+ rake (10.3.2)
34
+ rspec-core (3.1.2)
35
+ rspec-support (~> 3.1.0)
36
+ rspec-expectations (3.1.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.1.0)
39
+ rspec-mocks (3.1.0)
40
+ rspec-support (~> 3.1.0)
41
+ rspec-rails (3.1.0)
42
+ actionpack (>= 3.0)
43
+ activesupport (>= 3.0)
44
+ railties (>= 3.0)
45
+ rspec-core (~> 3.1.0)
46
+ rspec-expectations (~> 3.1.0)
47
+ rspec-mocks (~> 3.1.0)
48
+ rspec-support (~> 3.1.0)
49
+ rspec-support (3.1.0)
50
+ thor (0.19.1)
51
+ thread_safe (0.3.4)
52
+ tzinfo (1.2.2)
53
+ thread_safe (~> 0.1)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ rspec-rails
@@ -0,0 +1,8 @@
1
+ require 'net/http'
2
+ module PageSource
3
+ def get_page_source url
4
+ return "url should not be empty" if url.nil? || url.strip.empty?
5
+ uri = URI(url)
6
+ Net::HTTP.get(uri) rescue "Url Formate is not currect"
7
+ end
8
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ include PageSource
3
+
4
+ describe PageSource do
5
+ describe '#get_page_source' do
6
+ it 'should give error message for nil url' do
7
+ expected = 'url should not be empty'
8
+ actual = get_page_source nil
9
+ expected.should == actual
10
+ end
11
+
12
+ it 'should give error message for empty url' do
13
+ expected = 'url should not be empty'
14
+ actual = get_page_source ""
15
+ expected.should == actual
16
+ end
17
+
18
+ it 'should give error message when url is nor currect' do
19
+ expected = 'Url Formate is not currect'
20
+ actual = get_page_source "not_a_valid_url"
21
+ expected.should == actual
22
+ end
23
+
24
+ it 'should give page source with curect url' do
25
+ expected = "<!DOCTYPE html> <html> <head> <title>Heroku | Welcome to your new app!</title> <style type='text/css'> body { background-color: white; color: #333333; font-family: Arial, sans-serif; margin: 0; padding: 36px; line-height: 1; font-size: 14px; } .section { margin-bottom: 36px; } .section.friendly { color: #222222; } .section.friendly h1 { font-size: 26px; background-color: #dad8e4; padding: 18px 22px 15px 22px; margin: 0; overflow: hidden; } .section.friendly h1 strong { display: inline-block; float: left; } .section.friendly h1 small { display: inline-block; float: right; text-align: right; font-size: 18px; padding-top: 4px; color: #333333; } .section.friendly .article { border: 4px solid #dad8e4; padding: 24px 18px 18px 18px; } .section.friendly .article h3 { font-size: 20px; margin: 0 0 18px 0; } .section.friendly .article a { color: #6b6ceb; } .section.friendly .article a:visited { color: #1d1d3b; } .section.friendly .article p { font-size: 14px; } .section.friendly .article ul { list-style-type: square; } .section.original { background-color: #eeeeee; color: #444444; } .section.original h2 { background-color: #dddddd; margin: 0; padding: 18px 22px 18px 22px; font-size: 20px; } .section.original pre { margin: 0; padding: 18px 22px 18px 22px; overflow: auto; font-family: monaco, monospaced; } .section.original pre code { display: block; font-size: 11px; width: 100%; } </style> </head> <body> <div class='container'> <div class='section friendly'> <h1><strong>Heroku | Welcome to your new app!</strong></h1> <div class='article'> <p>Refer to the <a href=\"//devcenter.heroku.com/\">documentation</a> if you need help deploying.</p> </div> </div> </div> </body> </html>".gsub(/\n|\s/, "")
26
+ actual = get_page_source 'http://spec-test-app.herokuapp.com/'
27
+ expected.should == actual.gsub(/\n|\s/, "")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ require 'rspec'
6
+ require 'page_source'
7
+
8
+ # Requires supporting files with custom matchers and macros, etc,
9
+ # # in ./support/ and its subdirectories.
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+ end
metadata ADDED
@@ -0,0 +1,47 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: page_source
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dilkhush Soni
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: dilkhushsoni2010@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - Gemfile
20
+ - Gemfile.lock
21
+ - lib/page_source.rb
22
+ - spec/page_soruce_spec.rb
23
+ - spec/spec_helper.rb
24
+ homepage:
25
+ licenses: []
26
+ metadata: {}
27
+ post_install_message:
28
+ rdoc_options: []
29
+ require_paths:
30
+ - lib
31
+ required_ruby_version: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ requirements: []
42
+ rubyforge_project:
43
+ rubygems_version: 2.2.2
44
+ signing_key:
45
+ specification_version: 4
46
+ summary: page_source gem is to fatch page source by url.
47
+ test_files: []