site_analyzer 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: ce267934c8aefcd9a1144ba3cda530c4fcfde312
4
+ data.tar.gz: eb2f6963c302c2fcba81c064226881b18bea107f
5
+ SHA512:
6
+ metadata.gz: c305c773cd2e43c32b81d3f19c9b7c12a0dfd4c6c763c9645080b0b167fb96b6ba538ee2ad72a6e620776382ae240904c23c840d5b9a0fd12d37f6edab2164c0
7
+ data.tar.gz: a182a03fabb43e1a9a0376552dec05aba9bd354954b9de7159488a0482babe9a2110a01db4c5f64c26f50633ff6c1f3842446c4f07439e703efefad3f4ee4716
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /docs/
2
+ /.idea/
3
+ SiteAnalyzer.iml
@@ -0,0 +1,124 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Palette2">
4
+ <group name="Swing">
5
+ <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
6
+ <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
7
+ </item>
8
+ <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
9
+ <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
10
+ </item>
11
+ <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
12
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
13
+ </item>
14
+ <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
15
+ <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
16
+ </item>
17
+ <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
18
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
19
+ <initial-values>
20
+ <property name="text" value="Button" />
21
+ </initial-values>
22
+ </item>
23
+ <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
24
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
25
+ <initial-values>
26
+ <property name="text" value="RadioButton" />
27
+ </initial-values>
28
+ </item>
29
+ <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
30
+ <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
31
+ <initial-values>
32
+ <property name="text" value="CheckBox" />
33
+ </initial-values>
34
+ </item>
35
+ <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
36
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
37
+ <initial-values>
38
+ <property name="text" value="Label" />
39
+ </initial-values>
40
+ </item>
41
+ <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
42
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
43
+ <preferred-size width="150" height="-1" />
44
+ </default-constraints>
45
+ </item>
46
+ <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
47
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
48
+ <preferred-size width="150" height="-1" />
49
+ </default-constraints>
50
+ </item>
51
+ <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
52
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
53
+ <preferred-size width="150" height="-1" />
54
+ </default-constraints>
55
+ </item>
56
+ <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
57
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
58
+ <preferred-size width="150" height="50" />
59
+ </default-constraints>
60
+ </item>
61
+ <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
62
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
63
+ <preferred-size width="150" height="50" />
64
+ </default-constraints>
65
+ </item>
66
+ <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
67
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
68
+ <preferred-size width="150" height="50" />
69
+ </default-constraints>
70
+ </item>
71
+ <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
72
+ <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
73
+ </item>
74
+ <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
75
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
76
+ <preferred-size width="150" height="50" />
77
+ </default-constraints>
78
+ </item>
79
+ <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
80
+ <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
81
+ <preferred-size width="150" height="50" />
82
+ </default-constraints>
83
+ </item>
84
+ <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
85
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
86
+ <preferred-size width="150" height="50" />
87
+ </default-constraints>
88
+ </item>
89
+ <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
90
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
91
+ <preferred-size width="200" height="200" />
92
+ </default-constraints>
93
+ </item>
94
+ <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
95
+ <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
96
+ <preferred-size width="200" height="200" />
97
+ </default-constraints>
98
+ </item>
99
+ <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
100
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
101
+ </item>
102
+ <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
103
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
104
+ </item>
105
+ <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
106
+ <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
107
+ </item>
108
+ <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
109
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
110
+ </item>
111
+ <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
112
+ <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
113
+ <preferred-size width="-1" height="20" />
114
+ </default-constraints>
115
+ </item>
116
+ <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
117
+ <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
118
+ </item>
119
+ <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
120
+ <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
121
+ </item>
122
+ </group>
123
+ </component>
124
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format doc
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
4
+ before_install: gem install bundler -v 1.10.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ # A sample Gemfile
2
+ source 'https://rubygems.org'
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ site_analyzer (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.3.8)
10
+ diff-lcs (1.2.5)
11
+ mini_portile (0.6.2)
12
+ nokogiri (1.6.6.2)
13
+ mini_portile (~> 0.6.0)
14
+ rake (10.4.2)
15
+ robotstxt (0.5.4)
16
+ rspec (3.3.0)
17
+ rspec-core (~> 3.3.0)
18
+ rspec-expectations (~> 3.3.0)
19
+ rspec-mocks (~> 3.3.0)
20
+ rspec-core (3.3.1)
21
+ rspec-support (~> 3.3.0)
22
+ rspec-expectations (3.3.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.3.0)
25
+ rspec-mocks (3.3.1)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.3.0)
28
+ rspec-support (3.3.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ addressable (~> 2.3)
35
+ bundler (~> 1.10)
36
+ nokogiri (~> 1.6)
37
+ rake (~> 10.0)
38
+ robotstxt (~> 0.5)
39
+ rspec (~> 3.3)
40
+ site_analyzer!
41
+
42
+ BUNDLED WITH
43
+ 1.10.5
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Denis Savchuk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ <a href="https://github.com/Mordorreal/SiteAnalyzer"><b>Site Analyzer</b><a/>
2
+
3
+ Site Analyzer is a Ruby SEO site analizer gem.
4
+
5
+ Site Analyzer check site and make report for you.
6
+
7
+ <b>Requirements</b>
8
+
9
+ Ruby >= 1.8.7
10
+ Nokogiri >= 1.6.6.2
11
+ Addressable >= 2.3.8
12
+ Robotstxt >= 0.5.4
13
+
14
+ <b>Installation</b>
15
+
16
+ This library is intended to be installed via the RubyGems system.
17
+
18
+ $ gem install site_analyzer
19
+
20
+ You might need administrator privileges on your system to install it.
21
+
22
+ <b>How to use</b>
23
+
24
+ require 'site_analyzer'<br>
25
+ SiteAnalyzer.add_site 'http://savchuk.space' # add site to list<br>
26
+ SiteAnalyzer.start # start creating of reports<br>
27
+ SiteAnalyzer.show_all_reports # show all reports in console<br>
28
+ SiteAnalyzer.show_report 5 # show report number 5 starting from 1 in console<br>
29
+ SiteAnalyzer.report[0].report # return Hash report<br>
30
+
31
+ <b>Author</b>
32
+
33
+ Denis Savchuk <a href="mailto:denis@savchuk.space"><denis@savchuk.space></a>
34
+
35
+ <b>Resources</b>
36
+
37
+ Homepage <a href="savchuk.space" target="_blank">savchuk.space</a>
38
+
39
+ <b>License</b>
40
+
41
+ Copyright © 2015 Denis Savchuk, SiteAnalyzer is released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/SiteAnalyzer.iml ADDED
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.3.8, rbenv: 2.2.2) [gem]" level="application" />
9
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.10.5, rbenv: 2.2.2) [gem]" level="application" />
10
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.2.5, rbenv: 2.2.2) [gem]" level="application" />
11
+ <orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.2, rbenv: 2.2.2) [gem]" level="application" />
12
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.6.2, rbenv: 2.2.2) [gem]" level="application" />
13
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.4.2, rbenv: 2.2.2) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="robotstxt (v0.5.4, rbenv: 2.2.2) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.3.1, rbenv: 2.2.2) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.3.1, rbenv: 2.2.2) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.3.0, rbenv: 2.2.2) [gem]" level="application" />
20
+ </component>
21
+ </module>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "site_analizer"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,159 @@
1
+ module SiteAnalyzer
2
+ # Get site page and provide metods for analyse
3
+ require 'nokogiri'
4
+ require 'addressable/uri'
5
+ require 'open-uri'
6
+ require 'timeout'
7
+ class Page
8
+ attr_reader :page_url, :titles
9
+ def initialize(url)
10
+ @page_url = url
11
+ @page = get_page url
12
+ @site_url = get_domain url
13
+ @titles = all_titles
14
+ end
15
+
16
+ def get_page(url)
17
+ return nil if url.nil?
18
+ timeout(10) { Nokogiri::HTML(open(url)) }
19
+ rescue
20
+ nil
21
+ end
22
+
23
+ def get_domain(url)
24
+ return nil if url.nil?
25
+ timeout(10) { Addressable::URI.parse(url).host }
26
+ rescue
27
+ nil
28
+ end
29
+
30
+ def title_good?
31
+ return false if (title = @page.search('//title').children) == 0
32
+ title.text.size < 70
33
+ end
34
+ # true if title and h1 have no dublicates
35
+ def title_and_h1_good?
36
+ out = @page.search('//title', '//h1').children
37
+ arr = []
38
+ out.each { |node| arr << node.text }
39
+ arr.size > 1 || arr.uniq.size == arr.size
40
+ end
41
+ # true if metadescription less then 200 symbols
42
+ def metadescription_good?
43
+ tags = @page.css("meta[name='description']")
44
+ return false if tags.size == 0
45
+ tags.each do |t|
46
+ unless t['value'].nil?
47
+ return false if t['content'].size == 0 || t['content'].size > 200
48
+ end
49
+ end
50
+ true
51
+ end
52
+ # true if keywords less then 600 symbols
53
+ def keywords_good?
54
+ tags = @page.css("meta[name='keywords']")
55
+ return false if tags.size == 0
56
+ tags.each do |t|
57
+ unless t['value'].nil?
58
+ return false if t['content'].size == 0 || t['content'].size > 600
59
+ end
60
+ end
61
+ true
62
+ end
63
+ # true if code less then text
64
+ def code_less?
65
+ sum = 0
66
+ page_text = @page.text.size
67
+ @page.css('script').each do |tag|
68
+ sum += tag.text.size
69
+ end
70
+ sum < page_text / 2
71
+ end
72
+
73
+ def collect_metadates
74
+ @page.css('meta')
75
+ end
76
+
77
+ def metadates_good?
78
+ meta_tags = collect_metadates
79
+ return false if @page.css('title').size > 1 || meta_tags.nil?
80
+ node_names = []
81
+ meta_tags.each { |node| node_names << node['name'] }
82
+ return false if node_names.compact!.size < 1
83
+ node_names.uniq.size == node_names.size
84
+ end
85
+ # return hash with all titles, h1 and h2
86
+ def all_titles_h1_h2
87
+ out = []
88
+ out << @page.css('title').text << { @page_url => @page.css('h1').text }
89
+ out << { @page_url => @page.css('h2').text }
90
+ end
91
+
92
+ def home_a
93
+ home_a = []
94
+ all_a_tags_href.each do |link|
95
+ home_a << link if link.include? @site_url
96
+ end
97
+ home_a
98
+ end
99
+
100
+ def remote_a
101
+ remote_a = []
102
+ all_a_tags_href.uniq.each do |link|
103
+ remote_a << link unless link.include? @site_url
104
+ end
105
+ remote_a
106
+ end
107
+
108
+ def all_a_tags_href
109
+ tags = []
110
+ @page.css('a').each do |node|
111
+ tags << node['href'] unless node['href'].nil? || node['href'].size == 0
112
+ end
113
+ tags
114
+ end
115
+
116
+ def wrong_a
117
+ wrong_a = []
118
+ all_a_tags_href.each do |link|
119
+ wrong_a << link if link.include? '?meta='
120
+ end
121
+ wrong_a
122
+ end
123
+
124
+ def h2?
125
+ @page.css('h2').size > 0
126
+ end
127
+
128
+ def page_text_size
129
+ @page.text.size
130
+ end
131
+
132
+ def all_a_tags
133
+ tags = []
134
+ @page.css('a').each do |node|
135
+ tags << [node['href'], node['target'], node['rel']]
136
+ end
137
+ tags
138
+ end
139
+
140
+ def all_titles
141
+ titles = []
142
+ @page.css('title').each { |tag| titles << tag.text }
143
+ titles
144
+ end
145
+
146
+ def all_meta_description_content
147
+ tags = []
148
+ @page.css("meta[name='description']").each do |t|
149
+ tags << t['content']
150
+ end
151
+ tags
152
+ end
153
+ def h2
154
+ h2s = []
155
+ @page.css('h2').each { |tag| h2s << tag.text }
156
+ h2s
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,166 @@
1
+ module SiteAnalyzer
2
+ # Create report for site
3
+ class Report
4
+ attr_reader :site, :report
5
+ def initialize(site_url, max_pages, use_robot = false)
6
+ @site_url = site_url
7
+ @max_pages = max_pages
8
+ @use_robot = use_robot
9
+ @site = Site.new(@site_url, @max_pages, @use_robot)
10
+ end
11
+
12
+ def make_report
13
+ @report = {}
14
+ @report[:title_more_then_70_symbols] = check_titles_text_less_than_70
15
+ @report[:title_and_h1_have_doubles] = check_title_and_h1_for_doubles
16
+ @report[:meta_description_more_than_200] = check_meta_description_less_then_200
17
+ @report[:meta_keywords_tags_more_than_600] = check_meta_keywords_tags
18
+ @report[:dont_have_h2_tags] = check_h2
19
+ @report[:pages_size_with_url] = pages_size
20
+ @report[:code_more_then_text_on] = code_more
21
+ @report[:a_tags_list] = a_tag_array
22
+ @report[:title_doubles] = title_doubles
23
+ @report[:meta_description_doubles] = meta_description_doubles
24
+ @report[:bad_url] = bad_url
25
+ @report[:h2_doubles] = h2_doubles
26
+ @report
27
+ end
28
+
29
+ def to_s
30
+ return 'Report is empty' if @report.nil? || @report.empty?
31
+ puts "================Report for #{@site_url} with #{@max_pages} pages max_pages and robot check is #{@use_robot}================"
32
+ @report.each_pair do |key, value|
33
+ puts "=====================================#{key}====================================="
34
+ puts value
35
+ puts '===================================================================================================='
36
+ end
37
+ end
38
+
39
+ def check_titles_text_less_than_70
40
+ result = []
41
+ @site.pages.each_pair do |url, page|
42
+ result << url unless page.title_good?
43
+ end
44
+ result
45
+ end
46
+
47
+ def check_title_and_h1_for_doubles
48
+ result = []
49
+ @site.pages.each_pair do |url, page|
50
+ result << url unless page.title_and_h1_good?
51
+ end
52
+ result
53
+ end
54
+
55
+ def check_meta_description_less_then_200
56
+ result = []
57
+ @site.pages.each_pair do |url, page|
58
+ result << url unless page.metadescription_good?
59
+ end
60
+ result
61
+ end
62
+
63
+ def check_meta_keywords_tags
64
+ result = []
65
+ @site.pages.each_pair do |url, page|
66
+ result << url unless page.keywords_good?
67
+ end
68
+ result
69
+ end
70
+
71
+ def check_h2
72
+ result = []
73
+ @site.pages.each_pair do |url, page|
74
+ result << url unless page.h2?
75
+ end
76
+ result
77
+ end
78
+
79
+ def pages_size
80
+ result = []
81
+ @site.pages.each_pair do |url, page|
82
+ result << [url, page.page_text_size]
83
+ end
84
+ result
85
+ end
86
+
87
+ def code_more
88
+ result = []
89
+ @site.pages.each_pair do |url, page|
90
+ result << url unless page.code_less?
91
+ end
92
+ result
93
+ end
94
+
95
+ def a_tag_array
96
+ result = []
97
+ @site.pages.each_pair do |home_page_of_url, page|
98
+ page.all_a_tags.each do |link|
99
+ result << [home_page_of_url, link[0], link[1], link[2]]
100
+ end
101
+ end
102
+ result
103
+ end
104
+
105
+ def title_doubles
106
+ find_doubles @site.all_titles
107
+ end
108
+
109
+ def not_uniq_words_in_meta
110
+ find_not_uniq_words @site.all_descriptions
111
+ end
112
+
113
+ def meta_description_doubles
114
+ find_doubles @site.all_descriptions
115
+ end
116
+
117
+ def bad_url
118
+ result = []
119
+ a_tag_array.each do |url|
120
+ result << url if url[1].include? '?meta='
121
+ end
122
+ result
123
+ end
124
+
125
+ def h2_doubles
126
+ find_doubles(@site.all_h2)
127
+ end
128
+
129
+ def not_uniq_words_in_h2
130
+ find_not_uniq_words @site.all_h2
131
+ end
132
+
133
+ # in_array must be [[url_of_page, words_in_string_with_space],[next, same_element]]
134
+ def find_not_uniq_words(in_array)
135
+ all_words = []
136
+ counter = {}
137
+ result = []
138
+ in_array.each do |url_desc_cont|
139
+ url_desc_cont[0][1].scan(/\w+/).each do |word|
140
+ all_words << word
141
+ end
142
+ end
143
+ all_words.each do |word|
144
+ if counter[word]
145
+ counter[word] += 1
146
+ else
147
+ counter[word] = 1
148
+ end
149
+ end
150
+ counter.each_pair do |word, number|
151
+ result << word if number > 1
152
+ end
153
+ result
154
+ end
155
+ # in_array must be [[url_of_page, words_in_string_with_space],[next, same_element]]
156
+ def find_doubles(in_array)
157
+ result = []
158
+ find_not_uniq_words(in_array).each do |not_uniq_word|
159
+ in_array.each do |url_desc_cont|
160
+ result << url_desc_cont if url_desc_cont[0][1].include? not_uniq_word
161
+ end
162
+ end
163
+ result
164
+ end
165
+ end
166
+ end
@@ -0,0 +1,66 @@
1
+ module SiteAnalyzer
2
+ require 'robotstxt'
3
+ # Create site object with all scans
4
+ class Site
5
+ attr_reader :main_url, :pages, :domain
6
+ def initialize(url, max_pages = 10, use_robot_txt = false)
7
+ @main_url = url
8
+ @pages = {}
9
+ @max_pages = max_pages
10
+ @domain = Addressable::URI.parse(url).host
11
+ @use_robot_txt = use_robot_txt
12
+ all_site_pages(url)
13
+ end
14
+
15
+ def robot_txt_allowed?(url)
16
+ Robotstxt.allowed?(url, '*') rescue nil
17
+ end
18
+
19
+ def all_site_pages(url = main_url)
20
+ return nil if @max_pages < 0 || redirection_off(url).nil? || (robot_txt_allowed?(url) if @use_robot_txt)
21
+ @max_pages -= 1
22
+ page = Page.new url
23
+ urls_array = urls_of_pages(page)
24
+ if urls_array.size > 0
25
+ urls_array.each do |url_in|
26
+ all_site_pages(url_in) unless @pages.key?(url_in) || url_in.nil?
27
+ end
28
+ end
29
+ @pages[url] = page
30
+ end
31
+
32
+ def urls_of_pages(page)
33
+ page.home_a.uniq.delete_if { |url| url.start_with?('mailto') }
34
+ end
35
+
36
+ def redirection_off(url)
37
+ timeout(10) { open(url).base_uri.to_s }
38
+ rescue
39
+ nil
40
+ end
41
+
42
+ def all_titles
43
+ result = []
44
+ @pages.each_pair do |url, page|
45
+ result << [url, page.titles]
46
+ end
47
+ result
48
+ end
49
+
50
+ def all_descriptions
51
+ result = []
52
+ @pages.each_pair do |url, page|
53
+ result << [url, page.all_meta_description_content]
54
+ end
55
+ result
56
+ end
57
+
58
+ def all_h2
59
+ result = []
60
+ @pages.each_pair do |url, page|
61
+ result << [url, page.h2]
62
+ end
63
+ result
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,3 @@
1
+ module SiteAnalyzer
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,39 @@
1
+ # Main class for program
2
+ module SiteAnalyzer
3
+ require 'site_analyzer/page'
4
+ require 'site_analyzer/site'
5
+ require 'site_analyzer/report'
6
+ require 'site_analyzer/version'
7
+ require 'rubygems'
8
+ require 'nokogiri'
9
+ require 'addressable/uri'
10
+ require 'open-uri'
11
+ require 'timeout'
12
+ require 'robotstxt'
13
+ class << self
14
+ attr_reader :report
15
+ def add_site(site_url, max_pages = 100, robottxt = false)
16
+ @report = []
17
+ @report << SiteAnalyzer::Report.new(site_url, max_pages, robottxt)
18
+ end
19
+
20
+ def start
21
+ @report.each { |report| report.make_report }
22
+ end
23
+
24
+ def show_all_reports
25
+ return "Don't have any reports" if @report.nil?
26
+ @report.each {|report| report.to_s}
27
+ end
28
+
29
+ def show_report(number)
30
+ return "Don't have report with number #{number}" if @report[number - 1].nil?
31
+ number -= 1
32
+ @report[number].to_s
33
+ end
34
+
35
+ def clear
36
+ @report.clear
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'site_analyzer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'site_analyzer'
8
+ spec.version = SiteAnalyzer::VERSION
9
+ spec.authors = ['Denis Savchuk']
10
+ spec.email = ['mordorreal@gmail.com']
11
+ spec.date = '2015-07-01'
12
+ spec.summary = %q{Make report for SEO. Analyse site like SEOs like. }
13
+ spec.description = %q{Create site report for SEO many options.}
14
+ spec.homepage = 'https://github.com/Mordorreal/SiteAnalyzer'
15
+ spec.license = 'MIT'
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.10'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec', '~>3.3'
24
+ spec.add_development_dependency 'nokogiri', '~>1.6'
25
+ spec.add_development_dependency 'addressable', '~>2.3'
26
+ spec.add_development_dependency 'robotstxt', '~>0.5'
27
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: site_analyzer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Denis Savchuk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: addressable
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: robotstxt
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.5'
97
+ description: Create site report for SEO many options.
98
+ email:
99
+ - mordorreal@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".idea/uiDesigner.xml"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - CODE_OF_CONDUCT.md
109
+ - Gemfile
110
+ - Gemfile.lock
111
+ - LICENSE
112
+ - README.md
113
+ - Rakefile
114
+ - SiteAnalyzer.iml
115
+ - bin/console
116
+ - bin/setup
117
+ - lib/site_analyzer.rb
118
+ - lib/site_analyzer/page.rb
119
+ - lib/site_analyzer/report.rb
120
+ - lib/site_analyzer/site.rb
121
+ - lib/site_analyzer/version.rb
122
+ - site_analyzer.gemspec
123
+ homepage: https://github.com/Mordorreal/SiteAnalyzer
124
+ licenses:
125
+ - MIT
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options: []
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - ">="
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 2.4.5
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: Make report for SEO. Analyse site like SEOs like.
147
+ test_files: []