zidian 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
File without changes
data/README.mkd CHANGED
File without changes
data/Rakefile CHANGED
@@ -1,14 +1,19 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
- require 'echoe'
4
3
 
5
- Echoe.new('zidian', '0.0.1') do |p|
6
- p.description = "Chinese dictionary"
7
- p.url = "http://github.com/bastien/zidian"
8
- p.author = "Bastien Vaucher"
9
- p.email = "bastien.vaucher@gmail.com"
10
- p.ignore_pattern = ["tmp/*", "script/*"]
11
- p.development_dependencies = []
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gemspec|
7
+ gemspec.name = "zidian"
8
+ gemspec.summary = "Chinese dictionary"
9
+ gemspec.description = "Chinese dictionary using the CEDICT word list"
10
+ gemspec.email = "bastien.vaucher@gmail.com"
11
+ gemspec.homepage = "http://github.com/bastien/zidian"
12
+ gemspec.authors = ["Bastien Vaucher"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
12
17
  end
13
18
 
14
19
  Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,116 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>File: README.mkd</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="fileHeader">
50
+ <h1>README.mkd</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>README.mkd
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Wed Mar 31 10:52:29 +0200 2010</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <p>
73
+ <a href="../classes/Zidian.html">Zidian</a>
74
+ </p>
75
+ <h6></h6>
76
+ <p>
77
+ <a href="../classes/Zidian.html">Zidian</a> is a simple Chinese-English
78
+ dictionary written in ruby. It only works under Unix systems, as it uses
79
+ specific commands (sed, grep, less), at least for now.
80
+ </p>
81
+ <p>
82
+ Examples of use
83
+ </p>
84
+
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+
91
+ </div>
92
+
93
+
94
+ <!-- if includes -->
95
+
96
+ <div id="section">
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+ <!-- if method_list -->
106
+
107
+
108
+ </div>
109
+
110
+
111
+ <div id="validator-badges">
112
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
113
+ </div>
114
+
115
+ </body>
116
+ </html>
File without changes
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
data/lib/zidian.rb CHANGED
@@ -10,7 +10,7 @@ module Zidian
10
10
  when "String" then
11
11
  find_word(expression).lines.to_a.collect{|line| Word.new(line) }
12
12
  else
13
- raise "Invalid find parameter(#{expression.class}). Only integers, strings accepted"
13
+ raise InvalFindInputException
14
14
  end
15
15
  end
16
16
 
@@ -22,6 +22,7 @@ module Zidian
22
22
  end
23
23
 
24
24
  def self.get_line(line_number) #:nodoc:
25
+ raise InvalidIdException if (line_number < 35 || line_number > 86617)
25
26
  `sed -n '#{line_number}p' #{File.dirname(__FILE__)}/cedict_ts.u8`
26
27
  end
27
28
 
@@ -46,4 +47,16 @@ module Zidian
46
47
 
47
48
  end
48
49
 
50
+ class InvalidIdException < Exception;
51
+ def message
52
+ "Invalid ID, must be between 35 and 86617"
53
+ end
54
+ end
55
+
56
+ class InvalFindInputException < Exception;
57
+ def message
58
+ "Invalid find parameter. Only integers, strings accepted"
59
+ end
60
+ end
61
+
49
62
  end
@@ -0,0 +1,47 @@
1
+ require "#{File.dirname(__FILE__)}/../lib/zidian"
2
+ require "test/unit"
3
+
4
+ class TestZidian < Test::Unit::TestCase
5
+
6
+ def test_get_word_from_id
7
+ word = Zidian.find(200)
8
+ assert_equal(["aside", "to the side of"], word.english)
9
+ assert_equal("一旁", word.simplified)
10
+ end
11
+
12
+ def test_get_words_from_ids
13
+ words = Zidian.find([200, 210])
14
+ assert_equal(["aside", "to the side of"], words.first.english)
15
+ assert_equal(["a moment, a while", "in a moment"], words.last.english)
16
+ end
17
+
18
+ def test_raise_invalid_id
19
+ assert_raise(Zidian::InvalidIdException) do
20
+ Zidian.find(25)
21
+ end
22
+ assert_raise(Zidian::InvalidIdException) do
23
+ Zidian.find(86618)
24
+ end
25
+ end
26
+
27
+ def test_find_word_from_string
28
+ words = Zidian.find("shanghai")
29
+ assert_equal("guai3", words.last.pinyin)
30
+ end
31
+
32
+ def test_raise_when_invalid_input_type
33
+ assert_raise(Zidian::InvalFindInputException) do
34
+ Zidian.find(:shanghai)
35
+ end
36
+ end
37
+
38
+ def test_word_proper_extraction
39
+ word = Zidian::Word.new("134:一夫當關,萬夫莫開 一夫当关,万夫莫开 [yi1 fu1 dang1 guan1 , wan4 fu1 mo4 kai1] /If one man holds the pass, ten thousand cannot pass (idiom); One man can hold the pass against ten thousand enemies/\n")
40
+ assert_equal(134, word.id)
41
+ assert_equal("一夫當關,萬夫莫開", word.traditional)
42
+ assert_equal("一夫当关,万夫莫开", word.simplified)
43
+ assert_equal("yi1 fu1 dang1 guan1 , wan4 fu1 mo4 kai1", word.pinyin)
44
+ assert_equal(["If one man holds the pass, ten thousand cannot pass (idiom); One man can hold the pass against ten thousand enemies"], word.english)
45
+ end
46
+
47
+ end
data/zidian.gemspec CHANGED
@@ -1,22 +1,41 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{zidian}
5
- s.version = "0.0.1"
8
+ s.version = "0.1.0"
6
9
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Bastien Vaucher"]
9
- s.date = %q{2010-03-31}
10
- s.description = %q{Chinese dictionary}
12
+ s.date = %q{2010-04-01}
13
+ s.description = %q{Chinese dictionary using the CEDICT word list}
11
14
  s.email = %q{bastien.vaucher@gmail.com}
12
- s.extra_rdoc_files = ["README.mkd", "lib/cedict_ts.u8", "lib/zidian.rb"]
13
- s.files = ["README.mkd", "Rakefile", "lib/cedict_ts.u8", "lib/zidian.rb", "Manifest", "zidian.gemspec"]
15
+ s.extra_rdoc_files = [
16
+ "README.mkd"
17
+ ]
18
+ s.files = [
19
+ "Manifest",
20
+ "README.mkd",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "doc/files/README_mkd.html",
24
+ "doc/files/lib/cedict_ts_u8.html",
25
+ "doc/rdoc-style.css",
26
+ "lib/cedict_ts.u8",
27
+ "lib/zidian.rb",
28
+ "test/test_zidian.rb",
29
+ "zidian.gemspec"
30
+ ]
14
31
  s.homepage = %q{http://github.com/bastien/zidian}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Zidian", "--main", "README.mkd"]
32
+ s.rdoc_options = ["--charset=UTF-8"]
16
33
  s.require_paths = ["lib"]
17
- s.rubyforge_project = %q{zidian}
18
- s.rubygems_version = %q{1.3.5}
34
+ s.rubygems_version = %q{1.3.6}
19
35
  s.summary = %q{Chinese dictionary}
36
+ s.test_files = [
37
+ "test/test_zidian.rb"
38
+ ]
20
39
 
21
40
  if s.respond_to? :specification_version then
22
41
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -28,3 +47,4 @@ Gem::Specification.new do |s|
28
47
  else
29
48
  end
30
49
  end
50
+
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zidian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Bastien Vaucher
@@ -9,11 +14,11 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-31 00:00:00 +02:00
17
+ date: 2010-04-01 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
16
- description: Chinese dictionary
21
+ description: Chinese dictionary using the CEDICT word list
17
22
  email: bastien.vaucher@gmail.com
18
23
  executables: []
19
24
 
@@ -21,14 +26,17 @@ extensions: []
21
26
 
22
27
  extra_rdoc_files:
23
28
  - README.mkd
24
- - lib/cedict_ts.u8
25
- - lib/zidian.rb
26
29
  files:
30
+ - Manifest
27
31
  - README.mkd
28
32
  - Rakefile
33
+ - VERSION
34
+ - doc/files/README_mkd.html
35
+ - doc/files/lib/cedict_ts_u8.html
36
+ - doc/rdoc-style.css
29
37
  - lib/cedict_ts.u8
30
38
  - lib/zidian.rb
31
- - Manifest
39
+ - test/test_zidian.rb
32
40
  - zidian.gemspec
33
41
  has_rdoc: true
34
42
  homepage: http://github.com/bastien/zidian
@@ -36,32 +44,29 @@ licenses: []
36
44
 
37
45
  post_install_message:
38
46
  rdoc_options:
39
- - --line-numbers
40
- - --inline-source
41
- - --title
42
- - Zidian
43
- - --main
44
- - README.mkd
47
+ - --charset=UTF-8
45
48
  require_paths:
46
49
  - lib
47
50
  required_ruby_version: !ruby/object:Gem::Requirement
48
51
  requirements:
49
52
  - - ">="
50
53
  - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
51
56
  version: "0"
52
- version:
53
57
  required_rubygems_version: !ruby/object:Gem::Requirement
54
58
  requirements:
55
59
  - - ">="
56
60
  - !ruby/object:Gem::Version
57
- version: "1.2"
58
- version:
61
+ segments:
62
+ - 0
63
+ version: "0"
59
64
  requirements: []
60
65
 
61
- rubyforge_project: zidian
62
- rubygems_version: 1.3.5
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.6
63
68
  signing_key:
64
69
  specification_version: 3
65
70
  summary: Chinese dictionary
66
- test_files: []
67
-
71
+ test_files:
72
+ - test/test_zidian.rb