srbovanje 2.0.0 → 3.0.0

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
- SHA1:
3
- metadata.gz: 8585bfc72a559e745f7462a5013b39a895ff3706
4
- data.tar.gz: 5635dad2e00b862cee73aae52dafc5646983a7ba
2
+ SHA256:
3
+ metadata.gz: 023e6dfb500e0f7c94ad43929c393a79d91d7550fd97c728ded531db871460c7
4
+ data.tar.gz: 29ac77dd8e111626faed8b6c0f901795f8400499d4397adca2def0dc20c47aaa
5
5
  SHA512:
6
- metadata.gz: 42f900a613b43bdab1b67906fbb2f70a238376619aa4576502e8369a530611599c9633953cb4461b431fce3b07d9391065d4abfcfac26603875b78d4411c3fbd
7
- data.tar.gz: a9cd31e141d928ec2a1d5e3680b8ec0442e861d001345ad277054c93e072a9049d44daad057c1c081c5cafaec47e608f194a13dbade7b65571652f8be971ae85
6
+ metadata.gz: 9a40d1c0c568e411d1251442806de3906bec5b1eae90b7d99a56921bb4898bdfd98b5977808de323f062b59f0ea8522ad8b194f64f4bb59d16d4670fa03a27bd
7
+ data.tar.gz: e9d4fd5662644a49f50de410fdfa047961c084ad9331facf3ee9d2edf92eca81d0dfdf665d4dab9dfe1724560568620f9c46c0e16b3e3c64317d8c16a04f66e6
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2009 Dejan Simic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  srbovanje
2
2
  =========
3
3
 
4
- Ruby gem za preslovanjavanje ćirilice na latinicu i tzv. "ošišanu" latinicu
5
-
4
+ Ruby gem za preslovanjavanje ćirilice na latinicu i tzv. "ošišanu" (ASCII) latinicu.
6
5
 
7
6
  ## Instaliranje
8
7
 
@@ -10,42 +9,51 @@ U Gemfile projekta dodajte:
10
9
 
11
10
  gem 'srbovanje'
12
11
 
13
-
14
12
  ## Korišćenje
15
13
 
16
- >> "Ђурђевак".latinicom
17
- => "Đurđevak"
14
+ ```ruby
15
+ >> "Ђурђевак".latinicom
16
+ => "Đurđevak"
18
17
 
19
- >> "Ђурђевак".latinicom :ascii
20
- => "DJurdjevak"
18
+ >> "Ђурђевак".latinicom_ascii
19
+ => "Djurdjevak"
20
+ ```
21
21
 
22
22
  Ako zatreba, tu je i niz sa slovima abecede:
23
23
 
24
- >> Srbovanje.abeceda
25
- => ["A", "B", "C", "Č", "Ć", "D", "DŽ", "Đ", "E", "F", "G", "H", "I", "J", "K", "L", "LJ", "M", "N", "NJ", "O", "P", "R", "S", "Š", "T", "U", "V", "Z", "Ž"]
26
-
24
+ ```ruby
25
+ >> Srbovanje.abeceda
26
+ => ["A", "B", "C", "Č", "Ć", "D", "Dž", "Đ", "E", "F", "G", "H", "I", "J", "K", "L", "Lj", "M", "N", "Nj", "O", "P", "R", "S", "Š", "T", "U", "V", "Z", "Ž"]
27
+ ```
27
28
 
28
- Ako koristite Srbovanje uz Rails dobićete setovana pravila za preslovnjavanja
29
+ Ako koristite Srbovanje uz Rails dobićete setovana pravila za preslovljavanja
29
30
  koje koristi i18n gem, tako da će npr. parameterize raditi pravilnije:
30
31
 
31
- ## bez Srbovanja
32
+ ```ruby
33
+ ## bez Srbovanja
34
+
35
+ >> "Karađorđeva šnicla".parameterize
36
+ => "karadordeva-snicla"
37
+
38
+ >> "Шабан Шаулић".parameterize
39
+ => ""
40
+
41
+ ## uz Srbovanje
32
42
 
33
- >> "Karađorđeva šnicla".parameterize
34
- => "karadordeva-snicla"
35
-
36
- >> "Шабан Шаулић".parameterize
37
- => ""
43
+ >> "Karađorđeva šnicla".parameterize
44
+ => "karadjordjeva-snicla"
38
45
 
39
- ## uz Srbovanje
40
-
41
- >> "Karađorđeva šnicla".parameterize
42
- => "karadjordjeva-snicla"
46
+ >> "Шабан Шаулић".parameterize
47
+ => "saban-saulic"
48
+ ```
43
49
 
44
- >> "Шабан Шаулић".parameterize
45
- => "saban-saulic"
50
+ ## Performanse
46
51
 
52
+ Od verzije 3.0, Srbovanje koristi [Go](https://golang.org/) ekstenziju zbog
53
+ dramatično boljih (30x) performansi. Ekstenzija je unapred kompajlirana i
54
+ spakovana uz gem, tako da instaliranje gema nema dodatnih zahteva.
47
55
 
48
- ## MIT Licence
56
+ ## MIT License
49
57
 
50
58
  Copyright (c) 2009 Dejan Simic
51
59
 
@@ -0,0 +1,82 @@
1
+ /* Code generated by cmd/cgo; DO NOT EDIT. */
2
+
3
+ /* package command-line-arguments */
4
+
5
+
6
+ #line 1 "cgo-builtin-export-prolog"
7
+
8
+ #include <stddef.h> /* for ptrdiff_t below */
9
+
10
+ #ifndef GO_CGO_EXPORT_PROLOGUE_H
11
+ #define GO_CGO_EXPORT_PROLOGUE_H
12
+
13
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
14
+ typedef struct { const char *p; ptrdiff_t n; } _GoString_;
15
+ #endif
16
+
17
+ #endif
18
+
19
+ /* Start of preamble from import "C" comments. */
20
+
21
+
22
+ #line 3 "preslovi.go"
23
+
24
+ #include <stdio.h>
25
+ #include <stdlib.h>
26
+
27
+ #line 1 "cgo-generated-wrapper"
28
+
29
+
30
+ /* End of preamble from import "C" comments. */
31
+
32
+
33
+ /* Start of boilerplate cgo prologue. */
34
+ #line 1 "cgo-gcc-export-header-prolog"
35
+
36
+ #ifndef GO_CGO_PROLOGUE_H
37
+ #define GO_CGO_PROLOGUE_H
38
+
39
+ typedef signed char GoInt8;
40
+ typedef unsigned char GoUint8;
41
+ typedef short GoInt16;
42
+ typedef unsigned short GoUint16;
43
+ typedef int GoInt32;
44
+ typedef unsigned int GoUint32;
45
+ typedef long long GoInt64;
46
+ typedef unsigned long long GoUint64;
47
+ typedef GoInt64 GoInt;
48
+ typedef GoUint64 GoUint;
49
+ typedef __SIZE_TYPE__ GoUintptr;
50
+ typedef float GoFloat32;
51
+ typedef double GoFloat64;
52
+ typedef float _Complex GoComplex64;
53
+ typedef double _Complex GoComplex128;
54
+
55
+ /*
56
+ static assertion to make sure the file is being used on architecture
57
+ at least with matching size of GoInt.
58
+ */
59
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
60
+
61
+ #ifndef GO_CGO_GOSTRING_TYPEDEF
62
+ typedef _GoString_ GoString;
63
+ #endif
64
+ typedef void *GoMap;
65
+ typedef void *GoChan;
66
+ typedef struct { void *t; void *v; } GoInterface;
67
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
68
+
69
+ #endif
70
+
71
+ /* End of boilerplate cgo prologue. */
72
+
73
+ #ifdef __cplusplus
74
+ extern "C" {
75
+ #endif
76
+
77
+ extern char* latinicom(char* s);
78
+ extern char* latinicom_ascii(char* s);
79
+
80
+ #ifdef __cplusplus
81
+ }
82
+ #endif
@@ -0,0 +1,66 @@
1
+ /* Created by "go tool cgo" - DO NOT EDIT. */
2
+
3
+ /* package command-line-arguments */
4
+
5
+ /* Start of preamble from import "C" comments. */
6
+
7
+
8
+ #line 3 "/home/airninja/tmp/srbovanje/ext/preslovi.go"
9
+
10
+ #include <stdio.h>
11
+ #include <stdlib.h>
12
+
13
+
14
+
15
+ /* End of preamble from import "C" comments. */
16
+
17
+
18
+ /* Start of boilerplate cgo prologue. */
19
+
20
+ #ifndef GO_CGO_PROLOGUE_H
21
+ #define GO_CGO_PROLOGUE_H
22
+
23
+ typedef signed char GoInt8;
24
+ typedef unsigned char GoUint8;
25
+ typedef short GoInt16;
26
+ typedef unsigned short GoUint16;
27
+ typedef int GoInt32;
28
+ typedef unsigned int GoUint32;
29
+ typedef long long GoInt64;
30
+ typedef unsigned long long GoUint64;
31
+ typedef GoInt64 GoInt;
32
+ typedef GoUint64 GoUint;
33
+ typedef __SIZE_TYPE__ GoUintptr;
34
+ typedef float GoFloat32;
35
+ typedef double GoFloat64;
36
+ typedef float _Complex GoComplex64;
37
+ typedef double _Complex GoComplex128;
38
+
39
+ /*
40
+ static assertion to make sure the file is being used on architecture
41
+ at least with matching size of GoInt.
42
+ */
43
+ typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
44
+
45
+ typedef struct { const char *p; GoInt n; } GoString;
46
+ typedef void *GoMap;
47
+ typedef void *GoChan;
48
+ typedef struct { void *t; void *v; } GoInterface;
49
+ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
50
+
51
+ #endif
52
+
53
+ /* End of boilerplate cgo prologue. */
54
+
55
+ #ifdef __cplusplus
56
+ extern "C" {
57
+ #endif
58
+
59
+
60
+ extern char* latinicom(char* p0);
61
+
62
+ extern char* latinicom_ascii(char* p0);
63
+
64
+ #ifdef __cplusplus
65
+ }
66
+ #endif
@@ -1 +1,5 @@
1
- I18n.backend.store_translations(:sr, :i18n => {:transliterate => {:rule => Srbovanje::latinica_map(:ascii) }})
1
+ I18n.backend.store_translations(:sr, i18n: {
2
+ transliterate: {
3
+ rule: ->(string) { Srbovanje.latinicom_ascii(string) }
4
+ }
5
+ })
@@ -1,14 +1,13 @@
1
1
  # encoding: utf-8
2
2
 
3
- $KCODE = 'UTF8' if RUBY_VERSION.to_f < 1.9
4
-
5
3
  require 'srbovanje/srbovanje'
4
+ require 'srbovanje/preslovi'
6
5
  require 'srbovanje/string_ext'
7
6
 
8
7
  if defined?(Rails)
9
8
  require 'srbovanje/railtie'
10
9
  elsif defined?(I18n)
11
- require 'i18n_config'
10
+ require 'i18n_config'
12
11
  end
13
12
 
14
13
  module Srbovanje
@@ -0,0 +1,16 @@
1
+ # encoding: utf-8
2
+
3
+ require 'ffi'
4
+
5
+ module Preslovi
6
+ extend FFI::Library
7
+
8
+ PLATFORM = "#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}"
9
+
10
+ ffi_lib "#{__dir__}/../../ext/lib/preslovi.#{PLATFORM}.so"
11
+
12
+ attach_function :latinicom, [:string], :string
13
+ attach_function :latinicom_ascii, [:string], :string
14
+
15
+ extend self
16
+ end
@@ -1,103 +1,18 @@
1
1
  # encoding: utf-8
2
-
3
2
  module Srbovanje
4
3
 
5
- def abeceda
6
- %w(A B C Č Ć D DŽ Đ E F G H I J K L LJ M N NJ O P R S Š T U V Z Ž)
7
- end
4
+ ABECEDA = %w(A B C Č Ć D Dž Đ E F G H I J K L Lj M N Nj O P R S Š T U V Z Ž)
8
5
 
9
- def latinica_map(charset)
10
- charset.to_s == 'ascii' ? latinica_ascii_map : latinica_full_map
6
+ def latinicom(text)
7
+ Preslovi.latinicom(text).force_encoding('utf-8').encode
11
8
  end
12
9
 
13
- def latinica_full_map
14
- @@latinica_map ||= {
15
- 'а' => 'a',
16
- 'А' => 'A',
17
- 'б' => 'b',
18
- 'Б' => 'B',
19
- 'в' => 'v',
20
- 'В' => 'V',
21
- 'г' => 'g',
22
- 'Г' => 'G',
23
- 'д' => 'd',
24
- 'Д' => 'D',
25
- 'ђ' => 'đ',
26
- 'Ђ' => 'Đ',
27
- 'е' => 'e',
28
- 'Е' => 'E',
29
- 'ж' => 'ž',
30
- 'Ж' => 'Ž',
31
- 'з' => 'z',
32
- 'З' => 'Z',
33
- 'и' => 'i',
34
- 'И' => 'I',
35
- 'ј' => 'j',
36
- 'Ј' => 'J',
37
- 'к' => 'k',
38
- 'К' => 'K',
39
- 'л' => 'l',
40
- 'Л' => 'L',
41
- 'љ' => 'lj',
42
- 'Љ' => 'LJ',
43
- 'м' => 'm',
44
- 'М' => 'M',
45
- 'н' => 'n',
46
- 'Н' => 'N',
47
- 'њ' => 'nj',
48
- 'Њ' => 'NJ',
49
- 'о' => 'o',
50
- 'О' => 'O',
51
- 'п' => 'p',
52
- 'П' => 'P',
53
- 'р' => 'r',
54
- 'Р' => 'R',
55
- 'с' => 's',
56
- 'С' => 'S',
57
- 'т' => 't',
58
- 'Т' => 'T',
59
- 'ћ' => 'ć',
60
- 'Ћ' => 'Ć',
61
- 'ц' => 'c',
62
- 'Ц' => 'C',
63
- 'у' => 'u',
64
- 'У' => 'U',
65
- 'ф' => 'f',
66
- 'Ф' => 'F',
67
- 'х' => 'h',
68
- 'Х' => 'H',
69
- 'ч' => 'č',
70
- 'Ч' => 'Č',
71
- 'џ' => 'dž',
72
- 'Џ' => 'DŽ',
73
- 'ш' => 'š',
74
- 'Ш' => 'Š' }
10
+ def latinicom_ascii(text)
11
+ Preslovi.latinicom_ascii(text).force_encoding('utf-8').encode
75
12
  end
76
13
 
77
- def latinica_ascii_map
78
- @@latinica_ascii_map ||= latinica_full_map.merge(
79
- 'ћ' => 'c',
80
- 'ć' => 'c',
81
- 'ч' => 'c',
82
- 'č' => 'c',
83
- 'Ћ' => 'C',
84
- 'Ć' => 'C',
85
- 'Ч' => 'C',
86
- 'Č' => 'C',
87
- 'ж' => 'z',
88
- 'ž' => 'z',
89
- 'Ж' => 'Z',
90
- 'Ž' => 'Z',
91
- 'š' => 's',
92
- 'ш' => 's',
93
- 'Ш' => 'S',
94
- 'Š' => 'S',
95
- 'đ' => 'dj',
96
- 'ђ' => 'dj',
97
- 'Ђ' => 'DJ',
98
- 'Đ' => 'DJ',
99
- 'џ' => 'dz',
100
- 'Џ' => 'DZ')
14
+ def abeceda
15
+ ABECEDA
101
16
  end
102
17
 
103
18
  extend self
@@ -3,13 +3,13 @@
3
3
  String.class_eval do
4
4
 
5
5
  # Preslovljava na latinicu
6
- # Params:
7
- # +charset+:: ako je :ascii preslovljava u "ošišanu" latinicu.
8
- def latinicom(charset=:utf8)
9
- mapping = Srbovanje.latinica_map(charset)
10
- self.gsub(/.+?/) do |chr|
11
- mapping[chr] || chr
12
- end
6
+ def latinicom
7
+ Srbovanje.latinicom(self)
8
+ end
9
+
10
+ # Preslovljava na ASCII ("ošišanu") latinicu
11
+ def latinicom_ascii
12
+ Srbovanje.latinicom_ascii(self)
13
13
  end
14
14
 
15
15
  end
metadata CHANGED
@@ -1,25 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: srbovanje
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dejan Simic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
12
- dependencies: []
13
- description: '"Ђурђевак".latinicom #=> "Đurđevak"'
11
+ date: 2020-08-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.13.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.13'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.13.1
33
+ description: Transliteracija ćirilice na latinicu i tzv. "ošišanu" (ASCII) latinicu.
14
34
  email: desimic@gmail.com
15
35
  executables: []
16
36
  extensions: []
17
37
  extra_rdoc_files: []
18
38
  files:
19
39
  - CHANGELOG.md
40
+ - LICENSE
20
41
  - README.md
42
+ - ext/lib/preslovi.x86_64-darwin.h
43
+ - ext/lib/preslovi.x86_64-darwin.so
44
+ - ext/lib/preslovi.x86_64-linux.h
45
+ - ext/lib/preslovi.x86_64-linux.so
21
46
  - lib/i18n_config.rb
22
47
  - lib/srbovanje.rb
48
+ - lib/srbovanje/preslovi.rb
23
49
  - lib/srbovanje/railtie.rb
24
50
  - lib/srbovanje/srbovanje.rb
25
51
  - lib/srbovanje/string_ext.rb
@@ -42,9 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
68
  - !ruby/object:Gem::Version
43
69
  version: '0'
44
70
  requirements: []
45
- rubyforge_project:
46
- rubygems_version: 2.2.2
71
+ rubygems_version: 3.1.2
47
72
  signing_key:
48
73
  specification_version: 4
49
- summary: Transliteracija ćirilice na latinicu i tzv. ASCII latinicu.
74
+ summary: Transliteracija ćirilice na latinicu i tzv. "ošišanu" (ASCII) latinicu.
50
75
  test_files: []