encoda 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +19 -18
- data/VERSION +1 -1
- data/encoda.gemspec +1 -1
- data/lib/encoda.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -4,48 +4,49 @@ This is a simple file encoding converter
|
|
4
4
|
|
5
5
|
== Installation
|
6
6
|
|
7
|
-
sudo gem install
|
7
|
+
sudo gem install encoda
|
8
8
|
|
9
9
|
== Getting Started
|
10
10
|
|
11
|
+
|
11
12
|
==== Single file conversion
|
12
13
|
|
13
14
|
Encoda.convert do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
to_path 'convert/to/path'
|
16
|
+
from_file 'path/to/your/file'
|
17
|
+
from_encoding 'GB2312'
|
18
|
+
to_encoding 'UTF8'
|
18
19
|
end
|
19
20
|
|
20
21
|
==== Multiple files conversion
|
21
22
|
|
22
|
-
You can batch convert multiple files from a specific directory by specifying from_path
|
23
|
+
You can batch convert multiple files from a specific directory by specifying the from_path option
|
23
24
|
|
24
25
|
Encoda.convert do
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
from_path /from/path
|
27
|
+
to_path /to/path
|
28
|
+
to_encoding 'UTF8'
|
28
29
|
end
|
29
30
|
|
30
|
-
If you specify from_path, it will alway do the batch conversion and ignore the
|
31
|
+
If you specify from_path, it will alway do the batch conversion and ignore the from_file option.
|
31
32
|
|
32
33
|
As you can see, if you omit the from_encoding option, the Encoda will try to guess the file's original encoding.
|
33
34
|
The guessing feature is based on chardet library.
|
34
35
|
|
35
36
|
==== Retrieve the conversion result
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
encoda = Encoda.convert do
|
39
|
+
from_path /from/path
|
40
|
+
to_path /to/path
|
41
|
+
to_encoding 'UTF8'
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
puts encoda.failed #=> ['failed_file1.txt', 'failed_file2.txt']
|
45
|
+
puts encoda.success #=> ['success_file1.txt', 'success_file3.txt, file4.srt']
|
45
46
|
|
46
47
|
== TODOs
|
47
48
|
|
48
|
-
Refactoring!!!
|
49
|
+
Add more test and Refactoring!!!
|
49
50
|
|
50
51
|
== Note on Patches/Pull Requests
|
51
52
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/encoda.gemspec
CHANGED
data/lib/encoda.rb
CHANGED