omu-support 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +0 -0
- data/LICENSE.md +674 -0
- data/Rakefile +16 -0
- data/lib/omu-support.rb +3 -0
- data/lib/omu_support.rb +13 -0
- data/lib/omu_support/core_ext.rb +9 -0
- data/lib/omu_support/core_ext/array.rb +13 -0
- data/lib/omu_support/core_ext/class.rb +27 -0
- data/lib/omu_support/core_ext/hash.rb +21 -0
- data/lib/omu_support/core_ext/integer.rb +7 -0
- data/lib/omu_support/core_ext/object.rb +90 -0
- data/lib/omu_support/core_ext/securerandom.rb +11 -0
- data/lib/omu_support/core_ext/string.rb +126 -0
- data/lib/omu_support/data/en.yml +1266 -0
- data/lib/omu_support/data/tr.yml +931 -0
- data/lib/omu_support/minitest.rb +6 -0
- data/lib/omu_support/minitest/association_helper.rb +48 -0
- data/lib/omu_support/minitest/callback_helper.rb +42 -0
- data/lib/omu_support/minitest/enumeration_helper.rb +21 -0
- data/lib/omu_support/minitest/validation_helper.rb +94 -0
- data/lib/omu_support/rest_client.rb +114 -0
- data/lib/omu_support/sensitive.rb +54 -0
- data/lib/omu_support/version.rb +7 -0
- data/test/core_ext/array_test.rb +14 -0
- data/test/core_ext/class_test.rb +63 -0
- data/test/core_ext/hash_test.rb +28 -0
- data/test/core_ext/integer_test.rb +9 -0
- data/test/core_ext/object_test.rb +20 -0
- data/test/core_ext/securerandom_test.rb +10 -0
- data/test/core_ext/string_test.rb +39 -0
- data/test/support_test.rb +9 -0
- data/test/test_helper.rb +7 -0
- metadata +103 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
class HashTest < ActiveSupport::TestCase
|
8
|
+
test 'to_deep_ostruct works' do
|
9
|
+
hash = {
|
10
|
+
first_level: {
|
11
|
+
second_level: {
|
12
|
+
second: 2
|
13
|
+
},
|
14
|
+
first: 1
|
15
|
+
},
|
16
|
+
top: 0
|
17
|
+
}
|
18
|
+
|
19
|
+
ostruct = hash.to_deep_ostruct
|
20
|
+
|
21
|
+
assert ostruct.is_a? OpenStruct
|
22
|
+
assert_equal 0, ostruct.top
|
23
|
+
assert ostruct.first_level.is_a? OpenStruct
|
24
|
+
assert_equal 1, ostruct.first_level.first
|
25
|
+
assert ostruct.first_level.second_level.is_a? OpenStruct
|
26
|
+
assert_equal 2, ostruct.first_level.second_level.second
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class ObjectTest < ActiveSupport::TestCase
|
6
|
+
test 'must_be_any_of! works' do
|
7
|
+
assert_equal 13, 13.must_be_any_of!(String, Integer)
|
8
|
+
assert_equal '13', '13'.must_be_any_of!(Integer, String)
|
9
|
+
|
10
|
+
assert_raise(TypeError) { 13.must_be_any_of!(Symbol, String) }
|
11
|
+
|
12
|
+
assert_equal [13, 19], [13, 19].must_be_any_of!([Integer])
|
13
|
+
assert_equal({ x: 13, y: 19 }, { x: 13, y: 19 }.must_be_any_of!(Symbol => Integer))
|
14
|
+
|
15
|
+
assert_raise(TypeError) { 13.must_be_any_of!([Integer]) }
|
16
|
+
assert_raise(TypeError) { [13, '19'].must_be_any_of!([Integer]) }
|
17
|
+
assert_raise(TypeError) { 13.must_be_any_of!(Symbol => Integer) }
|
18
|
+
assert_raise(TypeError) { { x: 13, y: '19' }.must_be_any_of!(Symbol => Integer) }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class SecureRandomTest < ActiveSupport::TestCase
|
6
|
+
test 'random_number_string works' do
|
7
|
+
assert_match(/^\d{4}$/, SecureRandom.random_number_string(4))
|
8
|
+
assert_match(/^[0-9ABCDEF]{4}$/, SecureRandom.random_number_string(4, 16))
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class StringTest < ActiveSupport::TestCase
|
6
|
+
test 'capitalize_turkish method can capitalize words in Turkish' do
|
7
|
+
word = 'ışık ılık süt iç'
|
8
|
+
assert_equal 'Işık Ilık Süt İç', word.capitalize_turkish
|
9
|
+
end
|
10
|
+
|
11
|
+
test 'abbreviation method can generate abbreviations for words in Turkish' do
|
12
|
+
word = 'istanbul ışık üniversitesi'
|
13
|
+
assert_equal 'İIÜ', word.abbreviation
|
14
|
+
end
|
15
|
+
|
16
|
+
test 'affixed works' do
|
17
|
+
assert_equal 'aaa.foo bar baz quux_zzz', 'foo bar baz quux'.affixed(prefix: 'aaa.', interfix: '-', suffix: '_zzz')
|
18
|
+
end
|
19
|
+
|
20
|
+
test 'inside_offensives? works' do
|
21
|
+
assert 'salak'.inside_offensives?
|
22
|
+
assert 'manyak'.inside_offensives?
|
23
|
+
end
|
24
|
+
|
25
|
+
test 'inside_reserved? works' do
|
26
|
+
assert 'while'.inside_reserved?
|
27
|
+
assert 'end'.inside_reserved?
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'inside_abbreviations? works' do
|
31
|
+
assert 'yök'.inside_abbreviations?
|
32
|
+
assert 'kktc'.inside_abbreviations?
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'inside_conjunctions? works' do
|
36
|
+
assert 've'.inside_conjunctions?
|
37
|
+
assert 'veya'.inside_conjunctions?
|
38
|
+
end
|
39
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omu-support
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- OMU BAUM Crew
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 6.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 6.0.0
|
27
|
+
description: ActiveSupport like generic support libraries for OMU ecosystem.
|
28
|
+
email:
|
29
|
+
- irfan.isubas@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- CHANGELOG.md
|
35
|
+
- LICENSE.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/omu-support.rb
|
38
|
+
- lib/omu_support.rb
|
39
|
+
- lib/omu_support/core_ext.rb
|
40
|
+
- lib/omu_support/core_ext/array.rb
|
41
|
+
- lib/omu_support/core_ext/class.rb
|
42
|
+
- lib/omu_support/core_ext/hash.rb
|
43
|
+
- lib/omu_support/core_ext/integer.rb
|
44
|
+
- lib/omu_support/core_ext/object.rb
|
45
|
+
- lib/omu_support/core_ext/securerandom.rb
|
46
|
+
- lib/omu_support/core_ext/string.rb
|
47
|
+
- lib/omu_support/data/en.yml
|
48
|
+
- lib/omu_support/data/tr.yml
|
49
|
+
- lib/omu_support/minitest.rb
|
50
|
+
- lib/omu_support/minitest/association_helper.rb
|
51
|
+
- lib/omu_support/minitest/callback_helper.rb
|
52
|
+
- lib/omu_support/minitest/enumeration_helper.rb
|
53
|
+
- lib/omu_support/minitest/validation_helper.rb
|
54
|
+
- lib/omu_support/rest_client.rb
|
55
|
+
- lib/omu_support/sensitive.rb
|
56
|
+
- lib/omu_support/version.rb
|
57
|
+
- test/core_ext/array_test.rb
|
58
|
+
- test/core_ext/class_test.rb
|
59
|
+
- test/core_ext/hash_test.rb
|
60
|
+
- test/core_ext/integer_test.rb
|
61
|
+
- test/core_ext/object_test.rb
|
62
|
+
- test/core_ext/securerandom_test.rb
|
63
|
+
- test/core_ext/string_test.rb
|
64
|
+
- test/support_test.rb
|
65
|
+
- test/test_helper.rb
|
66
|
+
homepage: https://omu.sh
|
67
|
+
licenses:
|
68
|
+
- GPL-3.0
|
69
|
+
metadata:
|
70
|
+
homepage_uri: https://omu.sh
|
71
|
+
bug_tracker_uri: https://github.com/omu/joker/issues
|
72
|
+
changelog_uri: https://github.com/omu/joker/blob/main/CHANGELOG.md
|
73
|
+
source_code_uri: https://github.com/omu/joker/tree/main/support
|
74
|
+
github_repo: ssh://github.com/omu/joker
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 2.5.0
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubygems_version: 3.2.0
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: ActiveSupport like toolkit of support libraries.
|
94
|
+
test_files:
|
95
|
+
- test/core_ext/array_test.rb
|
96
|
+
- test/core_ext/securerandom_test.rb
|
97
|
+
- test/core_ext/object_test.rb
|
98
|
+
- test/core_ext/hash_test.rb
|
99
|
+
- test/core_ext/string_test.rb
|
100
|
+
- test/core_ext/class_test.rb
|
101
|
+
- test/core_ext/integer_test.rb
|
102
|
+
- test/support_test.rb
|
103
|
+
- test/test_helper.rb
|