data_science_theater_3000 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/data_science_theater_3000.gemspec +26 -0
- data/lib/data_science_theater_3000.rb +54 -0
- data/lib/data_science_theater_3000/version.rb +3 -0
- metadata +62 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "data_science_theater_3000/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "data_science_theater_3000"
|
7
|
+
s.version = DataScienceTheater3000::VERSION
|
8
|
+
s.authors = ["Tad Hosford"]
|
9
|
+
s.email = ["tad@isotope11.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Ruby interface to Data Science Toolkit.}
|
12
|
+
s.description = %q{Ruby interface to issue Data Science Toolkit API calls.}
|
13
|
+
|
14
|
+
s.rubyforge_project = "data_science_theater_3000"
|
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
|
+
s.add_dependency 'curb'
|
22
|
+
|
23
|
+
# specify any dependencies here; for example:
|
24
|
+
# s.add_development_dependency "rspec"
|
25
|
+
# s.add_runtime_dependency "rest-client"
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "curb"
|
2
|
+
require "data_science_theater_3000/version"
|
3
|
+
|
4
|
+
module DataScienceTheater3000
|
5
|
+
def self.ip2coordinates ip
|
6
|
+
url = "http://www.datasciencetoolkit.org"
|
7
|
+
response = Curl::Easy.perform( url + "/ip2coordinates/" + ip ).body_str
|
8
|
+
coordinates = make_hashy(response).with_indifferent_access
|
9
|
+
if coordinates[ip].nil?
|
10
|
+
coordinates = { ip => {"country_name"=>"United States", "region"=>"AL", "dma_code"=>630, "latitude"=>33.4667015075684, "country_code"=>"US", "area_code"=>205, "postal_code"=>"35209", "locality"=>"Birmingham", "country_code3"=>"USA", "longitude"=>-86.8066024780273}}.with_indifferent_access
|
11
|
+
else
|
12
|
+
coordinates
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.street2coordinates address
|
17
|
+
url = "http://www.datasciencetoolkit.org"
|
18
|
+
address.gsub!( "," , "%2c" )
|
19
|
+
address.gsub!( " " , "+" )
|
20
|
+
response = Curl::Easy.perform( url + "/street2coordinates/" + address ).body_str
|
21
|
+
|
22
|
+
coordinates = make_hashy(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.coordinates2politics coords
|
26
|
+
url = "http://www.datasciencetoolkit.org"
|
27
|
+
coords.gsub!( "," , "%2c" )
|
28
|
+
response = Curl::Easy.perform( url + "/coordinates2politics/" + coords ).body_str
|
29
|
+
|
30
|
+
coordinates = make_hashy(response)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.text2people name
|
34
|
+
#TODO should take array of names as well
|
35
|
+
#FIXME curl wants different arguments
|
36
|
+
#url = "http://www.datasciencetoolkit.org"
|
37
|
+
#response = Curl::Easy.perform( url + "/text2people/" + name ).body_str
|
38
|
+
|
39
|
+
#person = make_hashy(response)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.text2times text
|
43
|
+
#url = "http://www.datasciencetoolkit.org"
|
44
|
+
#text.gsub!( "," , "%2c" )
|
45
|
+
#FIXME curl wants different arguments
|
46
|
+
#response = Curl::Easy.perform( url + "/text2times/" + text ).body_str
|
47
|
+
|
48
|
+
#times = make_hashy(response)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.make_hashy response
|
52
|
+
ActiveSupport::JSON.decode(response)
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: data_science_theater_3000
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tad Hosford
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-19 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: curb
|
16
|
+
requirement: &10858140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *10858140
|
25
|
+
description: Ruby interface to issue Data Science Toolkit API calls.
|
26
|
+
email:
|
27
|
+
- tad@isotope11.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- Rakefile
|
35
|
+
- data_science_theater_3000.gemspec
|
36
|
+
- lib/data_science_theater_3000.rb
|
37
|
+
- lib/data_science_theater_3000/version.rb
|
38
|
+
homepage: ''
|
39
|
+
licenses: []
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubyforge_project: data_science_theater_3000
|
58
|
+
rubygems_version: 1.8.10
|
59
|
+
signing_key:
|
60
|
+
specification_version: 3
|
61
|
+
summary: Ruby interface to Data Science Toolkit.
|
62
|
+
test_files: []
|