rubyduck 0.0.0-x86-linux
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.
- data.tar.gz.sig +0 -0
- data/README.md +20 -0
- data/UNLICENSE +24 -0
- data/lib/rubyduck.rb +38 -0
- metadata +106 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
RubyDuck
|
2
|
+
========
|
3
|
+
|
4
|
+
RubyDuck is a Ruby library for interacting with
|
5
|
+
[DuckDuckGo](https://duckduckgo.com/).
|
6
|
+
|
7
|
+
Usage
|
8
|
+
-----
|
9
|
+
|
10
|
+
require 'rubyduck'
|
11
|
+
|
12
|
+
ddg = DuckDuckGo
|
13
|
+
|
14
|
+
ddg.describe("Paris") # "Paris is the capital of France."
|
15
|
+
ddg.describe("ijrnliwks") # nil
|
16
|
+
|
17
|
+
License
|
18
|
+
-------
|
19
|
+
|
20
|
+
This is free and unencumbered software released into the public domain.
|
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
data/lib/rubyduck.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
# Search for things on DuckDuckGo.com.
|
7
|
+
class DuckDuckGo
|
8
|
+
def initialize()
|
9
|
+
@con = Net::HTTP.new('api.duckduckgo.com', 443)
|
10
|
+
@con.use_ssl = true
|
11
|
+
end
|
12
|
+
|
13
|
+
# Give a short description about the query. Return nil if we don't know
|
14
|
+
# anything about it.
|
15
|
+
def describe(q)
|
16
|
+
res = json_query(q)
|
17
|
+
|
18
|
+
if not(res["AbstractText"].empty?)
|
19
|
+
return res["AbstractText"]
|
20
|
+
elsif (_=res["RelatedTopics"][0]) and _["Text"]
|
21
|
+
return _["Text"]
|
22
|
+
else
|
23
|
+
return nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
#private
|
28
|
+
|
29
|
+
# Return the JSON-encoded Hash given to us when we search for +q+.
|
30
|
+
def json_query(q)
|
31
|
+
# 'o' specifies the output format; 'p' determines whether or not safe search
|
32
|
+
# is on (-1 is off, 1 is on); 'q' is the query string.
|
33
|
+
req_path = '/?' + URI.encode_www_form(q: q, p: -1, o: 'json')
|
34
|
+
res_json = @con.get(req_path).body
|
35
|
+
JSON.parse(res_json)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyduck
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: x86-linux
|
7
|
+
authors:
|
8
|
+
- katmagic
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- ! '-----BEGIN CERTIFICATE-----
|
13
|
+
|
14
|
+
MIIDQDCCAiigAwIBAgIBADANBgkqhkiG9w0BAQUFADBGMRgwFgYDVQQDDA90aGUu
|
15
|
+
|
16
|
+
bWFnaWNhbC5rYXQxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixk
|
17
|
+
|
18
|
+
ARkWA2NvbTAeFw0xMTAyMTUwNDU0MDZaFw0xMjAyMTUwNDU0MDZaMEYxGDAWBgNV
|
19
|
+
|
20
|
+
BAMMD3RoZS5tYWdpY2FsLmthdDEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYK
|
21
|
+
|
22
|
+
CZImiZPyLGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
|
23
|
+
|
24
|
+
lOa4PmKeI2SoGx2fvQUQTHF8RpOw52yZgkeB/ZOLHhPGpkxN9zn0sBVRCh+8YsOh
|
25
|
+
|
26
|
+
4GGtY9kS5Z4pkMQhhJkdfqBhWxI/Dk3wkEd+GI0cyQ3cXc/INw/CmiFxvBiKEjoN
|
27
|
+
|
28
|
+
zeLesxMeHoOJmwpdF52VdIVwRanZQpL/9buTw+sJykXp/uSYV30M6A/KaiPdnAaN
|
29
|
+
|
30
|
+
+oautPQYWV3sf27vcOVWWG1gvyS8Ardcd8Nx9lSRf8w9WolMXG8qgCY+OGZQm8WK
|
31
|
+
|
32
|
+
WrJ8G6CEHABpd3123gY0Qx1mpPfgaCCi3nfCaSDIabcGFRvIUMiG6m950xcOOt9G
|
33
|
+
|
34
|
+
X0WDpSHYldyBVr3p+Nz4wQIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIE
|
35
|
+
|
36
|
+
sDAdBgNVHQ4EFgQUTkdCjc2gkF28POXx+iuTDgmaR20wDQYJKoZIhvcNAQEFBQAD
|
37
|
+
|
38
|
+
ggEBAHV/0Mp6m577vyZMxXGdBUcXHAxtd8n4FexczZlZm5NUXwGGVFAeFAG9jY0U
|
39
|
+
|
40
|
+
A/uWI3gIGoE1GOh+iDKnq56epx+wMcWIsLyu7qSbVBgEGmlbYZ9A8LUkk8FQ+CK1
|
41
|
+
|
42
|
+
v5dQUsPRBBYHR/GmQQekkAKumU2n0m1tYLOdKcsi0f3Rjx5XcpUtvgDd4RHiVLcx
|
43
|
+
|
44
|
+
ezvazGDhHTO5Jx5qF3wQ9yJqEoqb+G+tTOBi/OnKOhLKghp7diil8dwBx8jaVw2+
|
45
|
+
|
46
|
+
vfPcHDqz0OtHW/g2q3Y849LoINY8X27EvP0AaCrkrSUhX6736VvUh0gAPBdBQQfj
|
47
|
+
|
48
|
+
Rx1K02ODN+9Ezaa/+0cgt+bNFLM=
|
49
|
+
|
50
|
+
-----END CERTIFICATE-----
|
51
|
+
|
52
|
+
'
|
53
|
+
date: 2011-04-07 00:00:00.000000000 -04:00
|
54
|
+
default_executable:
|
55
|
+
dependencies:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: &85289390 !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: *85289390
|
67
|
+
description: ! 'RubyDuck is a Ruby library for interacting with DuckDuckGo
|
68
|
+
|
69
|
+
( https://duckduckgo.com/ ).
|
70
|
+
|
71
|
+
'
|
72
|
+
email: the.magical.kat@gmail.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- lib/rubyduck.rb
|
78
|
+
- UNLICENSE
|
79
|
+
- README.md
|
80
|
+
has_rdoc: true
|
81
|
+
homepage: https://github.com/katmagic
|
82
|
+
licenses:
|
83
|
+
- Unlicense
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 1.9.2
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project: rubyduck
|
102
|
+
rubygems_version: 1.5.2
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: RubyDuck is a Ruby library for interacting with DuckDuckGo.
|
106
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|