vizi_translator 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/Rakefile +44 -0
  2. data/build_gem1.bat +1 -0
  3. data/build_gem2.bat +1 -0
  4. data/build_gem3.bat +1 -0
  5. data/build_gem4.bat +1 -0
  6. data/data/index.md +17 -0
  7. data/data/testfile.txt +4 -0
  8. data/doc/Object.html +200 -0
  9. data/doc/ParserTest.html +268 -0
  10. data/doc/README_rdoc.html +128 -0
  11. data/doc/Rakefile.html +148 -0
  12. data/doc/Visit.html +487 -0
  13. data/doc/VisitList.html +385 -0
  14. data/doc/Vizi/LogFormat.html +377 -0
  15. data/doc/Vizi/LogParser.html +551 -0
  16. data/doc/Vizi/Translator.html +302 -0
  17. data/doc/Vizi/UnSupportedLanguage.html +212 -0
  18. data/doc/Vizi/Visit.html +487 -0
  19. data/doc/Vizi/VisitList.html +386 -0
  20. data/doc/Vizi.html +159 -0
  21. data/doc/ViziLogFormat.html +382 -0
  22. data/doc/ViziLogParser.html +551 -0
  23. data/doc/created.rid +4 -0
  24. data/doc/docs/Whois_Documentation.doc +0 -0
  25. data/doc/formats/apache-custom-log.pdf +0 -0
  26. data/doc/formats/apache.rtf +238 -0
  27. data/doc/formats/format-descriptions.xls +0 -0
  28. data/doc/formats/w3c-extended.pdf +0 -0
  29. data/doc/formats/w3c-extended.rtf +135 -0
  30. data/doc/images/brick.png +0 -0
  31. data/doc/images/brick_link.png +0 -0
  32. data/doc/images/bug.png +0 -0
  33. data/doc/images/bullet_black.png +0 -0
  34. data/doc/images/bullet_toggle_minus.png +0 -0
  35. data/doc/images/bullet_toggle_plus.png +0 -0
  36. data/doc/images/date.png +0 -0
  37. data/doc/images/find.png +0 -0
  38. data/doc/images/loadingAnimation.gif +0 -0
  39. data/doc/images/macFFBgHack.png +0 -0
  40. data/doc/images/package.png +0 -0
  41. data/doc/images/page_green.png +0 -0
  42. data/doc/images/page_white_text.png +0 -0
  43. data/doc/images/page_white_width.png +0 -0
  44. data/doc/images/plugin.png +0 -0
  45. data/doc/images/ruby.png +0 -0
  46. data/doc/images/tag_green.png +0 -0
  47. data/doc/images/wrench.png +0 -0
  48. data/doc/images/wrench_orange.png +0 -0
  49. data/doc/images/zoom.png +0 -0
  50. data/doc/index.html +68 -0
  51. data/doc/js/darkfish.js +116 -0
  52. data/doc/js/jquery.js +32 -0
  53. data/doc/js/quicksearch.js +114 -0
  54. data/doc/js/thickbox-compressed.js +10 -0
  55. data/doc/lib/vizi/parser_rb.html +63 -0
  56. data/doc/lib/vizi/vizi_tracker_rb.html +63 -0
  57. data/doc/lib/vizi/vizi_translator.html +104 -0
  58. data/doc/lib/vizi/vizi_translator_rb.html +69 -0
  59. data/doc/lib/vizi_log_parser_rb.html +56 -0
  60. data/doc/lib/vizi_tracker_rb.html +56 -0
  61. data/doc/lib/vizi_translator_rb.html +54 -0
  62. data/doc/rdoc.css +759 -0
  63. data/doc/test/parser_test_rb.html +54 -0
  64. data/doc/test/test_helper_rb.html +56 -0
  65. data/doc/testit_rb.html +63 -0
  66. data/geany_run_script.bat +6 -0
  67. data/lib/vizi/vizi_translator +11 -0
  68. data/lib/vizi/vizi_translator.rb +68 -0
  69. data/lib/vizi_translator.rb +5 -0
  70. data/log/system.log +1 -0
  71. data/testit.rb +51 -0
  72. data/vizi_translator.gemspec +17 -0
  73. metadata +122 -0
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
8
+
9
+ <title>File: parser_test.rb [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="../js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="../js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="../js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">2011-05-11 20:32:49 -0400</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ <li>uri</li>
35
+
36
+ </ul>
37
+ </dd>
38
+
39
+
40
+
41
+ </dl>
42
+ </div>
43
+
44
+ <div id="documentation">
45
+
46
+ <div class="description">
47
+ <h2>Description</h2>
48
+
49
+ </div>
50
+
51
+ </div>
52
+ </body>
53
+ </html>
54
+
@@ -0,0 +1,56 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
8
+
9
+ <title>File: test_helper.rb [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="../js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="../js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="../js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="../js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">2011-05-11 20:32:49 -0400</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ <li>test/unit</li>
35
+
36
+ <li>ruby-debug</li>
37
+
38
+ </ul>
39
+ </dd>
40
+
41
+
42
+
43
+ </dl>
44
+ </div>
45
+
46
+ <div id="documentation">
47
+
48
+ <div class="description">
49
+ <h2>Description</h2>
50
+
51
+ </div>
52
+
53
+ </div>
54
+ </body>
55
+ </html>
56
+
@@ -0,0 +1,63 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=IBM437" http-equiv="Content-Type" />
8
+
9
+ <title>File: testit.rb [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">2011-05-21 12:58:06 -0400</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ <li>c:\rails\vizi_tracker\lib\vizi_tracker</li>
35
+
36
+ <li>time</li>
37
+
38
+ <li>yaml</li>
39
+
40
+ <li>logger</li>
41
+
42
+ </ul>
43
+ </dd>
44
+
45
+
46
+
47
+ </dl>
48
+ </div>
49
+
50
+ <div id="documentation">
51
+
52
+ <div class="description">
53
+ <h2>Description</h2>
54
+
55
+ <p>This is a sample application that uses the Vizitracker gem classes Modified
56
+ by ...</p>
57
+
58
+ </div>
59
+
60
+ </div>
61
+ </body>
62
+ </html>
63
+
@@ -0,0 +1,6 @@
1
+ ruby "testit.rb"
2
+
3
+ pause
4
+ del "%0"
5
+
6
+ pause
@@ -0,0 +1,11 @@
1
+ # This gem module provides a classes to find the right Regional Internet Registry
2
+ # for a given IP Address. The query method will navigate each major RIR until a
3
+ # response is found.
4
+ #
5
+ # Author:: Al Kivi <al.kivi@vizitrax.com>
6
+ # License:: MIT
7
+
8
+ module Vizi
9
+ # This class includes a set of methods to navigate and query the regional whois servers
10
+ class Gowhois
11
+
@@ -0,0 +1,68 @@
1
+ # This gem module provides a language translator class based on the Frengly
2
+ # language translation service. The language translation is provided through an
3
+ # HTTP service and requires a registered username and password.
4
+ #
5
+ # Author:: Al Kivi <al.kivi@vizitrax.com>
6
+ # License:: MIT
7
+
8
+ module Vizi
9
+ require 'net/http'
10
+ require 'uri'
11
+ require 'xmlsimple'
12
+
13
+ class UnSupportedLanguage < RuntimeError
14
+ attr :msg
15
+ def initialize(message='')
16
+ @msg = "Language pair not supported yet."
17
+ end
18
+ end
19
+
20
+ # This class includes a set of methods to translate using the Frengly service
21
+ class Translator
22
+ SUPPORTED_LANG_CODES = ['fr','de','es','pt','it','nl','tl','fi','el','iw','pl','ru','sv']
23
+ SUPPORTED_LANG_LIST = {"English" => "en", "French" => "fr", "German" => "de", "Spanish" => "es",
24
+ "Portuguese" => "pt", "Italian" => "it", "Filipino" => "tl","Finnish" => "fi","Greek" => "el",
25
+ "Hebrew" => "iw", "Polish" => "pl", "Russian" => "ru", "Swedish" => "sv"}
26
+
27
+ # method to get array of language codes
28
+ def getcodes
29
+ result = SUPPORTED_LANG_CODES
30
+ end
31
+
32
+ # method to get hash list of languages
33
+ def getlist
34
+ result = SUPPORTED_LANG_LIST
35
+ end
36
+
37
+ # method to translate from one language to another
38
+ def gettext(username, password, input_text, output_code)
39
+ default_src = 'en'
40
+ default_action = 'translateREST'
41
+
42
+ input_text = URI.escape(input_text)
43
+ begin
44
+ raise UnSupportedLanguage unless SUPPORTED_LANG_CODES.include?(output_code)
45
+ site_url = 'www.syslang.com'
46
+ uri_method = '/frengly/controller?'
47
+ uri_string = 'action='+default_action+'&src='+default_src+'&dest='+output_code+'&text='+input_text+'&username='+username+'&password='+password
48
+ response = Net::HTTP.get_response(site_url, uri_method + uri_string)
49
+ if response.code == "200"
50
+ xml_data = response.body
51
+ data = XmlSimple.xml_in(xml_data)
52
+ result = data["translation"][0]
53
+ else
54
+ puts response.body
55
+ raise StandardError, response.body
56
+ end
57
+ rescue UnSupportedLanguage
58
+ raise UnSupportedLanguage.new
59
+ rescue => err_msg
60
+ puts "#{err_msg}"
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+ module Vizi # :doc:
3
+ require 'vizi_translator'
4
+ ## load 'c:\ramaze\viziapp\lib\vizi\vizi_translator.rb'
5
+ end
data/log/system.log ADDED
@@ -0,0 +1 @@
1
+ 
data/testit.rb ADDED
@@ -0,0 +1,51 @@
1
+ # This is a sample application that uses the Vizi_tracker gem classes
2
+ #
3
+ # This application will read a text file for translation.
4
+ # The sample text file is a index markdown file written in English;
5
+ # The English markdown file provides content for Vizitrax's home page.
6
+ # The translated file can be used to replace the English content with content for another language.
7
+ #
8
+ # Author:: Al Kivi <al.kivi@vizitrax.com>
9
+
10
+ require 'c:\ruby-gems\vizi_translator\lib\vizi_translator'
11
+ ## require 'vizi_translator'
12
+
13
+ require 'logger'
14
+ syslog = Logger.new('./log/system.log',shift_age = 'weekly')
15
+
16
+ p 'starting'
17
+ syslog.info "Starting ... >>> "+Time.now.to_s
18
+
19
+ # Set username and password. Username must be registered at Frengly
20
+ username = "akivi"
21
+ password = "welcome123"
22
+
23
+ # Set target language for translation
24
+ targetlanguage = "fr"
25
+
26
+ begin
27
+ # Open test file for translation
28
+ @test = File.read(Dir.pwd+'./data/index.md')
29
+ p 'input file ...'
30
+ p @test
31
+ syslog.info @test
32
+
33
+ # Initiate Translator class
34
+ translator = Vizi::Translator.new
35
+ # Get array with available language codes
36
+ @langcodes = translator.getcodes
37
+ p @langcodes
38
+ # Get hashed list of languages and language codes
39
+ @langlist = translator.getlist
40
+ p @langlist
41
+
42
+ # Call method to do the translation
43
+ @testnew = translator.gettext(username, password, @test, targetlanguage)
44
+ p 'output file ...'
45
+ p @testnew
46
+ syslog.info @testnew
47
+
48
+ p 'ending'
49
+ syslog.info "Ending ... >>> "+Time.now.to_s
50
+ end
51
+
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'vizi_translator'
5
+ s.version = '0.1.0'
6
+ s.summary = "Language translator that provides a wrapper to the Frengly on-line service"
7
+ s.description = "This gem module provides a classes to support the language translation of text files or text strings.
8
+ The Frengly on-line service requires registration and prvoides access with a username and password.
9
+ The gem module uses the NET::HTTP library to access the Frengly service"
10
+ s.files = Dir.glob("**/**/**")
11
+ s.test_files = Dir.glob("test/*_test.rb")
12
+ s.author = "Al Kivi"
13
+ s.homepage = "http://www.vizitrax.com"
14
+ s.email = "al.kivi@vizitrax.com"
15
+ s.has_rdoc = true
16
+ s.required_ruby_version = '>= 1.8.7'
17
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vizi_translator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease: !!null
6
+ platform: ruby
7
+ authors:
8
+ - Al Kivi
9
+ autorequire: !!null
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-02 00:00:00.000000000 -04:00
13
+ default_executable: !!null
14
+ dependencies: []
15
+ description: ! "This gem module provides a classes to support the language translation
16
+ of text files or text strings.\n The Frengly on-line service requires registration
17
+ and prvoides access with a username and password.\n The gem module uses the NET::HTTP
18
+ library to access the Frengly service"
19
+ email: al.kivi@vizitrax.com
20
+ executables: []
21
+ extensions: []
22
+ extra_rdoc_files: []
23
+ files:
24
+ - build_gem1.bat
25
+ - build_gem2.bat
26
+ - build_gem3.bat
27
+ - build_gem4.bat
28
+ - data/index.md
29
+ - data/testfile.txt
30
+ - doc/created.rid
31
+ - doc/docs/Whois_Documentation.doc
32
+ - doc/formats/apache-custom-log.pdf
33
+ - doc/formats/apache.rtf
34
+ - doc/formats/format-descriptions.xls
35
+ - doc/formats/w3c-extended.pdf
36
+ - doc/formats/w3c-extended.rtf
37
+ - doc/images/brick.png
38
+ - doc/images/brick_link.png
39
+ - doc/images/bug.png
40
+ - doc/images/bullet_black.png
41
+ - doc/images/bullet_toggle_minus.png
42
+ - doc/images/bullet_toggle_plus.png
43
+ - doc/images/date.png
44
+ - doc/images/find.png
45
+ - doc/images/loadingAnimation.gif
46
+ - doc/images/macFFBgHack.png
47
+ - doc/images/package.png
48
+ - doc/images/page_green.png
49
+ - doc/images/page_white_text.png
50
+ - doc/images/page_white_width.png
51
+ - doc/images/plugin.png
52
+ - doc/images/ruby.png
53
+ - doc/images/tag_green.png
54
+ - doc/images/wrench.png
55
+ - doc/images/wrench_orange.png
56
+ - doc/images/zoom.png
57
+ - doc/index.html
58
+ - doc/js/darkfish.js
59
+ - doc/js/jquery.js
60
+ - doc/js/quicksearch.js
61
+ - doc/js/thickbox-compressed.js
62
+ - doc/lib/vizi/parser_rb.html
63
+ - doc/lib/vizi/vizi_tracker_rb.html
64
+ - doc/lib/vizi/vizi_translator.html
65
+ - doc/lib/vizi/vizi_translator_rb.html
66
+ - doc/lib/vizi_log_parser_rb.html
67
+ - doc/lib/vizi_tracker_rb.html
68
+ - doc/lib/vizi_translator_rb.html
69
+ - doc/Object.html
70
+ - doc/ParserTest.html
71
+ - doc/Rakefile.html
72
+ - doc/rdoc.css
73
+ - doc/README_rdoc.html
74
+ - doc/test/parser_test_rb.html
75
+ - doc/test/test_helper_rb.html
76
+ - doc/testit_rb.html
77
+ - doc/Visit.html
78
+ - doc/VisitList.html
79
+ - doc/Vizi/LogFormat.html
80
+ - doc/Vizi/LogParser.html
81
+ - doc/Vizi/Translator.html
82
+ - doc/Vizi/UnSupportedLanguage.html
83
+ - doc/Vizi/Visit.html
84
+ - doc/Vizi/VisitList.html
85
+ - doc/Vizi.html
86
+ - doc/ViziLogFormat.html
87
+ - doc/ViziLogParser.html
88
+ - geany_run_script.bat
89
+ - lib/vizi/vizi_translator
90
+ - lib/vizi/vizi_translator.rb
91
+ - lib/vizi_translator.rb
92
+ - log/system.log
93
+ - Rakefile
94
+ - testit.rb
95
+ - vizi_translator-0.1.0.gem
96
+ - vizi_translator.gemspec
97
+ has_rdoc: true
98
+ homepage: http://www.vizitrax.com
99
+ licenses: []
100
+ post_install_message: !!null
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.8.7
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubyforge_project: !!null
118
+ rubygems_version: 1.5.0
119
+ signing_key: !!null
120
+ specification_version: 3
121
+ summary: Language translator that provides a wrapper to the Frengly on-line service
122
+ test_files: []