aiuto 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
+ SHA256:
3
+ metadata.gz: cbcbff68ed6b7a0ef83625c567edef26386ffab0f65e31ff2d1437d6ba4ec707
4
+ data.tar.gz: ba2b973a54aced91fc5d116050e214ff25703d2bd19dec2df57120d8ea3776de
5
+ SHA512:
6
+ metadata.gz: b509e25431d6900438827aae26569653ad031d4b7bbf21baf40ca15411494d2f52566e4ca8583d5f0ea2e5eb84441a27bbf9808aab5431b785d679b440f643b5
7
+ data.tar.gz: d3fe56e4fad3cd182e86577952580878e2c70b116470d875480ad1e24c4fec09591139d5b276d7c973d5ba17c72d4decd908154cbe5744e5f677e54aa2491b0c
data/Aiuto.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ require "rake"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "aiuto"
5
+ s.version = "0.0.1"
6
+ s.authors = ["Stefano Martin"]
7
+ s.email = ["stefano.martin87@gmail.com"]
8
+ s.homepage = "https://github.com/StefanoMartin/Aiuto"
9
+ s.license = "MIT"
10
+ s.summary = "For asking help to Google in easy way"
11
+ s.description = "Google help me! Aiuto aiuto!"
12
+ s.platform = Gem::Platform::RUBY
13
+ s.require_paths = ["bin", "lib"]
14
+ s.files = FileList["bin/*", "lib/*", "Aiuto.gemspec", "LICENSE.md", "README.md"].to_a
15
+ s.add_runtime_dependency "launchy", "~>2.4.3", ">= 2.4.3"
16
+ s.executables << 'aiuto'
17
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Stefano Martin
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.
data/README.md ADDED
@@ -0,0 +1,69 @@
1
+ Aiuto
2
+ ==================================
3
+
4
+ Aiuto means "help" in Italian. This is a gem to help you to search easily on Google by filtering on specific websites.
5
+
6
+ Install the gem with:
7
+
8
+ ```
9
+ gem install aiuto
10
+ ```
11
+
12
+ Then try it with:
13
+
14
+ ```
15
+ aiuto Ruby is awesome
16
+ ```
17
+
18
+ YEAH! Google is open and there are only Ruby blogs, forums and similia. No pages about stones and jewels!
19
+
20
+ ## Which websites do you use for filtering?
21
+
22
+ This is the list of websites used in the gem.
23
+ However by default only the websites under "blog", "git", "docs" and "social" are used by default.
24
+
25
+ ```ruby
26
+ {
27
+ blog: ["rubyflow.com", "medium.com", "rubylearning.com",
28
+ "rubyinside.com", "yehudakatz.com", "sitepoint.com/ruby",
29
+ "afreshcup.com", "rubyguides.com", "justinweiss.com",
30
+ "sandimetz.com", "guides.railsgirls.com"],
31
+ git: ["github.com", "gitlab.com"],
32
+ docs: ["ruby-doc.org", "devdocs.io/ruby", "rubydoc.info",
33
+ "guides.rubyonrails.org"],
34
+ social: ["stackoverflow.com/questions/tagged/ruby",
35
+ "ruby-forum.com", "reddit.com/r/ruby", "reddit.com/r/rails"],
36
+ utility: ["ruby.libhunt.com"],
37
+ rails: ["opensourcerails.com", "guides.rubyonrails.org",
38
+ "reddit.com/r/rails",
39
+ "stackoverflow.com/questions/tagged/ruby-on-rails"],
40
+ beginner: ["eloquentruby.com",
41
+ "pragprog.com/book/ruby4/programming-ruby-1-9-2-0",
42
+ "ruby.learncodethehardway.org/book",
43
+ "http://mislav.uniqpath.com/poignant-guide/",
44
+ "https://www.manning.com/books/rails-4-in-action",
45
+ "railstutorial.org/book"],
46
+ advanced: ["patshaughnessy.net", "confidentruby.com",
47
+ "pragprog.com/book/ager/exceptional-ruby", "rubyfu.net"]
48
+ }
49
+ ```
50
+
51
+ If you want to use different filters you can use "-f" followed by the filter you want to use.
52
+ Like this:
53
+
54
+ ```
55
+ aiuto Rails is awesome -f rails beginner
56
+ ```
57
+
58
+ In this case we filter by using the websites in the group "rails" and "beginner".
59
+
60
+ ## Do you have other commands like "-f" ?
61
+
62
+ Yes! I provide ```-no``` to remove all the filters, and ```-r``` to remove the word "ruby" from the search.
63
+
64
+ Futher I add ```aiuto --help``` for helps on the terminal and ```aiuto --list``` for returning the above list.
65
+
66
+ ## Hey! I want to use DuckDuckGo or other filters
67
+
68
+ Please create issue or do some pull requests for any idea you have.
69
+ I am more than welcome to improve this gem with your help. :smile:
data/bin/aiuto ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/aiuto"
4
+
5
+ Aiuto.cli(ARGV)
data/lib/aiuto.rb ADDED
@@ -0,0 +1,71 @@
1
+ require "launchy"
2
+ require_relative "list"
3
+ require_relative "klass"
4
+
5
+ class Aiuto
6
+ def self.to_table(arr, splice=3)
7
+ l = []
8
+ arr = arr.map{|a| a += ", "}
9
+ arr[-1][-1] = ""
10
+ arr[-1][-1] = ""
11
+ arr = arr.each_slice(splice).to_a
12
+ arr.each{|a| a[0] = " " + a[0]}
13
+ arr.each{|r|r.each_with_index{|f,i| l[i] = [l[i]||0, f.length].max}}
14
+ arr.each{|r|r.each_with_index{|f,i| print "#{f.ljust l[i]} "};puts ""}
15
+ end
16
+
17
+ def self.cli(*args)
18
+ args = args[0]
19
+ case args[0]
20
+ when "--help"
21
+ print "===== AIUTO HELP ======\n"
22
+ print "Welcome to Aiuto. Simply write \"aiuto Ruby is awesome\" and I will do a search for you on Google on some Ruby blog or website.\n"
23
+ print "Keep in mind that Google permits a maximum search of 32 words (OR is not counted as a word).\n\n"
24
+ print "-f, --filter \t Change filter followed by \"blog\", \"git\", \"docs\", \"social\", \"utility\", \"rails\", \"beginner\", or \"advanced\".\n"
25
+ print "\t Like this: \"aiuto 'rack queue' -f blog git docs.\n\n"
26
+ print "-no, --no-filter \t Use plain google\n\n"
27
+ print "-r, --no-ruby \t Remove word ruby\n\n"
28
+ print "--list \t List of the used libraries\n\n"
29
+ print "Aiuto means Help in Italian! :D\n\n"
30
+ print "========================\n"
31
+ when "--list"
32
+ print "========= AIUTO LIST ===========\n"
33
+ Aiuto_Helper::LIST.each do |k,v|
34
+ next if [:all, :no, :main].include?(k)
35
+ print "#{k.to_s.upcase}: \n"
36
+ to_table(v)
37
+ end
38
+ print "================================\n"
39
+ else
40
+ words = []
41
+ blogs = []
42
+ to_blog = false
43
+ to_word = true
44
+ no = false
45
+ ruby_word = true
46
+ args.each do |word|
47
+ case word
48
+ when "-f", "--filter"
49
+ to_blog = true
50
+ to_word = false
51
+ when "-no", "--no-filter"
52
+ to_blog = false
53
+ to_word = false
54
+ no = true
55
+ when "-r", "--no-ruby"
56
+ ruby_word = false
57
+ else
58
+ if to_word
59
+ words << word
60
+ elsif to_blog
61
+ blogs << word
62
+ end
63
+ end
64
+ end
65
+ blogs = [:main] if blogs.empty?
66
+ words = words.join(" ")
67
+ blogs = blogs.map(&:to_sym)
68
+ Aiuto.new(words).google(type: blogs, no: no, ruby: ruby_word)
69
+ end
70
+ end
71
+ end
data/lib/klass.rb ADDED
@@ -0,0 +1,31 @@
1
+ class Aiuto
2
+ include Aiuto_Helper
3
+
4
+ def initialize(obj)
5
+ case obj
6
+ when String
7
+ @obj = obj
8
+ when Method
9
+ @obj = obj.receiver + "#" + obj.name
10
+ when Class, Module
11
+ @obj = obj.to_s
12
+ else
13
+ @obj = obj.to_s
14
+ @obj = @obj.class.to_s if @obj.to_s[0..1] == "<#"
15
+ end
16
+ end
17
+
18
+ def google(type: [], no: false, ruby: true)
19
+ sites = []
20
+ type = [type] unless type.is_a?(Array)
21
+ type = [] if no
22
+ type.each do |t|
23
+ sites |= LIST[t.to_sym]
24
+ end
25
+ sites = sites.map{|s| "site:"+s}.join(" OR ")
26
+ url = "www.google.com/search?q="+sites
27
+ url += " ruby" if ruby
28
+ url += " "+@obj.gsub("#", "%23")
29
+ Launchy.open(url)
30
+ end
31
+ end
data/lib/list.rb ADDED
@@ -0,0 +1,27 @@
1
+ module Aiuto_Helper
2
+ LIST = {
3
+ blog: ["rubyflow.com", "medium.com", "rubylearning.com",
4
+ "rubyinside.com", "yehudakatz.com", "sitepoint.com/ruby",
5
+ "afreshcup.com", "rubyguides.com", "justinweiss.com",
6
+ "sandimetz.com", "guides.railsgirls.com"],
7
+ git: ["github.com", "gitlab.com"],
8
+ docs: ["ruby-doc.org", "devdocs.io/ruby", "rubydoc.info",
9
+ "guides.rubyonrails.org"],
10
+ social: ["stackoverflow.com/questions/tagged/ruby",
11
+ "ruby-forum.com", "reddit.com/r/ruby", "reddit.com/r/rails"],
12
+ utility: ["ruby.libhunt.com"],
13
+ rails: ["opensourcerails.com", "guides.rubyonrails.org",
14
+ "reddit.com/r/rails",
15
+ "stackoverflow.com/questions/tagged/ruby-on-rails"],
16
+ beginner: ["eloquentruby.com",
17
+ "pragprog.com/book/ruby4/programming-ruby-1-9-2-0",
18
+ "ruby.learncodethehardway.org/book",
19
+ "http://mislav.uniqpath.com/poignant-guide/",
20
+ "https://www.manning.com/books/rails-4-in-action",
21
+ "railstutorial.org/book"],
22
+ advanced: ["patshaughnessy.net", "confidentruby.com",
23
+ "pragprog.com/book/ager/exceptional-ruby", "rubyfu.net"]
24
+ }
25
+ LIST[:main] = LIST[:blog] | LIST[:docs] | LIST[:git] | LIST[:social]
26
+ LIST[:no] = []
27
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: aiuto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stefano Martin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: launchy
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.4.3
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: 2.4.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.4.3
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 2.4.3
33
+ description: Google help me! Aiuto aiuto!
34
+ email:
35
+ - stefano.martin87@gmail.com
36
+ executables:
37
+ - aiuto
38
+ extensions: []
39
+ extra_rdoc_files: []
40
+ files:
41
+ - Aiuto.gemspec
42
+ - LICENSE.md
43
+ - README.md
44
+ - bin/aiuto
45
+ - lib/aiuto.rb
46
+ - lib/klass.rb
47
+ - lib/list.rb
48
+ homepage: https://github.com/StefanoMartin/Aiuto
49
+ licenses:
50
+ - MIT
51
+ metadata: {}
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - bin
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubygems_version: 3.0.3
69
+ signing_key:
70
+ specification_version: 4
71
+ summary: For asking help to Google in easy way
72
+ test_files: []