frank_researcher 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed3cbb31c754a33cf4b563aea0d24e80b44c13bc
4
- data.tar.gz: a1c925f507a00c48331f839236800691878107a8
3
+ metadata.gz: f7e928274de37e4543bf381ffb876eed96ad852f
4
+ data.tar.gz: 49477f81ae7a6cad61d256f0b97ab7b29645fe7f
5
5
  SHA512:
6
- metadata.gz: 7ce27b84c690ef8926c6849fbe1ab18439579f870cf2fe07cc44a4078ab11f3c237e1c805f264a1927567558c52c54551b6039a7539cdacc9c80331d2d8afb45
7
- data.tar.gz: b7a7d94d84eec10d16bf59a52fc7ba27c374134df41ec4c572f1c97eca4287574980a6f9f2892c973cb9ff84f93c8659894c6664e8d520427499295646533689
6
+ metadata.gz: 6f874f50584201d60645b91f93e4258b5c6e745db3bbca1a94361220eb56eb30aa44e5ac7baf61c3c862ef15fb9628dcca4c1ac562619f9c32e013b8ff3e6f9c
7
+ data.tar.gz: dffb5a84a5b59ce658247cb002026a94668e74d7ff6424a2fed5d20beff4fb511377533c97919d67d31612e5d5422d04adac7492cbe35ae8ef83111b0c063fcb
data/demo/test.rb ADDED
@@ -0,0 +1,9 @@
1
+ require '../lib/frank_researcher'
2
+
3
+ FrankResearcher.configure do |config|
4
+ config.google_api_key = ENV['frank_google_api']
5
+ config.google_cx = ENV['frank_google_cx']
6
+ end
7
+
8
+
9
+ FrankResearcher.search('ChatBot')
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'frank_researcher'
3
+ s.version = '0.1.1'
4
+ s.date = '2017-10-14'
5
+ s.summary = "Frank Research"
6
+ s.description = "Ruby client for Google Custom Search"
7
+ s.authors = ["Maurício Jr."]
8
+ s.email = 'mauriciojs.junior@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.homepage = 'http://rubygems.org/gems/frank_researcher'
11
+ s.license = 'MIT'
12
+
13
+ s.add_dependency('rest-client', '~> 2.0')
14
+ end
@@ -0,0 +1,25 @@
1
+ require 'rest-client'
2
+
3
+ module FrankResearcher
4
+ class Client
5
+ attr_accessor :base_url
6
+ def initialize
7
+ google_key = FrankResearcher.configuration.google_api_key
8
+ google_cx = FrankResearcher.configuration.google_cx
9
+ @base_url = "https://www.googleapis.com/customsearch/v1?key=#{google_key}&cx=#{google_cx}"
10
+ end
11
+
12
+ def find params
13
+ response = request(@base_url, params)
14
+ puts response
15
+ end
16
+
17
+ def request url, query
18
+ url << "&q=#{query}"
19
+ response = RestClient.get(url, headers={content_type: :json, accept: :json})
20
+ if response.code == 200
21
+ response.body
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module FrankResearcher
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure
7
+ self.configuration ||= Configuration.new
8
+ yield(configuration)
9
+ end
10
+
11
+ class Configuration
12
+ attr_accessor :google_api_key
13
+ attr_accessor :google_cx
14
+
15
+ def initialize
16
+ @google_api_key = 'google_api_key'
17
+ @google_cx = 'google_cx'
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frank_researcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maurício Jr.
@@ -24,13 +24,17 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.0'
27
- description: Frank search your ruby questions on the web
27
+ description: Ruby client for Google Custom Search
28
28
  email: mauriciojs.junior@gmail.com
29
29
  executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
+ - demo/test.rb
34
+ - frank_researcher.gemspec
33
35
  - lib/frank_researcher.rb
36
+ - lib/frank_researcher/client.rb
37
+ - lib/frank_researcher/configuration.rb
34
38
  homepage: http://rubygems.org/gems/frank_researcher
35
39
  licenses:
36
40
  - MIT