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 +5 -5
- data/LICENSE +22 -0
- data/README.md +32 -24
- data/ext/lib/preslovi.x86_64-darwin.h +82 -0
- data/ext/lib/preslovi.x86_64-darwin.so +0 -0
- data/ext/lib/preslovi.x86_64-linux.h +66 -0
- data/ext/lib/preslovi.x86_64-linux.so +0 -0
- data/lib/i18n_config.rb +5 -1
- data/lib/srbovanje.rb +2 -3
- data/lib/srbovanje/preslovi.rb +16 -0
- data/lib/srbovanje/srbovanje.rb +7 -92
- data/lib/srbovanje/string_ext.rb +7 -7
- metadata +32 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 023e6dfb500e0f7c94ad43929c393a79d91d7550fd97c728ded531db871460c7
|
4
|
+
data.tar.gz: 29ac77dd8e111626faed8b6c0f901795f8400499d4397adca2def0dc20c47aaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
17
|
-
|
14
|
+
```ruby
|
15
|
+
>> "Ђурђевак".latinicom
|
16
|
+
=> "Đurđevak"
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
>> "Ђурђевак".latinicom_ascii
|
19
|
+
=> "Djurdjevak"
|
20
|
+
```
|
21
21
|
|
22
22
|
Ako zatreba, tu je i niz sa slovima abecede:
|
23
23
|
|
24
|
-
|
25
|
-
|
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
|
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
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
>> "Шабан Шаулић".parameterize
|
37
|
-
=> ""
|
43
|
+
>> "Karađorđeva šnicla".parameterize
|
44
|
+
=> "karadjordjeva-snicla"
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
=> "karadjordjeva-snicla"
|
46
|
+
>> "Шабан Шаулић".parameterize
|
47
|
+
=> "saban-saulic"
|
48
|
+
```
|
43
49
|
|
44
|
-
|
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
|
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
|
Binary file
|
@@ -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
|
Binary file
|
data/lib/i18n_config.rb
CHANGED
data/lib/srbovanje.rb
CHANGED
@@ -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
|
data/lib/srbovanje/srbovanje.rb
CHANGED
@@ -1,103 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
2
|
module Srbovanje
|
4
3
|
|
5
|
-
|
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
|
10
|
-
|
6
|
+
def latinicom(text)
|
7
|
+
Preslovi.latinicom(text).force_encoding('utf-8').encode
|
11
8
|
end
|
12
9
|
|
13
|
-
def
|
14
|
-
|
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
|
78
|
-
|
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
|
data/lib/srbovanje/string_ext.rb
CHANGED
@@ -3,13 +3,13 @@
|
|
3
3
|
String.class_eval do
|
4
4
|
|
5
5
|
# Preslovljava na latinicu
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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:
|
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:
|
12
|
-
dependencies:
|
13
|
-
|
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
|
-
|
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: []
|