yahoo-placemaker 0.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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/README.rdoc +0 -0
- data/Rakefile +1 -0
- data/lib/yahoo-placemaker.rb +38 -0
- data/lib/yahoo-placemaker/config.rb +0 -0
- data/lib/yahoo-placemaker/version.rb +5 -0
- data/yahoo-placemaker.gemspec +24 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "yahoo-placemaker/version"
|
2
|
+
require "json"
|
3
|
+
require "ostruct"
|
4
|
+
require "net/http"
|
5
|
+
|
6
|
+
module Yahoo
|
7
|
+
module Placemaker
|
8
|
+
|
9
|
+
def self.extract (text = '')
|
10
|
+
host = 'wherein.yahooapis.com'
|
11
|
+
payload = {
|
12
|
+
'documentContent' => text,
|
13
|
+
'appid' => APP_ID,
|
14
|
+
'outputType' => 'json',
|
15
|
+
'documentType' => 'text/plain'
|
16
|
+
}
|
17
|
+
|
18
|
+
req = ::Net::HTTP::Post.new('/v1/document')
|
19
|
+
req.body = to_url_params(payload)
|
20
|
+
response = ::Net::HTTP.new(host).start do |http|
|
21
|
+
http.request(req)
|
22
|
+
end
|
23
|
+
json = ::JSON.parse(response.body)
|
24
|
+
OpenStruct.new(json)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def self.to_url_params(h)
|
30
|
+
elements = []
|
31
|
+
h.keys.size.times do |i|
|
32
|
+
elements << "#{h.keys[i]}=#{h.values[i]}"
|
33
|
+
end
|
34
|
+
elements.join('&')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "yahoo-placemaker/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "yahoo-placemaker"
|
7
|
+
s.version = Yahoo::Placemaker::VERSION
|
8
|
+
s.authors = ["Kyle Decot"]
|
9
|
+
s.email = ["kyle.decot@me.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = "Easily interact w/ the Yahoo Placemaker API"
|
12
|
+
s.description = "Easily interact w/ the Yahoo Placemaker API"
|
13
|
+
|
14
|
+
s.rubyforge_project = "yahoo-placemaker"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yahoo-placemaker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kyle Decot
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-20 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: Easily interact w/ the Yahoo Placemaker API
|
15
|
+
email:
|
16
|
+
- kyle.decot@me.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README.rdoc
|
24
|
+
- Rakefile
|
25
|
+
- lib/yahoo-placemaker.rb
|
26
|
+
- lib/yahoo-placemaker/config.rb
|
27
|
+
- lib/yahoo-placemaker/version.rb
|
28
|
+
- yahoo-placemaker.gemspec
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: yahoo-placemaker
|
49
|
+
rubygems_version: 1.8.10
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Easily interact w/ the Yahoo Placemaker API
|
53
|
+
test_files: []
|