google-copy-link 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,10 @@
1
+ [The MIT License](http://www.opensource.org/licenses/mit-license.php)
2
+ =====================================================================
3
+
4
+ Copyright (c) 2012 Kerrick Long
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ google-copy-link
2
+ ================
3
+
4
+ The CLI displays results from the [Google Web Search API](https://developers.google.com/web-search/), allows you to page through the results, and choose a url to copy to your clipboard, all without leaving the command line.
5
+
6
+ [![Screenshot of `goo` in action!](https://github.com/21croissants/google/raw/master/screenshots/example_01.jpg)](https://github.com/21croissants/google/raw/master/screenshots/example_01.jpg "Click to view full size")
7
+
8
+ ## Installation
9
+
10
+ gem install google-copy-link # Requires Ruby 1.9
11
+
12
+ ## Usage Examples
13
+
14
+ Typing `goo --help` will list all the available commands. They are also listed here.
15
+
16
+ The goo gem is a simple tool to search Gooogle and copy a search result link to your clipboard.
17
+ Usage:
18
+ goo [options] "my search query string here"
19
+ where [options] are:
20
+ --markdown, -m: Use markdown format when copying link to clipboard. Example: \[Trollop\]\(http://trollop.rubyforge.org/\) (Default: false)
21
+ --page, -p <i>: Start by showing the <i>th result page. (Default: 1)
22
+ --size, -s <i>: Show <i> results on each SERP. Must be between 1 and 8. (Default: 4)
23
+ --result, -r <i>: Skip the SERP and show the <i>th result.
24
+ --help, -h: Show this information and exit.
25
+
26
+ At the prompt, type the index of a search result, it will be copied to your clipboard.
27
+
28
+ If you press <Return>, the first search result link will be copied.
29
+
30
+ *ONLY TESTED with a mac*. Should work on linux and windows thanks to clipboard gem;)
31
+
32
+ When writing blog posts in Markdown or looking for libraries in google, I became tired to repeat the whole manual search process in the browser so I found a way to automate it;)
33
+
34
+ ### Search on a single site
35
+
36
+ goo 'site:randsinrepose.com NADD'
37
+
38
+ ## Features
39
+
40
+ * You have access to all the [search operators](http://support.google.com/websearch/bin/answer.py?hl=en&answer=136861) you've come to know and love in Google Search.
41
+
42
+ * Results are shown in [markdown](http://daringfireball.net/projects/markdown/) for a good balance between legibility and document heirarchy. (Shoutout to [reverse_markdown](https://github.com/xijo/reverse_markdown)!)
43
+
44
+ * Results pages are formatted to look like a Google SERP, including colors, domains, descriptions, and bold search matches. (Shoutout to [formatador](https://github.com/geemus/formatador)!)
45
+
46
+ ## Supported Ruby Versions
47
+
48
+ This library has only been tested against Ruby 1.9.3. Other versions might be supported, but they haven't been tested.
49
+
50
+ ## Acknowledgements
51
+
52
+ Most of the code is a fork of Kerrick Long. See [LICENSE](https://github.com/21croissants/google/blob/master/LICENSE.md) for details.
53
+
54
+ This gem is [Powered by Google](http://www.google.com).
55
+
56
+ ### Copyright
57
+
58
+ Copyright (c) 2012 Jean-Michel Garnier. See [LICENSE](https://github.com/21croissants/google/blob/master/LICENSE.md) for details.
59
+
60
+ ### Dependencies
61
+
62
+ * [Trollop](http://trollop.rubyforge.org/) (gem)
63
+
64
+ * [JSON Implementation for Ruby](http://flori.github.com/json/) (gem)
65
+
66
+ * [Formatador](https://github.com/geemus/formatador) (gem)
67
+
68
+ * [HTML Entities for Ruby](http://htmlentities.rubyforge.org/) (gem)
69
+
70
+ * [Reverse Markdown](https://github.com/xijo/reverse_markdown) (lib)
71
+
72
+ * [clipboard gem](https://github.com/janlelis/clipboard)
data/bin/goo ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'google'
4
+
5
+ opts = Trollop::options do
6
+ version "goo v1.0.0 (c) 2012 https://github.com/21croissants/google forked Kerrick Long's' http://kerrick.github.com/google"
7
+ banner <<-EOM
8
+ The google gem is a simple tool to search Gooogle with via a CLI.
9
+ Usage:
10
+ google [options] "my search query string here"
11
+ where [options] are:
12
+ EOM
13
+
14
+ opt :page, "Start by showing the <i>th result page.", :type => :int, :default => 1
15
+
16
+ opt :size, "Show <i> results on each SERP. Must be between 1 and 8.", :type => :int, :default => 4
17
+
18
+ opt :result, "Skip the SERP and show the <i>th result.", :type => :int
19
+
20
+ opt :markdown, "Use markdown format when copying to clipboard. Example: [Trollop]\(http://trollop.rubyforge.org/)",
21
+ :default => false
22
+
23
+ opt :version, "Print the version and exit."
24
+ opt :help, "Show this information and exit."
25
+ end
26
+
27
+ query = ARGV.join(' ')
28
+ raise Trollop::die "no search query specified" if query.empty?
29
+
30
+ begin
31
+ g = Google.new query, opts
32
+ g.search
33
+ rescue Interrupt
34
+ puts "\nInterrupt received. Exiting application."
35
+ exit
36
+ end
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "google-copy-link"
3
+ s.version = "0.0.1"
4
+ s.executables << 'goo'
5
+ s.add_runtime_dependency "trollop", ["~> 1"]
6
+ s.add_runtime_dependency "json", ["~> 1"]
7
+ s.add_runtime_dependency "htmlentities", ["~> 4"]
8
+ s.add_runtime_dependency "formatador", ["~> 0.2"]
9
+ s.add_runtime_dependency "clipboard", ["~> 1.0.1"]
10
+
11
+ s.add_development_dependency 'rspec', '~> 2.5'
12
+ s.add_development_dependency 'guard-rspec', '~> 0.2'
13
+
14
+ s.date = "2012-05-25"
15
+ s.summary = "Google Search on the command line"
16
+ s.description = "A ruby gem to give you the power of Google Search in your command line and copy links to your clipboard"
17
+ s.authors = ["Jean-Michel Garnier" ,"Kerrick Long"]
18
+ s.files = ["bin/goo"]
19
+ s.files += ["lib/google.rb", "lib/google/utils.rb", "lib/google/reverse-markdown/reverse_markdown.rb"]
20
+ s.files += ["LICENSE.md", "README.md", "google.gemspec"]
21
+ s.homepage = "https://github.com/21croissants/google"
22
+ end
@@ -0,0 +1,130 @@
1
+ require 'google/utils'
2
+ require 'google/reverse-markdown/reverse_markdown'
3
+ require 'trollop'
4
+ require 'uri'
5
+ require 'open-uri'
6
+ require 'json'
7
+ require 'formatador'
8
+ require 'htmlentities'
9
+ require 'clipboard'
10
+
11
+ class Google
12
+ def initialize(query, opts)
13
+ @unescaped_query = query
14
+ @query = URI.escape(query)
15
+ @opts = opts
16
+ @opts[:size] = 8 if opts[:size] > 7
17
+ @opts[:size] = 1 if opts[:size] <= 1
18
+ end
19
+
20
+ def search
21
+ if @opts[:result]
22
+ results = request :q => @query, :rsz => 1, :start => (@opts[:result] - 1)
23
+ view results[:results]['responseData']['results'][0]['url']
24
+ else
25
+ results = request :q => @query, :rsz => @opts[:size], :start => ((@opts[:page] - 1) * @opts[:size])
26
+ display_serp results
27
+ end
28
+ end
29
+
30
+ def request(query_strings)
31
+ @api_url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0"\
32
+ "&rsz=#{query_strings[:rsz]}&start=#{query_strings[:start]}&q=#{query_strings[:q]}"
33
+ results = JSON.parse(open(@api_url).read)
34
+ if results['responseStatus'].to_i != 200
35
+ Trollop::die Utils::wrap("Google Search API Status #{results['responseStatus']}. Details:\n"\
36
+ "#{results['responseDetails']}\nTry again in a moment")
37
+ end
38
+
39
+ {:results => results, :query_strings => query_strings}
40
+ end
41
+
42
+ def display_serp(info)
43
+ results = info[:results]
44
+ query_strings = info[:query_strings]
45
+ coder = HTMLEntities.new
46
+ current_page = results['responseData']['cursor']['currentPageIndex']+1
47
+ max_result = query_strings[:start] + query_strings[:rsz]
48
+ estimated_results = results['responseData']['cursor']['resultCount']
49
+ result_array = results['responseData']['results']
50
+
51
+ Formatador.display_line "\n#{' ' * (max_result.to_s.length + 2)}[yellow]Powered by Google[/]"
52
+
53
+ result_array.each_with_index do |result, i|
54
+ this_num = (i + query_strings[:start] + 1).to_s
55
+
56
+ serp_title = "\n#{' ' * (max_result.to_s.length - this_num.length)}[bold][blue]#{this_num}. "\
57
+ "[normal]#{result["titleNoFormatting"]}[/]\n"
58
+ serp_url = "#{' ' * max_result.to_s.length}[green]#{result["url"]}[/]\n"
59
+ serp_desc = ' ' * max_result.to_s.length + result["content"].gsub(/<b>/, "[bold]").gsub(/<\/b>/, "[/]").squeeze(" ")
60
+
61
+ Formatador.display_line coder.decode(Utils::wrap(serp_title, :prefix => max_result.to_s.length + 2))
62
+ Formatador.display_line coder.decode(Utils::wrap(serp_url, :prefix => max_result.to_s.length + 2))
63
+ Formatador.display_line coder.decode(Utils::wrap(serp_desc, :prefix => max_result.to_s.length + 2))
64
+ end
65
+
66
+ Formatador.display_line "\n#{' ' * (max_result.to_s.length + 2)}[yellow]Displaying results #{query_strings[:start] + 1}"\
67
+ " through #{max_result} of #{estimated_results} (Page #{current_page})"
68
+
69
+ input info, result_array
70
+ end
71
+
72
+ def input(info, result_array)
73
+ Formatador.display Utils::wrap("\n[yellow]Enter N or P for pagination, E or Q to quit, or a number to copy the url to your clipboard.")
74
+ Formatador.display "\n[bold]>[/] "
75
+ choice = STDIN.gets
76
+ if choice.nil? # Likely because the user submitted EOT via ^D
77
+ choice = ' '
78
+ else
79
+ choice.chomp + ' '
80
+ end
81
+
82
+ case
83
+ # Quit
84
+ when choice[0].downcase == 'e' || choice[0].downcase == 'q'
85
+ exit
86
+ # Next Page
87
+ when choice[0].downcase == 'n'
88
+ display_serp request(:q => @query, :rsz => @opts[:size], :start => info[:query_strings][:start] + @opts[:size])
89
+ # Previous Page
90
+ when choice[0].downcase == 'p'
91
+ if info[:query_strings][:start] < 1
92
+ Formatador.display Utils::wrap("[yellow]! Already at page one.")
93
+ input info, result_array
94
+ else
95
+ display_serp request(:q => @query, :rsz => @opts[:size], :start => info[:query_strings][:start] - @opts[:size])
96
+ end
97
+ # Numerical Choice
98
+ when choice[0].match(/\d/)
99
+ /(\d+)(\s*\|(.*))*/.match(choice) do |str|
100
+ #puts str.inspect
101
+
102
+ num = str[1].to_i - 1 # Remember, we are 1-indexing things for the user
103
+
104
+ clipboard_copy url(result_array, info, num)
105
+ end
106
+ # Catch-all to grab input again
107
+ else
108
+ clipboard_copy url(result_array, info, 0)
109
+ end
110
+ exit
111
+ end
112
+
113
+ def clipboard_copy(plain_url, markdown_link_format = @opts[:markdown])
114
+ text = if markdown_link_format
115
+ "[#{@unescaped_query}](#{plain_url})"
116
+ else
117
+ plain_url
118
+ end
119
+ Clipboard.copy text
120
+ end
121
+
122
+ def url(result_array, info, obscure_num)
123
+ result_array[obscure_num - info[:query_strings][:start]]['url']
124
+ end
125
+
126
+
127
+ def view(url)
128
+ Formatador.display Utils::wrap(grab(url))
129
+ end
130
+ end
@@ -0,0 +1,297 @@
1
+ require 'rexml/document'
2
+ require 'benchmark'
3
+ include REXML
4
+ include Benchmark
5
+
6
+ # reverse markdown for ruby
7
+ # author: JO
8
+ # e-mail: xijo@gmx.de
9
+ # date: 14.7.2009
10
+ # version: 0.1
11
+ # license: GPL
12
+ # taken from https://github.com/xijo/reverse-markdown/raw/master/reverse_markdown.rb
13
+
14
+ # TODO
15
+ # - ol numbering is buggy, in fact doesn't matter for markdown code
16
+ # -
17
+
18
+ class ReverseMarkdown
19
+
20
+ # set basic variables:
21
+ # - @li_counter: numbering list item (li) tags in an ordered list (ol)
22
+ # - @links: hold the links for adding them to the bottom of the @output
23
+ # this means 'reference style', please take a look at http://daringfireball.net/projects/markdown/syntax#link
24
+ # - @outout: fancy markdown code in here!
25
+ # - @indent: control indention level for nested lists
26
+ # - @errors: appearing errors, like unknown tags, go into this array
27
+ def initialize()
28
+ @li_counter = 0
29
+ @links = []
30
+ @output = ""
31
+ @indent = 0
32
+ @errors = []
33
+ end
34
+
35
+ # Invokes the HTML parsing by using a string. Returns the markdown code in @output.
36
+ # To garantuee well-formed xml for REXML a <root> element will be added, but has no effect.
37
+ # After parsing all elements, the 'reference style'-links will be inserted.
38
+ def parse_string(string)
39
+ doc = Document.new("<root>\n"+string.encode("UTF-8")+"\n</root>")
40
+ parse_element(doc.root, :none)
41
+ insert_links()
42
+ @output
43
+ end
44
+
45
+ # Parsing an element and its children (recursive) and writing its markdown code to @output
46
+ # 1. do indent for nested list items
47
+ # 2. add the markdown opening tag for this element
48
+ # 3a. if element only contains text, handle it like a text node
49
+ # 3b. if element is a container handle its children, which may be text- or element nodes
50
+ # 4. finally add the markdown ending tag for this element
51
+ def parse_element(element, parent)
52
+ name = element.name.to_sym
53
+ # 1.
54
+ @output << indent() if name.eql?(:li)
55
+ # 2.
56
+ @output << opening(element, parent)
57
+
58
+ # 3a.
59
+ if (element.has_text? and element.children.size < 2)
60
+ @output << (text_node(element, parent) || '')
61
+ end
62
+
63
+ # 3b.
64
+ if element.has_elements?
65
+ element.children.each do |child|
66
+ # increase indent if nested list
67
+ @indent += 1 if element.name=~/(ul|ol)/ and parent.eql?(:li)
68
+
69
+ if child.node_type.eql?(:element)
70
+ parse_element(child, element.name.to_sym)
71
+ else
72
+ if parent.eql?(:blockquote)
73
+ @output << child.to_s.gsub("\n ", "\n>")
74
+ else
75
+ @output << child.to_s
76
+ end
77
+ end
78
+
79
+ # decrease indent if end of nested list
80
+ @indent -= 1 if element.name=~/(ul|ol)/ and parent.eql?(:li)
81
+ end
82
+ end
83
+
84
+ # 4.
85
+ @output << ending(element, parent)
86
+ end
87
+
88
+ # Returns opening markdown tag for the element. Its parent matters sometimes!
89
+ def opening(type, parent)
90
+ case type.name.to_sym
91
+ when :h1
92
+ "# "
93
+ when :li
94
+ parent.eql?(:ul) ? " - " : " "+(@li_counter+=1).to_s+". "
95
+ when :ol
96
+ @li_counter = 0
97
+ ""
98
+ when :ul
99
+ ""
100
+ when :h2
101
+ "## "
102
+ when :h3
103
+ "### "
104
+ when :h4
105
+ "#### "
106
+ when :h5
107
+ "##### "
108
+ when :h6
109
+ "###### "
110
+ when :em
111
+ "*"
112
+ when :strong
113
+ "**"
114
+ when :blockquote
115
+ # remove leading newline
116
+ type.children.first.value = ""
117
+ "> "
118
+ when :code
119
+ parent.eql?(:pre) ? " " : "`"
120
+ when :a
121
+ "["
122
+ when :img
123
+ "!["
124
+ when :hr
125
+ "----------\n\n"
126
+ when :root
127
+ ""
128
+ else
129
+ @errors << "unknown start tag: "+type.name.to_s
130
+ ""
131
+ end
132
+ end
133
+
134
+ # Returns the closing markdown tag, like opening()
135
+ def ending(type, parent)
136
+ case type.name.to_sym
137
+ when :h1
138
+ " #\n\n"
139
+ when :h2
140
+ " ##\n\n"
141
+ when :h3
142
+ " ###\n\n"
143
+ when :h4
144
+ " ####\n\n"
145
+ when :h5
146
+ " #####\n\n"
147
+ when :h6
148
+ " ######\n\n"
149
+ when :p
150
+ parent.eql?(:root) ? "\n\n" : "\n"
151
+ when :ol
152
+ parent.eql?(:li) ? "" : "\n"
153
+ when :ul
154
+ parent.eql?(:li) ? "" : "\n"
155
+ when :em
156
+ "*"
157
+ when :strong
158
+ "**"
159
+ when :li
160
+ ""
161
+ when :blockquote
162
+ ""
163
+ when :code
164
+ parent.eql?(:pre) ? "" : "`"
165
+ when :a
166
+ @links << type.attribute('href').to_s
167
+ "][" + @links.size.to_s + "] "
168
+ when :img
169
+ @links << type.attribute('src').to_s
170
+ "" + type.attribute('alt').to_s + "][" + @links.size.to_s + "] "
171
+ "#{type.attribute('alt')}][#{@links.size}] "
172
+ when :root
173
+ ""
174
+ else
175
+ @errors << " unknown end tag: "+type.name.to_s
176
+ ""
177
+ end
178
+ end
179
+
180
+ # Perform indent: two space, @indent times - quite simple! :)
181
+ def indent
182
+ str = ""
183
+ @indent.times do
184
+ str << " "
185
+ end
186
+ str
187
+ end
188
+
189
+ # Return the content of element, which should be just text.
190
+ # If its a code block to indent of 4 spaces.
191
+ # For block quotation add a leading '>'
192
+ def text_node(element, parent)
193
+ if element.name.to_sym.eql?(:code) and parent.eql?(:pre)
194
+ element.text.gsub("\n","\n ") << "\n"
195
+ elsif parent.eql?(:blockquote)
196
+ element.text.gsub!("\n ","\n>")
197
+ else
198
+ element.text
199
+ end
200
+ end
201
+
202
+ # Insert the mentioned reference style links.
203
+ def insert_links
204
+ @output << "\n"
205
+ @links.each_index do |index|
206
+ @output << " [#{index+1}]: #{@links[index]}\n"
207
+ end
208
+ end
209
+
210
+ # Print out all errors, that occured and have been written to @errors.
211
+ def print_errors
212
+ @errors.each do |error|
213
+ puts error
214
+ end
215
+ end
216
+
217
+ # Perform a benchmark on a given string n-times.
218
+ def speed_benchmark(string, n)
219
+ initialize()
220
+ bm(15) do |test|
221
+ test.report("reverse markdown:") { n.times do; parse_string(string); initialize(); end; }
222
+ end
223
+ end
224
+
225
+ end
226
+
227
+ if __FILE__ == $0
228
+
229
+ # Example HTML Code for parsing
230
+ example = <<-EOF
231
+ This text, though not within an element, should also be shown.
232
+
233
+ <h2>heading 1.1</h2>
234
+
235
+ <p>text *italic* and **bold**.</p>
236
+
237
+ <pre><code>text *italic* and **bold**.
238
+ sdfsdff
239
+ sdfsd
240
+ sdf sdfsdf
241
+ </code></pre>
242
+
243
+ <blockquote>
244
+ <p>text <em>italic</em> and <strong>bold</strong>. sdfsdff
245
+ sdfsd sdf sdfsdf</p>
246
+ </blockquote>
247
+
248
+ <p>asdasd <code>sdfsdfsdf</code> asdad <a href="http://www.bla.de">link text</a></p>
249
+
250
+ <p><a href="http://www.bla.de">link <strong>text</strong></a></p>
251
+
252
+ <ol>
253
+ <li>List item</li>
254
+ <li>List <em>item</em>
255
+ <ol><li>List item</li>
256
+ <li>dsfdsf
257
+ <ul><li>dfwe</li>
258
+ <li>dsfsdfsdf</li></ul></li>
259
+ <li>lidsf <img src="http://www.dfgdfg.de/dsf.jpe" alt="item" title="" /></li></ol></li>
260
+ <li>sdfsdfsdf
261
+ <ul><li>sdfsdfsdf</li>
262
+ <li>sdfsdfsdf <strong>sdfsdf</strong></li></ul></li>
263
+ </ol>
264
+
265
+ <blockquote>
266
+ <p>Lorem ipsum dolor sit amet, consetetur
267
+ voluptua. At vero eos et accusam et
268
+ justo duo dolores et ea rebum. Stet
269
+ clita kasd gubergren, no sea takimata
270
+ sanctus est Lorem ipsum dolor sit
271
+ amet. <em>italic</em></p>
272
+ </blockquote>
273
+
274
+ <hr />
275
+
276
+ <blockquote>
277
+ <p>Lorem ipsum dolor sit amet, consetetur
278
+ sadipscing elitr, sed diam nonumy
279
+ eirmod tempor invidunt ut labore et
280
+ dolore magna aliquyam erat, sed</p>
281
+ </blockquote>
282
+
283
+ This should also be shown, even if it's not wrapped in an element.
284
+
285
+ <p>nur ein text! nur eine maschine!</p>
286
+
287
+ This text should not be invisible!
288
+ EOF
289
+
290
+ r = ReverseMarkdown.new
291
+
292
+ puts r.parse_string(example)
293
+
294
+ #r.print_errors
295
+
296
+ #r.speed_benchmark(example, 100)
297
+ end
@@ -0,0 +1,51 @@
1
+ class Utils
2
+ # From the trollop rubygem
3
+ # File lib/trollop.rb, line 644
4
+ def self.wrap_line str, opts={}
5
+ prefix = opts[:prefix] || 0
6
+ width = opts[:width] || (self.width - 1)
7
+ start = 0
8
+ ret = []
9
+ until start > str.length
10
+ nextt =
11
+ if start + width >= str.length
12
+ str.length
13
+ else
14
+ x = str.rindex(/\s/, start + width)
15
+ x = str.index(/\s/, start) if x && x < start
16
+ x || str.length
17
+ end
18
+ ret << (ret.empty? ? "" : " " * prefix) + str[start ... nextt]
19
+ start = nextt + 1
20
+ end
21
+ ret
22
+ end
23
+
24
+ # From the trollop rubygem
25
+ # File lib/trollop.rb, line 505
26
+ def self.wrap str, opts={} # :nodoc:
27
+ if str == ""
28
+ [""]
29
+ else
30
+ str.split("\n").map { |s| self.wrap_line s, opts }.flatten(1).join("\n")
31
+ end
32
+ end
33
+
34
+ # From the trollop rubygem
35
+ # File lib/trollop.rb, line 489
36
+ def self.width #:nodoc:
37
+ @@width ||= if $stdout.tty?
38
+ begin
39
+ require 'curses'
40
+ Curses::init_screen
41
+ x = Curses::cols
42
+ Curses::close_screen
43
+ x
44
+ rescue Exception
45
+ 80
46
+ end
47
+ else
48
+ 80
49
+ end
50
+ end
51
+ end
metadata ADDED
@@ -0,0 +1,166 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: google-copy-link
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jean-Michel Garnier
9
+ - Kerrick Long
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-05-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: trollop
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '1'
31
+ - !ruby/object:Gem::Dependency
32
+ name: json
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1'
47
+ - !ruby/object:Gem::Dependency
48
+ name: htmlentities
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '4'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '4'
63
+ - !ruby/object:Gem::Dependency
64
+ name: formatador
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: '0.2'
71
+ type: :runtime
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: '0.2'
79
+ - !ruby/object:Gem::Dependency
80
+ name: clipboard
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ~>
85
+ - !ruby/object:Gem::Version
86
+ version: 1.0.1
87
+ type: :runtime
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ~>
93
+ - !ruby/object:Gem::Version
94
+ version: 1.0.1
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ~>
101
+ - !ruby/object:Gem::Version
102
+ version: '2.5'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '2.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ version: '0.2'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ version: '0.2'
127
+ description: A ruby gem to give you the power of Google Search in your command line
128
+ and copy links to your clipboard
129
+ email:
130
+ executables:
131
+ - goo
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - bin/goo
136
+ - lib/google.rb
137
+ - lib/google/utils.rb
138
+ - lib/google/reverse-markdown/reverse_markdown.rb
139
+ - LICENSE.md
140
+ - README.md
141
+ - google.gemspec
142
+ homepage: https://github.com/21croissants/google
143
+ licenses: []
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
+ none: false
156
+ requirements:
157
+ - - ! '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ requirements: []
161
+ rubyforge_project:
162
+ rubygems_version: 1.8.24
163
+ signing_key:
164
+ specification_version: 3
165
+ summary: Google Search on the command line
166
+ test_files: []