wtf_lang 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/wtf_lang/core_ext/extension.rb +6 -3
- data/lib/wtf_lang/languages.rb +103 -103
- data/lib/wtf_lang/version.rb +1 -1
- data/test/test_wtf_lang.rb +5 -1
- data/wtf_lang.gemspec +2 -2
- metadata +11 -11
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### wtf_lang
|
2
2
|
|
3
|
-
Can't stop dreaming about an easy language detector? Just use
|
3
|
+
Can't stop dreaming about an easy language detector? Just use wtf_lang!
|
4
4
|
|
5
5
|
### Install
|
6
6
|
|
@@ -17,12 +17,13 @@ Can't stop dreaming about an easy language detector? Just use wtf_language!
|
|
17
17
|
"ruby is so awesome!".lang_confidence # => ["en", 0.15502742]
|
18
18
|
|
19
19
|
"ruby is so awesome!".en? # => true
|
20
|
+
"ruby is so awesome!".english? # => true
|
20
21
|
|
21
22
|
If you want to cache results to make less requests to google API, use variables
|
22
23
|
|
23
24
|
text = "ruby is so awesome!"
|
24
25
|
text.lang #=> "en"
|
25
|
-
text.full_lang #=> "
|
26
|
+
text.full_lang #=> "english"
|
26
27
|
|
27
28
|
It works with symbols too!
|
28
29
|
|
@@ -20,10 +20,13 @@ module WtfLang
|
|
20
20
|
detect_lang.lang_confidence
|
21
21
|
end
|
22
22
|
|
23
|
-
WtfLang::LANGUAGES.each do |
|
23
|
+
WtfLang::LANGUAGES.each do |full_lang_name, code_lang_name|
|
24
24
|
self.class_eval <<-RUBY
|
25
|
-
def #{
|
26
|
-
lang == "#{
|
25
|
+
def #{code_lang_name}?
|
26
|
+
lang == "#{code_lang_name}"
|
27
|
+
end
|
28
|
+
def #{full_lang_name}?
|
29
|
+
full_lang == "#{full_lang_name}"
|
27
30
|
end
|
28
31
|
RUBY
|
29
32
|
end
|
data/lib/wtf_lang/languages.rb
CHANGED
@@ -1,107 +1,107 @@
|
|
1
1
|
module WtfLang
|
2
2
|
LANGUAGES = {
|
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-
'
|
3
|
+
'afrikaans' => 'af',
|
4
|
+
'albanian' => 'sq',
|
5
|
+
'amharic' => 'am',
|
6
|
+
'arabic' => 'ar',
|
7
|
+
'armenian' => 'hy',
|
8
|
+
'azerbaijani' => 'az',
|
9
|
+
'basque' => 'eu',
|
10
|
+
'belarusian' => 'be',
|
11
|
+
'bengali' => 'bn',
|
12
|
+
'bihari' => 'bh',
|
13
|
+
'breton' => 'br',
|
14
|
+
'bulgarian' => 'bg',
|
15
|
+
'burmese' => 'my',
|
16
|
+
'catalan' => 'ca',
|
17
|
+
'cherokee' => 'chr',
|
18
|
+
'chinese' => 'zh',
|
19
|
+
'corsican' => 'co',
|
20
|
+
'croatian' => 'hr',
|
21
|
+
'czech' => 'cs',
|
22
|
+
'danish' => 'da',
|
23
|
+
'dhivehi' => 'dv',
|
24
|
+
'dutch'=> 'nl',
|
25
|
+
'english' => 'en',
|
26
|
+
'esperanto' => 'eo',
|
27
|
+
'estonian' => 'et',
|
28
|
+
'faroese' => 'fo',
|
29
|
+
'filipino' => 'tl',
|
30
|
+
'finnish' => 'fi',
|
31
|
+
'french' => 'fr',
|
32
|
+
'frisian' => 'fy',
|
33
|
+
'galician' => 'gl',
|
34
|
+
'georgian' => 'ka',
|
35
|
+
'german' => 'de',
|
36
|
+
'greek' => 'el',
|
37
|
+
'gujarati' => 'gu',
|
38
|
+
'haitian_creole' => 'ht',
|
39
|
+
'hebrew' => 'iw',
|
40
|
+
'hindi' => 'hi',
|
41
|
+
'hungarian' => 'hu',
|
42
|
+
'icelandic' => 'is',
|
43
|
+
'indonesian' => 'id',
|
44
|
+
'inuktitut' => 'iu',
|
45
|
+
'irish' => 'ga',
|
46
|
+
'italian' => 'it',
|
47
|
+
'japanese' => 'ja',
|
48
|
+
'javanese' => 'jw',
|
49
|
+
'kannada' => 'kn',
|
50
|
+
'kazakh' => 'kk',
|
51
|
+
'khmer' => 'km',
|
52
|
+
'korean' => 'ko',
|
53
|
+
'kurdish'=> 'ku',
|
54
|
+
'kyrgyz'=> 'ky',
|
55
|
+
'lao' => 'lo',
|
56
|
+
'latin' => 'la',
|
57
|
+
'latvian' => 'lv',
|
58
|
+
'lithuanian' => 'lt',
|
59
|
+
'luxembourgish' => 'lb',
|
60
|
+
'macedonian' => 'mk',
|
61
|
+
'malay' => 'ms',
|
62
|
+
'malayalam' => 'ml',
|
63
|
+
'maltese' => 'mt',
|
64
|
+
'maori' => 'mi',
|
65
|
+
'marathi' => 'mr',
|
66
|
+
'mongolian' => 'mn',
|
67
|
+
'nepali' => 'ne',
|
68
|
+
'norwegian' => 'no',
|
69
|
+
'occitan' => 'oc',
|
70
|
+
'pashto' => 'ps',
|
71
|
+
'persian' => 'fa',
|
72
|
+
'polish' => 'pl',
|
73
|
+
'portuguese' => 'pt',
|
74
|
+
'punjabi' => 'pa',
|
75
|
+
'quechua' => 'qu',
|
76
|
+
'romanian' => 'ro',
|
77
|
+
'russian' => 'ru',
|
78
|
+
'sanskrit' => 'sa',
|
79
|
+
'scots_gaelic' => 'gd',
|
80
|
+
'serbian' => 'sr',
|
81
|
+
'sindhi' => 'sd',
|
82
|
+
'sinhalese' => 'si',
|
83
|
+
'slovak' => 'sk',
|
84
|
+
'slovenian' => 'sl',
|
85
|
+
'spanish' => 'es',
|
86
|
+
'sundanese' => 'su',
|
87
|
+
'swahili' => 'sw',
|
88
|
+
'swedish' => 'sv',
|
89
|
+
'syriac' => 'syr',
|
90
|
+
'tajik' => 'tg',
|
91
|
+
'tamil' => 'ta',
|
92
|
+
'tatar' => 'tt',
|
93
|
+
'telugu' => 'te',
|
94
|
+
'thai' => 'th',
|
95
|
+
'tibetan' => 'bo',
|
96
|
+
'tonga' => 'to',
|
97
|
+
'turkish' => 'tr',
|
98
|
+
'ukrainian' => 'uk',
|
99
|
+
'urdu' => 'ur',
|
100
|
+
'uzbek' => 'uz',
|
101
|
+
'uighur' => 'ug',
|
102
|
+
'vietnamese' => 'vi',
|
103
|
+
'welsh' => 'cy',
|
104
|
+
'yiddish' => 'yi',
|
105
|
+
'yoruba' => 'yo'
|
106
106
|
}
|
107
107
|
end
|
data/lib/wtf_lang/version.rb
CHANGED
data/test/test_wtf_lang.rb
CHANGED
@@ -16,12 +16,16 @@ class TestWtfLang < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
should "return full language name" do
|
19
|
-
assert_equal "
|
19
|
+
assert_equal "russian", "руби такой крутой!".full_lang
|
20
20
|
end
|
21
21
|
|
22
22
|
should "return assert language" do
|
23
23
|
assert "ruby is so awesome!".en?
|
24
24
|
end
|
25
|
+
|
26
|
+
should "return assert with full language name" do
|
27
|
+
assert "ruby is so awesome!".english?
|
28
|
+
end
|
25
29
|
|
26
30
|
should "return confidence" do
|
27
31
|
assert "руби такой крутой!".lang_confidence.kind_of? Array
|
data/wtf_lang.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wtf_lang}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["nashby"]
|
12
|
-
s.date = %q{2011-05-
|
12
|
+
s.date = %q{2011-05-08}
|
13
13
|
s.description = %q{Can't stop dreaming about an easy language detector? Just use wtf_lang!}
|
14
14
|
s.email = %q{younash@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wtf_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-05-
|
12
|
+
date: 2011-05-08 00:00:00.000000000 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: shoulda
|
17
|
-
requirement: &
|
17
|
+
requirement: &9746400 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *9746400
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
28
|
-
requirement: &
|
28
|
+
requirement: &9745932 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *9745932
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: jeweler
|
39
|
-
requirement: &
|
39
|
+
requirement: &9745428 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.6.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *9745428
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rcov
|
50
|
-
requirement: &
|
50
|
+
requirement: &9744996 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,7 +55,7 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *9744996
|
59
59
|
description: Can't stop dreaming about an easy language detector? Just use wtf_lang!
|
60
60
|
email: younash@gmail.com
|
61
61
|
executables: []
|
@@ -97,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
segments:
|
99
99
|
- 0
|
100
|
-
hash: -
|
100
|
+
hash: -1011563727
|
101
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
102
|
none: false
|
103
103
|
requirements:
|