get_seo 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dda93265c8b01fe546e13f323e06a8c49a0b66c9
4
+ data.tar.gz: 00111bb888d7f2ec966d6871dc3bf4ce07832998
5
+ SHA512:
6
+ metadata.gz: e0d1671ef63e0f5592a304fcf25d8bce9119fb0b3112e144b9293a5e6c5d7559cadc8276f33d15fabaa96bfc483f5735889aa5e2880f76c00cf397821957b40e
7
+ data.tar.gz: f518660843d0b68f4871fdd6e9b4d4b4a72fd38b8b43b85e6014dc3289aa72eb016be610e957fcf119e42de5071df6301fbad6d7e7f1cbf67833c86c58c5de40
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at dom.mckellar@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in get_seo.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dom McKellar
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,87 @@
1
+ # GetSeo
2
+
3
+ [GetSeo](https://rubygems.org/gems/get_seo) is a CLI built in ruby. It allows you to quickly and easily inspect various SEO metrics from any website. Simply enter the url of a website you’d like to inspect, select the SEO metric you wish to retrieve, and your results will be displayed in the terminal.
4
+
5
+ ---
6
+
7
+ ## Installation
8
+
9
+ ### Option (1)
10
+
11
+ * Add this line to your application's Gemfile:
12
+
13
+ `gem 'get_seo'`
14
+
15
+ * Run bundle from your terminal
16
+
17
+ `$ bundle`
18
+
19
+ ### Option (2)
20
+
21
+ Install the gem on your local system:
22
+
23
+ `$ gem install get_seo`
24
+
25
+ ---
26
+
27
+ ## CLI Usage
28
+
29
+ ### Go to the project directory:
30
+
31
+ `$ cd get_seo/`
32
+
33
+ ### Begin a GetSeo session:
34
+
35
+ `$ ruby bin/get-seo`
36
+
37
+ or alternatively
38
+
39
+ `$ ./bin/get-seo`
40
+
41
+ ###### Note: You may receive a `Permission Denied` error. Fix it by doing the following:
42
+
43
+ ##### (step 1)
44
+ `$ cd bin/`
45
+
46
+ ##### (step 2)
47
+ `$ ls -lah`
48
+
49
+ * Assuming your `get-seo` file doesn't have the following permission(s): `-rwxr-xr-x`
50
+
51
+ ##### (step 3)
52
+ `$ chmod +x get-seo`
53
+
54
+ ##### (step 4)
55
+ `$ ls -lah` will verify your changes took effect
56
+
57
+ ---
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+
63
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ ---
66
+
67
+ ## Creator
68
+
69
+ ### Dominic McKellar
70
+
71
+ * Website: [domckellar.com](http://domckellar.com/)
72
+
73
+ * Blog: [newme.io](http://newme.io/)
74
+
75
+ * Github: [@Dom-Mc](https://github.com/Dom-Mc)
76
+
77
+ ---
78
+
79
+ ## Contributing
80
+
81
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/get_seo. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+
83
+ ---
84
+
85
+ ## License
86
+
87
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,3 @@
1
+ theme: jekyll-theme-cayman
2
+ title: Dom McKellar | GetSeo
3
+ description: GetSeo was created by Dominic McKellar. It's a CLI built in Ruby that allows you to quickly and easily inspect various SEO metrics from any website.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "get_seo"
5
+
6
+ require "pry"
7
+ Pry.start
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ # NOTE: loads main library
6
+ require "get_seo"
7
+
8
+ # NOTE: call to start program (file located in lib/get_seo/cli.rb)
9
+ GetSeo::CLI.new.run_program
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'get_seo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "get_seo"
8
+ spec.version = GetSeo::VERSION
9
+ spec.author = ["Dom McKellar"]
10
+ spec.email = ["dom.mckellar@gmail.com"]
11
+
12
+ spec.summary = %q{Quickly and easily inspect various SEO metrics from any website.}
13
+ spec.description = %q{GetSeo allows you to avoid browser extensions and immediately fetch SEO various SEO metrics. Simply enter the url of a website you’d like to inspect, select the SEO metric you'd like to retrieve, and GetSeo will display your results via the terminal.}
14
+ spec.homepage = "http://newme.io/get_seo/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Development
31
+ spec.add_development_dependency "bundler", "~> 1.12"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "pry", "~> 0.10.4"
35
+ spec.add_development_dependency "require_all", "~> 1.3", ">= 1.3.3"
36
+
37
+ # Production
38
+ spec.add_dependency "nokogiri", "~> 1.6"
39
+ end
@@ -0,0 +1,8 @@
1
+ #Will act as our environment file
2
+ require 'open-uri'
3
+ require 'nokogiri'
4
+ require 'pry'
5
+
6
+ require_relative 'get_seo/version'
7
+ require_relative 'get_seo/seo'
8
+ require_relative 'get_seo/cli'
@@ -0,0 +1,146 @@
1
+ #CLI Controller
2
+ class GetSeo::CLI
3
+
4
+ attr_accessor :protocal, :start_of_program, :seo_data
5
+
6
+ def initialize
7
+ @start_of_program = true
8
+ end
9
+
10
+ def run_program
11
+ welcome_message
12
+ check_requested_protocal
13
+ get_seo_info
14
+ seo_menu if start_of_program
15
+ goodbye_message
16
+ end
17
+
18
+ private
19
+
20
+ def check_requested_protocal
21
+ loop do
22
+ line_break
23
+ puts "Check the webpage you would like to inspect and find out if it uses 'http' or 'https'?",
24
+ "-To select 'http' (Enter 1)",
25
+ "-To select 'https' (Enter 2)"
26
+
27
+ requested_protocal = gets.strip.downcase
28
+
29
+ if requested_protocal == '1' || requested_protocal == 'http'
30
+ self.protocal = 'http://'
31
+ break
32
+ elsif requested_protocal == '2' || requested_protocal == 'https'
33
+ self.protocal = 'https://'
34
+ break
35
+ else
36
+ section_break
37
+ puts "\t*Sorry but '#{requested_protocal}' is not a valid option.*"
38
+ section_break
39
+ end
40
+ end
41
+ end
42
+
43
+ def get_seo_info
44
+ line_break
45
+ puts "In order to retrieve SEO information, please enter the domain of the webpage you would like to inspect (i.e. example.com):"
46
+
47
+ print protocal # 'http://' or 'https://'
48
+ requested_url = gets.strip.downcase
49
+
50
+ # NOTE: Throw an exception if website cannote be accessed
51
+ begin
52
+
53
+ self.seo_data = GetSeo::Seo.setup(protocal + requested_url)
54
+
55
+ rescue
56
+
57
+ section_break
58
+ puts "\t*There seems to be an issue with the domain you entered.*",
59
+ "\t*Please double check the url and try again.*"
60
+ section_break
61
+
62
+ run_program
63
+ end
64
+ end
65
+
66
+ def seo_menu
67
+ # NOTE: pervent seo_menu from running again after "exit"
68
+ self.start_of_program = false
69
+
70
+ loop do
71
+
72
+ 2.times { line_break }
73
+ puts "What information would you like to retrieve?:",
74
+ "- Title Tag (Enter 1)",
75
+ "- Description Meta Tag' (Enter 2)",
76
+ "- Keyword Meta Tag (Enter 3)",
77
+ "- h1 Heading Tag(s) (Enter 4)",
78
+ "- h2 Heading Tag(s) (Enter 5)",
79
+ "- h3 Heading Tag(s) (Enter 6)",
80
+ "- Image Alt Attribute(s)' (Enter 7)",
81
+ "- Exit the program (Enter 'exit' or 'quit')"
82
+
83
+ user_selection = gets.strip.downcase
84
+
85
+ case user_selection
86
+ when '1'
87
+ print_seo_data(seo_data.title, "Title Tag")
88
+ when '2'
89
+ print_seo_data(seo_data.description, "Description Meta Tag")
90
+ when '3'
91
+ print_seo_data(seo_data.keywords, "Keywords Meta Tag")
92
+ when '4'
93
+ print_seo_data(seo_data.heading1, "h1 Heading Tag(s)")
94
+ when '5'
95
+ print_seo_data(seo_data.heading2, "h2 Heading Tag(s)")
96
+ when '6'
97
+ print_seo_data(seo_data.heading3, "h3 Heading Tag(s)")
98
+ when '7'
99
+ print_seo_data(seo_data.img_alt_attribute, "Image Alt Attribute(s)")
100
+ when 'exit', 'quit'
101
+ break
102
+ else
103
+ section_break
104
+ puts "\t*Sorry but '#{user_selection}' is invalid, please select another option.*"
105
+ section_break
106
+ end
107
+ end
108
+
109
+ end
110
+
111
+ def welcome_message
112
+ line_break
113
+ puts "Welcome to SEO. Ok enough chitchat, let's get to work!"
114
+ end
115
+
116
+ def goodbye_message
117
+ line_break
118
+ puts "Great SEO work! Job well done."
119
+ line_break
120
+ end
121
+
122
+ def print_seo_data(data_attr, name)
123
+ section_break
124
+ puts "\t*#{name.upcase}*"
125
+ section_break
126
+
127
+ if data_attr.empty?
128
+ puts "\t*#{name} - Not found on page.*"
129
+ else
130
+ data_attr.each do |value|
131
+ puts "* #{value}"
132
+ end
133
+ end
134
+ end
135
+
136
+ def section_break
137
+ line_break
138
+ 70.times { print '*' }
139
+ line_break
140
+ end
141
+
142
+ def line_break
143
+ puts "\n"
144
+ end
145
+
146
+ end
@@ -0,0 +1,50 @@
1
+ class GetSeo::Seo
2
+
3
+ attr_accessor :heading1, :heading2, :heading3, :keywords, :title, :description, :img_alt_attribute
4
+
5
+ def self.setup(url)
6
+ html = Nokogiri::HTML(open(url))
7
+ seo = self.new
8
+
9
+ seo.heading1 = html.search("h1").map do |h1|
10
+ h1.text.strip.gsub(/\s+/, " ")
11
+ end.reject(&:empty?)
12
+
13
+ seo.heading2 = html.search("h2").map do |h2|
14
+ h2.text.strip.gsub(/\s+/, " ")
15
+ end.reject(&:empty?)
16
+
17
+ seo.heading3 = html.search("h3").map do |h3|
18
+ h3.text.strip.gsub(/\s+/, " ")
19
+ end.reject(&:empty?)
20
+
21
+ seo.title = []
22
+ if title = html.at("title")&.text
23
+ seo.title << title.strip unless title.empty?
24
+ end
25
+
26
+ seo.keywords = []
27
+ if keywords = (html.at("meta[name='keywords']") &&
28
+ html.at("meta[name='keywords']")['content'])
29
+
30
+ keywords.split(',').each do |keyword|
31
+ stripped_word = keyword.strip
32
+ seo.keywords << stripped_word unless stripped_word.empty?
33
+ end
34
+ end
35
+
36
+ seo.description = []
37
+ if description = (html.at("meta[name='description']") &&
38
+ html.at("meta[name='description']")['content'])
39
+
40
+ seo.description << description unless description.empty?
41
+ end
42
+
43
+ seo.img_alt_attribute = html.search('img').map do |img|
44
+ img['alt']&.strip
45
+ end.compact.reject!(&:empty?)
46
+
47
+ seo
48
+ end
49
+
50
+ end
@@ -0,0 +1,3 @@
1
+ module GetSeo
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: get_seo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dom McKellar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-01-25 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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: require_all
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 1.3.3
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '1.3'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 1.3.3
89
+ - !ruby/object:Gem::Dependency
90
+ name: nokogiri
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.6'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.6'
103
+ description: GetSeo allows you to avoid browser extensions and immediately fetch SEO
104
+ various SEO metrics. Simply enter the url of a website you’d like to inspect, select
105
+ the SEO metric you'd like to retrieve, and GetSeo will display your results via
106
+ the terminal.
107
+ email:
108
+ - dom.mckellar@gmail.com
109
+ executables: []
110
+ extensions: []
111
+ extra_rdoc_files: []
112
+ files:
113
+ - ".gitignore"
114
+ - ".rspec"
115
+ - ".travis.yml"
116
+ - CODE_OF_CONDUCT.md
117
+ - Gemfile
118
+ - LICENSE.txt
119
+ - README.md
120
+ - Rakefile
121
+ - _config.yml
122
+ - bin/console
123
+ - bin/get-seo
124
+ - bin/setup
125
+ - get_seo.gemspec
126
+ - lib/get_seo.rb
127
+ - lib/get_seo/cli.rb
128
+ - lib/get_seo/seo.rb
129
+ - lib/get_seo/version.rb
130
+ homepage: http://newme.io/get_seo/
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.6.8
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: Quickly and easily inspect various SEO metrics from any website.
154
+ test_files: []