sekka 1.7.0 → 1.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f14974e9acd87ad10f08d88a02162ef21a8c7fff
4
- data.tar.gz: c9d7db3ca95a63b316d8089c947ab23424cde502
3
+ metadata.gz: 68e39f2abd18a04dded3aa414d166935798ea4b7
4
+ data.tar.gz: dd3c4f863160bc9d7d7310f5783f1ffbfcfdeba3
5
5
  SHA512:
6
- metadata.gz: 97f809c4c8f84c6a5123a7b71ac6f0698c46d4104b1661eb1428ea557cf9c650f47f324d7b2e2c9dfe16e1e30ad3d4b531fc6dcd1595ac5ee34535b392b6b84e
7
- data.tar.gz: 68af3d5572e414b082afb7ec85f2024912387a2df90b43de0f68c098854e1698f6def4c01190141e77099a121e749ea74ba54d246b9c5c23c8f9bd2347c8e91d
6
+ metadata.gz: a476ff53c1f26fe54f027916db088c7acbf4bad6a26874869f33e3b57045de9ff280c3364ade55af903846e68ef966faf9e9b032e31da3134dc8e10662d4ff0b
7
+ data.tar.gz: e74a861ddaaf1177b97f75f58a4236946c694375da1aee3c050965927d5751f218ecfdb6fcea5a17a885fa229c85788594c440caeb443bf50a31dbd3a61e16b4
data/.gitignore CHANGED
@@ -26,4 +26,8 @@
26
26
  /test.log
27
27
  /test.record
28
28
  /test.tch
29
+ /test1.mapdb
30
+ /test2.mapdb
31
+ /test_mapdb
32
+ /test_mapdb.p
29
33
  /tmpfile.euc
@@ -6,6 +6,7 @@ rvm:
6
6
  - 2.2.0
7
7
  - 2.3.0
8
8
  - 2.4.0
9
+ - jruby-19mode
9
10
 
10
11
  env:
11
12
  - DB=pure
@@ -13,3 +14,10 @@ env:
13
14
 
14
15
  gemfile:
15
16
  - gemfiles/Gemfile
17
+
18
+ matrix:
19
+ allow_failures:
20
+ - rvm: jruby-19mode
21
+
22
+ jdk:
23
+ - oraclejdk8
data/COPYING CHANGED
@@ -54,4 +54,20 @@ Copyright of test/skk-azik-table.nnd ----------------------------------------
54
54
  This file is covered by GPL version 2
55
55
  ported from DDSKK-14.1.90
56
56
 
57
+ Copy right of lib/sekka/jar/lz4-1.3.0.jar ---------------------------------
58
+ Copy right of lib/sekka/jar/elsa-3.0.0-M7.jar
59
+ Copy right of lib/sekka/jar/kotlin-compiler-1.1.2-3.jar
60
+ Copy right of lib/sekka/jar/kotlin-stdlib-jre8-1.1.2-3.jar
61
+ Copy right of lib/sekka/jar/guava-19.0.jar
62
+ Copy right of lib/sekka/jar/google-collections-1.0.jar
63
+ Copy right of lib/sekka/jar/mapdb-3.1.0-SNAPSHOT.jar
64
+
65
+ This file is covered by Apache License Version 2.0
66
+
67
+ Copy right of lib/sekka/jar/eclipse-collections-8.2.0.jar -------------------
68
+ Copy right of lib/sekka/jar/eclipse-collections-api-8.2.0.jar
69
+
70
+ Eclipse Collections is open sourced under the Eclipse Public License v1.0
71
+ and the Eclipse Distribution License v1.0.
72
+
57
73
  -----------------------------------------------------------------------------
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sekka (石火) SKK like Japanese input method
2
2
 
3
- ![Logo]( https://dl.dropboxusercontent.com/u/3870066/blog/iStock_000016378483XTiny.jpg ) [![Build Status](https://travis-ci.org/kiyoka/sekka.svg?branch=master)](https://travis-ci.org/kiyoka/sekka)
3
+ ![Logo](https://www.dropbox.com/s/eabcg33iqx5h7nw/iStock_000016378483XTiny.jpg?raw=1) [![Build Status](https://travis-ci.org/kiyoka/sekka.svg?branch=master)](https://travis-ci.org/kiyoka/sekka)
4
4
 
5
5
  ----
6
6
 
data/Rakefile CHANGED
@@ -15,6 +15,8 @@
15
15
  # DB=gdbm
16
16
  # DB=tokyocabinet
17
17
  # DB=redis
18
+ # DB=pure pure Ruby(for travis-ci)
19
+ # DB=mapdb for Java platform
18
20
  # DB= (default)
19
21
  # DB=all gdbm/tokyocabinet/redis
20
22
  #
@@ -76,13 +78,17 @@ task :test do
76
78
  exit 1
77
79
  end
78
80
 
79
- ["test.record", "test.tch", "test.db" ].each {|name|
81
+ ["test.record", "test.tch", "test.db", "test1.mapdb", "test2.mapdb"].each {|name|
80
82
  File.unlink( name ) if File.exist?( name )
81
83
  }
82
84
  ["test.ldb"].each {|name|
83
85
  FileUtils.rm_rf( name ) if File.exist?( name )
84
86
  }
85
87
  files = []
88
+ if RUBY_PLATFORM == 'java'
89
+ files << "./test/jruby_mapdb.nnd"
90
+ end
91
+ files << "./test/downloader.nnd"
86
92
  files << "./test/memcache.nnd"
87
93
  files << "./test/util.nnd"
88
94
  files << "./test/alphabet-lib.nnd"
@@ -102,6 +108,8 @@ task :test do
102
108
  when 'redis'
103
109
  files << "./test/redis.nnd"
104
110
  files << "./test/henkan-main.nnd redis"
111
+ when 'mapdb'
112
+ files << "./test/henkan-main.nnd mapdb"
105
113
  when 'pure'
106
114
  files << "./test/henkan-main.nnd pure"
107
115
  when 'all'
@@ -111,9 +119,14 @@ task :test do
111
119
  files << "./test/henkan-main.nnd pure"
112
120
  files << "./test/henkan-main.nnd leveldb"
113
121
  else # default
114
- files << "./test/henkan-main.nnd tokyocabinet"
115
- files << "./test/henkan-main.nnd pure"
116
- files << "./test/henkan-main.nnd leveldb"
122
+ if RUBY_PLATFORM == 'java'
123
+ files << "./test/henkan-main.nnd mapdb"
124
+ files << "./test/henkan-main.nnd pure"
125
+ else
126
+ files << "./test/henkan-main.nnd tokyocabinet"
127
+ files << "./test/henkan-main.nnd pure"
128
+ files << "./test/henkan-main.nnd leveldb"
129
+ end
117
130
  end
118
131
  files.each {|filename|
119
132
  sh sprintf( "export RUBY_THREAD_VM_STACK_SIZE=100000 ; ruby -I ./lib -S nendo -I ./lib -d %s", filename )
@@ -149,11 +162,11 @@ task :load do
149
162
  end
150
163
 
151
164
  task :dump do
152
- sh sprintf( "ruby ./bin/sekka-jisyo dump ./data/SEKKA-JISYO.N.tch#xmsiz=1024m > ./data/SEKKA-JISYO-%s.N.tsv", dictVersion )
165
+ sh sprintf( "ruby ./bin/sekka-jisyo dump ./data/SEKKA-JISYO-%s.N.mapdb > ./data/SEKKA-JISYO-%s.N.tsv", dictVersion, dictVersion )
153
166
  end
154
167
 
155
168
  task :restore do
156
- sh sprintf("export RUBY_THREAD_VM_STACK_SIZE=100000 ; ruby -I ./lib ./bin/sekka-jisyo restore ./data/SEKKA-JISYO-%s.N.tsv jisyo.N.ldb", dictVersion )
169
+ sh sprintf("export RUBY_THREAD_VM_STACK_SIZE=100000 ; ruby -I ./lib ./bin/sekka-jisyo restore ./data/SEKKA-JISYO-%s.N.tsv ./data/SEKKA-JISYO-%s.N.mapdb", dictVersion, dictVersion )
157
170
  end
158
171
 
159
172
  task :load_leveldb do
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 7
4
- :patch: 0
4
+ :patch: 1
@@ -85,14 +85,17 @@ core.evalStr( <<";;END-OF-SCRIPT" )
85
85
  (print " sekka-jisyo load SEKKA-JISYO.X SEKKA-JISYO.X.tch ... load SEKKA-JISYO to Tokyo Cabinet DB")
86
86
  (print " sekka-jisyo load SEKKA-JISYO.X SEKKA-JISYO.X.db ... load SEKKA-JISYO to gdbm DB")
87
87
  (print " sekka-jisyo load SEKKA-JISYO.X SEKKA-JISYO.X.ldb ... load SEKKA-JISYO to LevelDB")
88
+ (print " sekka-jisyo load SEKKA-JISYO.X SEKKA-JISYO.X.mapdb ... load SEKKA-JISYO to MapDB")
88
89
  (print " sekka-jisyo load SEKKA-JISYO.X redis:[hostname] ... load SEKKA-JISYO to redis DB on [hostname]")
89
90
  (print " sekka-jisyo load SEKKA-JISYO.X redis: ... load SEKKA-JISYO to redis DB on localhost")
90
91
  (print " sekka-jisyo dump SEKKA-JISYO.X.tch ... dump Tokyo Cabinet DB to DUMPDATA(STDOUT)")
91
92
  (print " sekka-jisyo dump SEKKA-JISYO.X.db ... dump gdbm to DUMPDATA(STDOUT)")
92
93
  (print " sekka-jisyo dump SEKKA-JISYO.X.ldb ... dump LevelDB to DUMPDATA(STDOUT)")
94
+ (print " sekka-jisyo dump SEKKA-JISYO.X.mapdb ... dump MapDB to DUMPDATA(STDOUT)")
93
95
  (print " sekka-jisyo dump redis:[hostname] ... dump redis DB on [hostname] to DUMPDATA(STDOUT)")
94
96
  (print " sekka-jisyo dump redis: ... dump redis DB on localhost to DUMPDATE(STDOUT)")
95
97
  (print " sekka-jisyo restore SEKKA-JISYO.X.tsv SEKKA-JISYO.X.tch ... restore Tokyo Cabinet DB from tsv-file")
98
+ (print " sekka-jisyo restore SEKKA-JISYO.X.tsv SEKKA-JISYO.X.mapdb ... restore MapDB from tsv-file")
96
99
  (print " sekka-jisyo restore SEKKA-JISYO.X.tsv redis:[hostname] ... restore redis DB on [hostname] from tsv-file")
97
100
  (print " sekka-jisyo restore SEKKA-JISYO.X.tsv redis: ... restore redis DB on localhost from tsv-file"))
98
101
 
@@ -105,6 +108,8 @@ core.evalStr( <<";;END-OF-SCRIPT" )
105
108
  (values 'gdbm filename))
106
109
  ((rxmatch #/[.]ldb$/ filename)
107
110
  (values 'leveldb filename))
111
+ ((rxmatch #/[.]mapdb$/ filename)
112
+ (values 'mapdb filename))
108
113
  ((rxmatch #/^redis:(.*)$/ filename)
109
114
  => (lambda (m)
110
115
  (let1 str (rxmatch-substring m 1)
@@ -7,6 +7,7 @@ require 'rack'
7
7
  require 'uri'
8
8
  require 'sekkaconfig'
9
9
  require 'sekka/sekkaversion'
10
+ require 'sekka/downloader'
10
11
 
11
12
 
12
13
 
@@ -21,14 +22,18 @@ TSV_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.tsv", DICTDIR, SekkaVer
21
22
  TSV_SUMFILE = sprintf( "%s/SEKKA-JISYO-%s.N.md5", DICTDIR, SekkaVersion.dictVersion )
22
23
  LDB_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.ldb.tar.gz", DICTDIR, SekkaVersion.dictVersion )
23
24
  LDB_SUMFILE = sprintf( "%s/SEKKA-JISYO-%s.N.ldb.tar.gz.md5", DICTDIR, SekkaVersion.dictVersion )
25
+ MAPDB_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.mapdb", DICTDIR, SekkaVersion.dictVersion )
26
+ MAPDB_SUMFILE = sprintf( "%s/SEKKA-JISYO-%s.N.mapdb.md5", DICTDIR, SekkaVersion.dictVersion )
24
27
 
25
- GDBM_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.db", DICTDIR, SekkaVersion.dictVersion )
26
- LEVELDB_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.ldb", DICTDIR, SekkaVersion.dictVersion )
28
+ GDBM_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.db", DICTDIR, SekkaVersion.dictVersion )
29
+ LEVELDB_FILE = sprintf( "%s/SEKKA-JISYO-%s.N.ldb", DICTDIR, SekkaVersion.dictVersion )
27
30
 
28
31
  TSV_URLURL = sprintf( "%s/SEKKA-JISYO-%s.N.url", DICTURL, SekkaVersion.dictVersion )
29
32
  TSV_SUMURL = sprintf( "%s/SEKKA-JISYO-%s.N.md5", DICTURL, SekkaVersion.dictVersion )
30
33
  LDB_URLURL = sprintf( "%s/SEKKA-JISYO-%s.N.ldb.tar.gz.url", DICTURL, SekkaVersion.dictVersion )
31
34
  LDB_SUMURL = sprintf( "%s/SEKKA-JISYO-%s.N.ldb.tar.gz.md5", DICTURL, SekkaVersion.dictVersion )
35
+ MAPDB_URLURL = sprintf( "%s/SEKKA-JISYO-%s.N.mapdb.url", DICTURL, SekkaVersion.dictVersion )
36
+ MAPDB_SUMURL = sprintf( "%s/SEKKA-JISYO-%s.N.mapdb.md5", DICTURL, SekkaVersion.dictVersion )
32
37
 
33
38
  MEMCACHED = "localhost:11211" # memcahced
34
39
 
@@ -48,11 +53,17 @@ def getSekkaDbInfo( env )
48
53
  [ :gdbm, nil ]
49
54
  elsif m = ENV['SEKKA_DB'].match( /^level[a-z]+$/i )
50
55
  [ :leveldb, nil ]
56
+ elsif m = ENV['SEKKA_DB'].match( /^map[a-z]+$/i )
57
+ [ :mapdb, nil ]
51
58
  else
52
- raise RuntimeError, "Error: env var SEKKA_DB requires [redis:hostname] or [redis:] or [tokyocabinet] or [leveldb]"
59
+ raise RuntimeError, "Error: env var SEKKA_DB requires [redis:hostname] or [redis:] or [tokyocabinet] or [leveldb] or [mapdb]"
53
60
  end
54
61
  else
55
- [ :tokyocabinet, nil ]
62
+ if RUBY_PLATFORM == 'java'
63
+ [ :mapdb, nil ]
64
+ else
65
+ [ :tokyocabinet, nil ]
66
+ end
56
67
  end
57
68
  end
58
69
 
@@ -83,6 +94,13 @@ def checkJisyoIsInstalled( dictType, dictSource )
83
94
  ret = kvs.get( key )
84
95
  kvs.close()
85
96
  ret
97
+ when :mapdb
98
+ require 'sekka/kvs'
99
+ kvs = Kvs.new( :mapdb )
100
+ kvs.open( dictSource )
101
+ ret = kvs.get( key )
102
+ kvs.close()
103
+ ret
86
104
  when :redis
87
105
  begin
88
106
  require 'redis'
@@ -103,38 +121,38 @@ end
103
121
  def downloadFile( targetfile, sumfile, urlurl, sumurl )
104
122
  if not File.exist?( targetfile )
105
123
  STDERR.printf( "Info: Downloading SEKKA-JISYO\n" )
106
- # 辞書をダウンロードする
107
- cmd = sprintf( "curl %s", urlurl )
108
- STDERR.printf( "Command : %s\n", cmd )
109
- targeturl = open( "|" + cmd ) { |f|
110
- f.read
111
- }
112
- STDERR.printf( " download URL of target file : %s\n", targeturl );
113
- cmd = sprintf( "curl -o %s %s", targetfile, targeturl )
114
- STDERR.printf( "Command : %s\n", cmd )
115
- system( cmd )
116
- cmd = sprintf( "curl -o %s %s", sumfile, sumurl )
117
- STDERR.printf( "Command : %s\n", cmd )
118
- system( cmd )
124
+ # 辞書のURLをダウンロードする
125
+ dl = Downloader.new( urlurl )
126
+ dl.download()
127
+ targeturl = dl.getBody().chomp
128
+ dl.clearBody()
129
+
130
+ # md5記載ファイルをダウンロード
131
+ dl = Downloader.new( sumurl )
132
+ dl.download()
133
+ md5body = dl.getBody()
134
+ correctSum = md5body.chomp.split[0]
135
+ dl.clearBody()
136
+
137
+ # 辞書ファイル本体をダウンロード
138
+ STDERR.printf( " downloading URL : %s ...\n", targeturl );
139
+ dl = Downloader.new( targeturl )
140
+ dl.downloadToFile( targetfile )
141
+ dl.clearBody()
119
142
 
120
143
  # チェックサムを確認する
121
- downloadSum = ""
122
- open( targetfile ) { |f|
123
- dataBody = f.read
124
- downloadSum = Digest::MD5.hexdigest( dataBody )
125
- }
126
- open( sumfile ) { |f|
127
- correctSum = f.readline.chomp.split[0]
128
- STDERR.printf( " downloaded file's MD5 : %s\n", downloadSum )
129
- STDERR.printf( " correct MD5 : %s\n", correctSum )
130
- if downloadSum == correctSum
131
- STDERR.printf( "Info: downloaded file [%s] verify OK.\n", targetfile )
132
- else
133
- STDERR.printf( "Error: downloaded file [%s] verify NG.\n", targetfile )
134
- File.unlink( targetfile )
135
- exit( 1 )
136
- end
137
- }
144
+ md5 = Digest::MD5.file( targetfile )
145
+ downloadSum = md5.hexdigest
146
+
147
+ STDERR.printf( " downloaded file's MD5 : %s\n", downloadSum )
148
+ STDERR.printf( " correct MD5 : %s\n", correctSum )
149
+ if downloadSum == correctSum
150
+ STDERR.printf( "Info: downloaded file [%s] verify OK.\n", targetfile )
151
+ else
152
+ STDERR.printf( "Error: downloaded file [%s] verify NG.\n", targetfile )
153
+ File.unlink( targetfile )
154
+ exit( 1 )
155
+ end
138
156
  end
139
157
  end
140
158
 
@@ -165,6 +183,8 @@ def main
165
183
  case dictType
166
184
  when :leveldb
167
185
  downloadFile( LDB_FILE, LDB_SUMFILE, LDB_URLURL, LDB_SUMURL )
186
+ when :mapdb
187
+ downloadFile( MAPDB_FILE, MAPDB_SUMFILE, MAPDB_URLURL, MAPDB_SUMURL )
168
188
  else
169
189
  downloadFile( TSV_FILE, TSV_SUMFILE, TSV_URLURL, TSV_SUMURL )
170
190
  end
@@ -209,6 +229,17 @@ def main
209
229
  STDERR.printf( "Info: [OK]\n" )
210
230
  dictSource = TC_FILE
211
231
 
232
+ when :mapdb
233
+ # MapDBに辞書が投入済みか確認する
234
+ ok = checkJisyoIsInstalled( dictType, MAPDB_FILE )
235
+ unless ok
236
+ # tsvファイルをuploadする
237
+ STDERR.printf( "Error: mapdb file is not installed.\n" )
238
+ exit(1)
239
+ end
240
+ STDERR.printf( "Info: [OK]\n" )
241
+ dictSource = MAPDB_FILE
242
+
212
243
  when :redis
213
244
  # redisサーバーに辞書が投入済みか確認する
214
245
  ok = checkJisyoIsInstalled( dictType, dictSource )
@@ -20,6 +20,7 @@
20
20
  /SEKKA-JISYO-1.6.2.N.ldb
21
21
  /SEKKA-JISYO-1.6.2.N.ldb.tar.gz
22
22
  /SEKKA-JISYO-1.6.2.N.ldb.tar.gz.md5
23
+ /SEKKA-JISYO-1.6.2.N.mapdb
23
24
  /SEKKA-JISYO-1.6.2.N.md5
24
25
  /SEKKA-JISYO-1.6.2.N.tsv
25
26
  /SEKKA-JISYO.CUSTOM
@@ -3,7 +3,7 @@
3
3
  ;; Copyright (C) 2010-2014 Kiyoka Nishiyama
4
4
  ;;
5
5
  ;; Author: Kiyoka Nishiyama <kiyoka@sumibi.org>
6
- ;; Version: 1.7.0 ;;SEKKA-VERSION
6
+ ;; Version: 1.7.1 ;;SEKKA-VERSION
7
7
  ;; Keywords: ime, skk, japanese
8
8
  ;; Package-Requires: ((cl-lib "0.3") (concurrent "0.3.1") (popup "0.5.2"))
9
9
  ;; URL: https://github.com/kiyoka/sekka
@@ -1756,7 +1756,7 @@ point から行頭方向に同種の文字列が続く間を漢字変換しま
1756
1756
  (setq default-input-method "japanese-sekka")
1757
1757
 
1758
1758
  (defconst sekka-version
1759
- "1.7.0" ;;SEKKA-VERSION
1759
+ "1.7.1" ;;SEKKA-VERSION
1760
1760
  )
1761
1761
  (defun sekka-version (&optional arg)
1762
1762
  "入力モード変更"
@@ -0,0 +1,102 @@
1
+ # downloader.rb - "downloader for SEKKA-JISYO data"
2
+ #
3
+ # Copyright (c) 2017 Kiyoka Nishiyama <kiyoka@sumibi.org>
4
+ #
5
+ # Redistribution and use in source and binary forms, with or without
6
+ # modification, are permitted provided that the following conditions
7
+ # are met:
8
+ #
9
+ # 1. Redistributions of source code must retain the above copyright
10
+ # notice, this list of conditions and the following disclaimer.
11
+ #
12
+ # 2. Redistributions in binary form must reproduce the above copyright
13
+ # notice, this list of conditions and the following disclaimer in the
14
+ # documentation and/or other materials provided with the distribution.
15
+ #
16
+ # 3. Neither the name of the authors nor the names of its contributors
17
+ # may be used to endorse or promote products derived from this
18
+ # software without specific prior written permission.
19
+ #
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
26
+ # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27
+ # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28
+ # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+ #
32
+ # $Id:
33
+ #
34
+
35
+ require 'net/http'
36
+ require 'uri'
37
+ require 'tmpdir'
38
+ require 'digest'
39
+
40
+ class Downloader
41
+ def initialize( url, savepath = nil )
42
+ @url_str = url
43
+ @body = nil
44
+ end
45
+
46
+ def download()
47
+ url = URI.parse(@url_str)
48
+ if(url)
49
+ req = Net::HTTP::Get.new(url.path)
50
+ http = Net::HTTP.new(url.host,url.port)
51
+ if url.scheme == 'https'
52
+ http.use_ssl = true
53
+ end
54
+ res = http.request(req)
55
+ @body = res.body
56
+ end
57
+ return @body
58
+ end
59
+
60
+ def downloadToFile(path)
61
+ url = URI.parse(@url_str)
62
+ req = Net::HTTP::Get.new url.path
63
+ http = Net::HTTP.new(url.host, url.port)
64
+ if url.scheme == 'https'
65
+ http.use_ssl = true
66
+ end
67
+ http.request req do |response|
68
+ open path, 'wb' do |io|
69
+ response.read_body do |chunk|
70
+ io.write chunk
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def getBodySize()
77
+ size = 0
78
+ if @body
79
+ size = @body.size
80
+ end
81
+ return size
82
+ end
83
+
84
+ def getBody()
85
+ return @body
86
+ end
87
+
88
+ def saveAs(path)
89
+ open(path,"w") {|f|
90
+ f.write(@body)
91
+ }
92
+ end
93
+
94
+ def clearBody()
95
+ @body = nil
96
+ end
97
+
98
+ def calcMD5()
99
+ Digest::MD5.hexdigest @body
100
+ end
101
+
102
+ end