duckgo 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: db9f873a22d18a71f87ef838a110ecb668304e04
4
- data.tar.gz: 5be7c578227e2dacb4f623e43a0f1e3f350b21fc
3
+ metadata.gz: 1bc99459451547866cbe6143bae74a256ae367ee
4
+ data.tar.gz: b38dda87d89a65bea18c3fe59aa3a7373c09c0d9
5
5
  SHA512:
6
- metadata.gz: e53046fc36a7723941ed1fe8b67073e57069b9a773cdcd7bf0257dbca68fef1e4ffe564a9c279e22706311cc082904202996abe4fcb4036c29f02c4c099748bc
7
- data.tar.gz: 8a6cd711c2a08d2214ba2f9d650a538c80eeae8aae631abd84f7b9c35d8f02ece6ec02a43087aa1bff40403abba17f5911cf564f03373869439c18e5c33e0588
6
+ metadata.gz: 7b3f498a3275210e586205c101fcac4d914e5e32ebd9acf1509bdb78c248f3178fe5103d6e7fa4c75c49daf0941fe89448c145e9c504b26b9bbc130fc59fcf8e
7
+ data.tar.gz: 55c352ffce08ba453f1c82af2db897d8a635f7808ef31b4b657afde44da71b25ceb3a4730d5463e7e21252791c532bcf6e4ecba15633df7996b2560ae2942864
data/bin/duckgo CHANGED
@@ -23,6 +23,11 @@ duckgo [--version | -V] : Display version
23
23
  duckgo [--favicon | -f] google.com : Get google's favicon
24
24
  duckgo \\!gem duckgo : Use !bang syntax to search a specific site
25
25
 
26
+ If you do not see an answer, please shorten the search string.
27
+ e.g. 'something with tons of extra information' => 'something'
28
+ This is an aspect of DuckGo I can control, because the official API does not
29
+ allow a full search. More information - https://duckduckgo.com/api
30
+
26
31
  View docs and API on https://github.com/wlib/duckgo
27
32
  Made by Daniel Ethridge | git.io/de
28
33
  """
@@ -43,6 +48,16 @@ case ARGV[0]
43
48
  puts "Queried favicon from #{site}."
44
49
  file.close
45
50
  exit
51
+ when "--infobox", "-i"
52
+ data = get_data(ARGV[1..-1].join(" "))
53
+ extras_data = find_extras(data)
54
+ if extras_data["Infobox"]
55
+ puts extract_infobox(data).to_yaml
56
+ exit
57
+ else
58
+ puts "No infobox retrieved, try more clear search keywords or remove 'the --infobox|-i flag'"
59
+ exit
60
+ end
46
61
  else
47
62
  handle(ARGV[0..-1].join(" "))
48
63
  exit
@@ -0,0 +1,63 @@
1
+ # Extracting Relevant Information
2
+
3
+ Once you get the data and parse it to a hash, you need to filter for the relevant information, here's how.
4
+
5
+ ## extract_common()
6
+
7
+ Extract common occurring relevant information
8
+
9
+ ### Arguments
10
+
11
+ `extract_common(data)`
12
+
13
+ + `data`
14
+ - A hash with the data retrieved from the api (with `get_data()`)
15
+
16
+ ### Usage
17
+
18
+ ```Ruby
19
+ data = get_data("Hello World")
20
+ common = extract_common(data)
21
+ puts common #=> {"Heading"=>"Hello World", "Type"=>"Disambiguation"....
22
+ ```
23
+
24
+ ## find_extras()
25
+
26
+ This is an optional step to extract a deeper understanding of the data received.
27
+
28
+ ### Arguments
29
+
30
+ `find_extras(data)`
31
+
32
+ + `data`
33
+ - A hash with the data retrieved from the api (with `get_data()`)
34
+
35
+ ### Usage
36
+
37
+ ```Ruby
38
+ data = get_data("Mark Zuckerburg")
39
+ extras_data = find_extras(data)
40
+ puts extras_data #=> {"Infobox"=>{"Total"=>13}, "Results"=>{"Total"=>1}}
41
+ ```
42
+
43
+ ## extract_extras()
44
+
45
+ This is how we auomatically handle extracting extra data, based off of the output of `find_extras()`
46
+
47
+ ### Arguments
48
+
49
+ `extract_extras(data, extras_data)`
50
+
51
+ + `data`
52
+ - A hash with the data retrieved from the api (with `get_data()`)
53
+ + `extras_data`
54
+ - The hash we got from `find_extras()`
55
+
56
+ ### Usage
57
+
58
+ ```Ruby
59
+ data = get_data("Apple Inc.")
60
+ extras_data = find_extras(data)
61
+ extras = extract_extras(data, extras_data)
62
+ puts extras #=> {"Infobox"=>{"Traded as"=>"NASDAQ: aapl AAPl...}, "Results"=>{"Official Site"...
63
+ ```
@@ -1,3 +1,3 @@
1
1
  module DuckGo
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckgo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Ethridge
@@ -54,11 +54,10 @@ files:
54
54
  - Rakefile
55
55
  - bin/duckgo
56
56
  - bin/setup
57
- - de.surge.sh-favicon.ico
58
57
  - docs/README.md
58
+ - docs/extracting_relevant_info.md
59
59
  - docs/getting_data.md
60
60
  - duckgo.gemspec
61
- - due.s-favicon.ico
62
61
  - lib/duckgo.rb
63
62
  - lib/duckgo/version.rb
64
63
  homepage: https://github.com/wlib/duckgo
File without changes
File without changes