gizoogle 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4d170214299845ba648933d30b38f7099276aa33
4
+ data.tar.gz: 7a8e4d7f69220fdd481e036d39c858fe128c9e30
5
+ SHA512:
6
+ metadata.gz: 647049075d50e10d591d71ef325f960dbf573993c2adf54805e91bebc6133778267cca25beb004019a12c266a550270655c7f2f64ac00625a5acca9b8a7bdb9f
7
+ data.tar.gz: b33c07a260e7ff668aacd71ac9e3b13bcc17557b8964661a1b89ca7726f408dfde475ff2a004975ad09f49f9272d43686d731fe330e41dfe749a7da35ed72ae1
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gizoogle'
4
+
5
+ if $stdin.tty?
6
+ str = ARGV.join(' ')
7
+ puts Gizoogle::String.translate(str) if str.length > 0
8
+ else
9
+ str = $stdin.readlines.join(' ')
10
+ puts Gizoogle::String.translate(str) if str.length > 0
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'gizoogle/string'
2
+ require 'gizoogle/webpage'
3
+
4
+ module Gizoogle
5
+ # nothing to see here, pops
6
+ end
@@ -0,0 +1,32 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+ require 'nokogiri'
4
+
5
+ module Gizoogle
6
+ # Translate your strings into gangsta
7
+ class String
8
+ # Translate a single string, returns translated string
9
+ #
10
+ # Example:
11
+ # >> Gizoogle::String.translate('hello world')
12
+ # => wassup ghetto
13
+ #
14
+ # Arguments:
15
+ # str: (String)
16
+
17
+ def self.translate(str)
18
+ params = { 'translatetext' => str }
19
+ url = URI('http://www.gizoogle.net/textilizer.php')
20
+ resp = Net::HTTP.post_form(url, params)
21
+
22
+ # gizoogle returns invalid html, let's fix that before parsing
23
+ body = resp.body.gsub(/name="translatetext"[^>]*>/,
24
+ 'name="translatetext" >')
25
+
26
+ html_doc = Nokogiri::HTML(body)
27
+ textarea = html_doc.css('textarea[name=translatetext]').first
28
+
29
+ textarea ? textarea.content.strip : str
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ require 'uri'
2
+ require 'net/http'
3
+
4
+ module Gizoogle
5
+ # Translate a whole webpage into gangsta
6
+ class Webpage
7
+ # Translate a webpage, returns translated HTML of page
8
+ #
9
+ # Example:
10
+ # >> Gizoogle::Webpage.translate('github.com')
11
+ # => <html><head>...translated html here...
12
+ #
13
+ # Arguments:
14
+ # url: (String)
15
+ def self.translate(url)
16
+ params = { 'search' => url }
17
+ url = URI('http://www.gizoogle.net/tranzizzle.php')
18
+ url.query = URI.encode_www_form(params)
19
+ body = Net::HTTP.get(url)
20
+
21
+ body
22
+ end
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gizoogle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kyle Powers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.0
27
+ description: Allows translating strings and webpages into gangsta slang
28
+ email: kylepowers@gmail.com
29
+ executables:
30
+ - gizoogle
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/gizoogle
35
+ - lib/gizoogle.rb
36
+ - lib/gizoogle/string.rb
37
+ - lib/gizoogle/webpage.rb
38
+ homepage: https://github.com/mfkp/gizoogle
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.4.5
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: The (unofficial) interface to gizoogle.net
62
+ test_files: []