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 CHANGED
@@ -1,6 +1,6 @@
1
1
  ### wtf_lang
2
2
 
3
- Can't stop dreaming about an easy language detector? Just use wtf_language!
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 #=> "ENGLISH"
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 |lang, code|
23
+ WtfLang::LANGUAGES.each do |full_lang_name, code_lang_name|
24
24
  self.class_eval <<-RUBY
25
- def #{code}?
26
- lang == "#{code}"
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
@@ -1,107 +1,107 @@
1
1
  module WtfLang
2
2
  LANGUAGES = {
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'
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
@@ -1,7 +1,7 @@
1
1
  module WtfLang
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -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 "RUSSIAN", "руби такой крутой!".full_lang
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.2.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-07}
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.2.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-07 00:00:00.000000000 +03:00
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: &9682284 !ruby/object:Gem::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: *9682284
25
+ version_requirements: *9746400
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
- requirement: &9681720 !ruby/object:Gem::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: *9681720
36
+ version_requirements: *9745932
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: jeweler
39
- requirement: &9681384 !ruby/object:Gem::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: *9681384
47
+ version_requirements: *9745428
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rcov
50
- requirement: &9681036 !ruby/object:Gem::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: *9681036
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: -607690351
100
+ hash: -1011563727
101
101
  required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  none: false
103
103
  requirements: