ggl 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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ggl +84 -0
  3. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 317bfc39f0da5d332a42c9c545ca8cb810185701
4
+ data.tar.gz: 2d4b553eb7e31fdafa75f7a44e210ebde0105656
5
+ SHA512:
6
+ metadata.gz: 841f04b51caff479ecd4d7f3487f36c524fb89c76f3a2daefa78636dd345f0fed0af01e0ca5840e3dbd2476d1cdd76a32ed841a471c47a5d0e1eff0097895d94
7
+ data.tar.gz: ce9496910569ae8f939b65c171d814e1fc88bf9d3c4492e5dd04a2edcd11186cc883396c222ffdc488e3024d67d59ee72bfc0a39078622a8a1bfaa038df3ec52
data/bin/ggl ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ system = `uname -s`
4
+ @search = ARGV
5
+ @query = ''
6
+
7
+ case system
8
+ when 'Darwin', "Darwin\n"
9
+ @open_command = 'open'
10
+ else
11
+ @open_command = 'xdg-open'
12
+ end
13
+
14
+ def search_for_query
15
+ @search.each do |word|
16
+ add_to_query(word)
17
+ end
18
+ system "#{@open_command} https://www.google.com/search?q=\"#{@query}\""
19
+ end
20
+
21
+ def search_for_images
22
+ @search.delete(@search.first)
23
+ @search.each do |word|
24
+ add_to_query(word)
25
+ end
26
+ system "#{@open_command} \"https://www.google.com/search?q=#{@query}&tbm=isch\""
27
+ end
28
+
29
+ def search_youtube
30
+ @search.delete(@search.first)
31
+ @search.each do |word|
32
+ add_to_query(word)
33
+ end
34
+ system "#{@open_command} https://www.youtube.com/results?search_query=\"#{@query}\""
35
+ end
36
+
37
+ def search_stack
38
+ @search.delete(@search.first)
39
+ @search.each do |word|
40
+ if word == @search.last
41
+ @query << word
42
+ else
43
+ @query << "#{word}+"
44
+ end
45
+ end
46
+ system "#{@open_command} http://stackoverflow.com/search?q=#{@query}"
47
+ end
48
+
49
+ def add_to_query(word)
50
+ if word == @search.last
51
+ @query << word
52
+ else
53
+ @query << "#{word} "
54
+ end
55
+ end
56
+
57
+ def usage
58
+ puts <<-USAGE
59
+ ggl - Google right from your command line
60
+
61
+ Usage:
62
+
63
+ ggl [query]
64
+ ggl -i/--images [query]
65
+ ggl -y/--youtube [query]
66
+ ggl -s/--stack/--stackoverflow [query]
67
+
68
+ ggl -h/--help
69
+
70
+ USAGE
71
+ end
72
+
73
+ case @search.first
74
+ when '-i', '--images'
75
+ search_for_images
76
+ when '-y', '--youtube'
77
+ search_youtube
78
+ when '-s', '--stack', '--stackoverflow'
79
+ search_stack
80
+ when '-h', '--help', nil
81
+ usage
82
+ else
83
+ search_for_query
84
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ggl
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Justyna Rachowicz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: justynarachowicz@gmail.com
15
+ executables:
16
+ - ggl
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/ggl
21
+ homepage: https://github.com/mrowa44/ggl
22
+ licenses:
23
+ - GPL-3.0
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Google right from your command line
45
+ test_files: []