string_foundation 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -0
  3. data/CODE_OF_CONDUCT.md +75 -0
  4. data/Gemfile +38 -0
  5. data/Gemfile.lock +58 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +324 -0
  8. data/Rakefile +13 -0
  9. data/bin/console +15 -0
  10. data/bin/setup +11 -0
  11. data/circle.yml +14 -0
  12. data/coverage/assets/0.10.0/application.css +799 -0
  13. data/coverage/assets/0.10.0/application.js +1707 -0
  14. data/coverage/assets/0.10.0/colorbox/border.png +0 -0
  15. data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  16. data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  17. data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  18. data/coverage/assets/0.10.0/favicon_green.png +0 -0
  19. data/coverage/assets/0.10.0/favicon_red.png +0 -0
  20. data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  21. data/coverage/assets/0.10.0/loading.gif +0 -0
  22. data/coverage/assets/0.10.0/magnify.png +0 -0
  23. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  24. data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  25. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  26. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  27. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  28. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  29. data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  30. data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  31. data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  32. data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  33. data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  34. data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  35. data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  36. data/coverage/index.html +12508 -0
  37. data/lib/string_foundation/case.rb +102 -0
  38. data/lib/string_foundation/convert.rb +51 -0
  39. data/lib/string_foundation/convertible.rb +40 -0
  40. data/lib/string_foundation/like.rb +24 -0
  41. data/lib/string_foundation/version.rb +7 -0
  42. data/lib/string_foundation/with.rb +26 -0
  43. data/lib/string_foundation.rb +6 -0
  44. data/pkg/string_foundation-1.0.0.gem +0 -0
  45. data/spec/spec_helper.rb +40 -0
  46. data/spec/string_foundation/case_spec.rb +901 -0
  47. data/spec/string_foundation/convert_spec.rb +234 -0
  48. data/spec/string_foundation/convertaile_spec.rb +286 -0
  49. data/spec/string_foundation/like_spec.rb +218 -0
  50. data/spec/string_foundation/version_spec.rb +14 -0
  51. data/spec/string_foundation/with_spec.rb +99 -0
  52. data/spec/support/enhanced_matchers_extension.rb +11 -0
  53. data/string_foundation.gemspec +22 -0
  54. data/string_foundation.png +0 -0
  55. metadata +106 -0
@@ -0,0 +1,218 @@
1
+ # ==============================================================================
2
+ # SPEC - STRING FOUNDATION - LIKE
3
+ # ==============================================================================
4
+ # frozen_string_literal: true
5
+ describe '[ Like Methods ]' do
6
+
7
+ # ----------------------------------------------------------------------------
8
+ # Check Whether A String Is Integer
9
+ # ----------------------------------------------------------------------------
10
+ describe 'CHECK WHETHER A STRING IS INTEGER ::' do
11
+ let(:string) { nil }
12
+ subject { string.like_i? }
13
+
14
+ context 'when a string is an integral number,' do
15
+ context 'and it is a positive number,' do
16
+ let(:string) { '123' }
17
+
18
+ it { is_expected.to eq true }
19
+ end
20
+
21
+ context 'and it is a positive number with a sign,' do
22
+ let(:string) { '+123' }
23
+
24
+ it { is_expected.to eq true }
25
+ end
26
+
27
+ context 'and it is a negative number,' do
28
+ let(:string) { '-5' }
29
+
30
+ it { is_expected.to eq true }
31
+ end
32
+ end
33
+
34
+ context 'when a string is a floating point number,' do
35
+ context 'and it is a positive number,' do
36
+ let(:string) { '0.123' }
37
+
38
+ it { is_expected.to eq false }
39
+ end
40
+
41
+ context 'and it is a positive number with a sign,' do
42
+ let(:string) { '+0.123' }
43
+
44
+ it { is_expected.to eq false }
45
+ end
46
+
47
+ context 'and it is a negative number,' do
48
+ let(:string) { '-5.123' }
49
+
50
+ it { is_expected.to eq false }
51
+ end
52
+ end
53
+
54
+ context 'when a string is a floating point number without an integer,' do
55
+ context 'and it is a positive number,' do
56
+ let(:string) { '.123' }
57
+
58
+ it { is_expected.to eq false }
59
+ end
60
+
61
+ context 'and it is a positive number with a sign,' do
62
+ let(:string) { '+.123' }
63
+
64
+ it { is_expected.to eq false }
65
+ end
66
+
67
+ context 'and it is a negative number,' do
68
+ let(:string) { '-.123' }
69
+
70
+ it { is_expected.to eq false }
71
+ end
72
+ end
73
+
74
+ context 'when a string a number has leading zeros,' do
75
+ context 'and it is a positive number,' do
76
+ let(:string) { '00000123' }
77
+
78
+ it { is_expected.to eq true }
79
+ end
80
+
81
+ context 'and it is a positive number with a sign,' do
82
+ let(:string) { '+00000123' }
83
+
84
+ it { is_expected.to eq true }
85
+ end
86
+
87
+ context 'and it is a negative number,' do
88
+ let(:string) { '-00000123' }
89
+
90
+ it { is_expected.to eq true }
91
+ end
92
+ end
93
+
94
+ context 'when a string is 0,' do
95
+ let(:string) { '0' }
96
+
97
+ it { is_expected.to eq true }
98
+ end
99
+
100
+ context 'when a string is 0.0,' do
101
+ let(:string) { '0.0' }
102
+
103
+ it { is_expected.to eq false }
104
+ end
105
+
106
+ context 'when a string is not a number,' do
107
+ let(:string) { 'abc' }
108
+
109
+ it { is_expected.to eq false }
110
+ end
111
+ end
112
+
113
+ # ----------------------------------------------------------------------------
114
+ # Check Whether A String Is Float
115
+ # ----------------------------------------------------------------------------
116
+ describe 'CHECK WHETHER A STRING IS FLOAT ::' do
117
+ let(:string) { nil }
118
+ subject { string.like_f? }
119
+
120
+ context 'when a string is an integral number,' do
121
+ context 'and it is a positive number,' do
122
+ let(:string) { '123' }
123
+
124
+ it { is_expected.to eq false }
125
+ end
126
+
127
+ context 'and it is a positive number with a sign,' do
128
+ let(:string) { '+123' }
129
+
130
+ it { is_expected.to eq false }
131
+ end
132
+
133
+ context 'and it is a negative number,' do
134
+ let(:string) { '-5' }
135
+
136
+ it { is_expected.to eq false }
137
+ end
138
+ end
139
+
140
+ context 'when a string is a floating point number,' do
141
+ context 'and it is a positive number,' do
142
+ let(:string) { '0.123' }
143
+
144
+ it { is_expected.to eq true }
145
+ end
146
+
147
+ context 'and it is a positive number with a sign,' do
148
+ let(:string) { '+0.123' }
149
+
150
+ it { is_expected.to eq true }
151
+ end
152
+
153
+ context 'and it is a negative number,' do
154
+ let(:string) { '-5.123' }
155
+
156
+ it { is_expected.to eq true }
157
+ end
158
+ end
159
+
160
+ context 'when a string is a floating point number without an integer,' do
161
+ context 'and it is a positive number,' do
162
+ let(:string) { '.123' }
163
+
164
+ it { is_expected.to eq true }
165
+ end
166
+
167
+ context 'and it is a positive number with a sign,' do
168
+ let(:string) { '+.123' }
169
+
170
+ it { is_expected.to eq true }
171
+ end
172
+
173
+ context 'and it is a negative number,' do
174
+ let(:string) { '-.123' }
175
+
176
+ it { is_expected.to eq true }
177
+ end
178
+ end
179
+
180
+ context 'when a string a number has leading zeros,' do
181
+ context 'and it is a positive number,' do
182
+ let(:string) { '00000123' }
183
+
184
+ it { is_expected.to eq false }
185
+ end
186
+
187
+ context 'and it is a positive number with a sign,' do
188
+ let(:string) { '+00000123' }
189
+
190
+ it { is_expected.to eq false }
191
+ end
192
+
193
+ context 'and it is a negative number,' do
194
+ let(:string) { '-00000123' }
195
+
196
+ it { is_expected.to eq false }
197
+ end
198
+ end
199
+
200
+ context 'when a string is 0,' do
201
+ let(:string) { '0' }
202
+
203
+ it { is_expected.to eq false }
204
+ end
205
+
206
+ context 'when a string is 0.0,' do
207
+ let(:string) { '0.0' }
208
+
209
+ it { is_expected.to eq true }
210
+ end
211
+
212
+ context 'when a string is not a number,' do
213
+ let(:string) { 'abc' }
214
+
215
+ it { is_expected.to eq false }
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,14 @@
1
+ # ==============================================================================
2
+ # SPEC - STRING FOUNDATION - VERSION
3
+ # ==============================================================================
4
+ # frozen_string_literal: true
5
+ describe StringFoundation::VERSION do
6
+
7
+ # ----------------------------------------------------------------------------
8
+ # Version Definition
9
+ # ----------------------------------------------------------------------------
10
+ it 'should have a version number' do
11
+ expect(StringFoundation::VERSION).not_to be nil
12
+ end
13
+
14
+ end
@@ -0,0 +1,99 @@
1
+ # ==============================================================================
2
+ # SPEC - STRING FOUNDATION - VERSION
3
+ # ==============================================================================
4
+ # frozen_string_literal: true
5
+ describe '[ With Methods ]' do
6
+
7
+ # ----------------------------------------------------------------------------
8
+ # Without Leading Zeros
9
+ # ----------------------------------------------------------------------------
10
+ describe 'WITHOUT LEADING ZEROS ::' do
11
+ let(:string_number) { nil }
12
+ subject { string_number.without_leading_zeros }
13
+
14
+ context 'when a string has leading zeros,' do
15
+ context 'without a plus or minus sign,' do
16
+ let(:string_number) { '0000123' }
17
+
18
+ it { is_expected.to eq '123' }
19
+ end
20
+
21
+ context 'with a minus sign,' do
22
+ let(:string_number) { '-0000123' }
23
+
24
+ it { is_expected.to eq '-123' }
25
+ end
26
+ end
27
+
28
+ context 'when a string has some zero characters,' do
29
+ context 'without a plus or minus sign,' do
30
+ let(:string_number) { '00001230000' }
31
+
32
+ it { is_expected.to eq '1230000' }
33
+ end
34
+
35
+
36
+ context 'with a minus sign,' do
37
+ let(:string_number) { '-00001230000' }
38
+
39
+ it { is_expected.to eq '-1230000' }
40
+ end
41
+ end
42
+
43
+ context 'when a string like a floating point number has leading zeros,' do
44
+ context 'without a plus or minus sign,' do
45
+ let(:string_number) { '000000.3' }
46
+
47
+ it { is_expected.to eq '0.3' }
48
+ end
49
+
50
+ context 'with a minus sign,' do
51
+ let(:string_number) { '-000000.3' }
52
+
53
+ it { is_expected.to eq '-0.3' }
54
+ end
55
+ end
56
+
57
+ context 'when a string is "0",' do
58
+ context 'without a plus or minus sign,' do
59
+ let(:string_number) { '0' }
60
+
61
+ it { is_expected.to eq '0' }
62
+ end
63
+
64
+ context 'with a minus sign,' do
65
+ let(:string_number) { '-0' }
66
+
67
+ it { is_expected.to eq '0' }
68
+ end
69
+ end
70
+
71
+ context 'when a string has only zero characters,' do
72
+ context 'without a plus or minus sign,' do
73
+ it 'should return a string "0"' do
74
+ expect('00'.without_leading_zeros).to eq '0'
75
+ expect('000'.without_leading_zeros).to eq '0'
76
+ expect('0000'.without_leading_zeros).to eq '0'
77
+ expect('00000'.without_leading_zeros).to eq '0'
78
+ end
79
+ end
80
+
81
+ context 'with a minus sign,' do
82
+ it 'should return a string "0"' do
83
+ expect('-00'.without_leading_zeros).to eq '0'
84
+ expect('-000'.without_leading_zeros).to eq '0'
85
+ expect('-0000'.without_leading_zeros).to eq '0'
86
+ expect('-00000'.without_leading_zeros).to eq '0'
87
+ end
88
+ end
89
+ end
90
+
91
+ context 'when a string does not start with "0" and "-0",' do
92
+ it 'should return the same string' do
93
+ random_text = RandomToken.gen(10, seed: :alphabet).without_leading_zeros
94
+ expect(random_text).to eq random_text
95
+ end
96
+ end
97
+ end
98
+
99
+ end
@@ -0,0 +1,11 @@
1
+ # ==============================================================================
2
+ # SPEC - SUPPORT - ENHANCED MATCHERS EXTENSION
3
+ # ==============================================================================
4
+ module EnhancedMatchersExtension
5
+
6
+ # Call a proc object and be expected.
7
+ def is_expected_as_block
8
+ expect { subject }
9
+ end
10
+
11
+ end
@@ -0,0 +1,22 @@
1
+ # ==============================================================================
2
+ # STRING FOUNDATION GEMSPEC
3
+ # ==============================================================================
4
+ # frozen_string_literal: true
5
+ $:.push File.expand_path("../lib", __FILE__)
6
+ require 'string_foundation/version'
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = 'string_foundation'
10
+ spec.version = StringFoundation::VERSION
11
+ spec.platform = Gem::Platform::RUBY
12
+ spec.authors = ['Brushdown']
13
+ spec.email = ['dev@brushdown.com']
14
+ spec.homepage = 'https://github.com/brushdown/string_foundation.rb'
15
+ spec.summary = 'A library that extends Ruby string class.'
16
+ spec.description = 'String Foundation is a Ruby library that provides useful methods for the Ruby string class.'
17
+ spec.license = 'MIT'
18
+
19
+ spec.files = Dir['**/*'].keep_if { |file| File.file?(file) }
20
+ spec.test_files = Dir['spec/**/*']
21
+ spec.require_paths = ['lib']
22
+ end
Binary file
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string_foundation
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brushdown
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: String Foundation is a Ruby library that provides useful methods for
14
+ the Ruby string class.
15
+ email:
16
+ - dev@brushdown.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - CODE_OF_CONDUCT.md
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - LICENSE.txt
26
+ - README.md
27
+ - Rakefile
28
+ - bin/console
29
+ - bin/setup
30
+ - circle.yml
31
+ - coverage/assets/0.10.0/application.css
32
+ - coverage/assets/0.10.0/application.js
33
+ - coverage/assets/0.10.0/colorbox/border.png
34
+ - coverage/assets/0.10.0/colorbox/controls.png
35
+ - coverage/assets/0.10.0/colorbox/loading.gif
36
+ - coverage/assets/0.10.0/colorbox/loading_background.png
37
+ - coverage/assets/0.10.0/favicon_green.png
38
+ - coverage/assets/0.10.0/favicon_red.png
39
+ - coverage/assets/0.10.0/favicon_yellow.png
40
+ - coverage/assets/0.10.0/loading.gif
41
+ - coverage/assets/0.10.0/magnify.png
42
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png
43
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png
44
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png
45
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png
46
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png
47
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png
48
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png
49
+ - coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png
50
+ - coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png
51
+ - coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png
52
+ - coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png
53
+ - coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png
54
+ - coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png
55
+ - coverage/index.html
56
+ - lib/string_foundation.rb
57
+ - lib/string_foundation/case.rb
58
+ - lib/string_foundation/convert.rb
59
+ - lib/string_foundation/convertible.rb
60
+ - lib/string_foundation/like.rb
61
+ - lib/string_foundation/version.rb
62
+ - lib/string_foundation/with.rb
63
+ - pkg/string_foundation-1.0.0.gem
64
+ - spec/spec_helper.rb
65
+ - spec/string_foundation/case_spec.rb
66
+ - spec/string_foundation/convert_spec.rb
67
+ - spec/string_foundation/convertaile_spec.rb
68
+ - spec/string_foundation/like_spec.rb
69
+ - spec/string_foundation/version_spec.rb
70
+ - spec/string_foundation/with_spec.rb
71
+ - spec/support/enhanced_matchers_extension.rb
72
+ - string_foundation.gemspec
73
+ - string_foundation.png
74
+ homepage: https://github.com/brushdown/string_foundation.rb
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.5.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: A library that extends Ruby string class.
98
+ test_files:
99
+ - spec/spec_helper.rb
100
+ - spec/string_foundation/case_spec.rb
101
+ - spec/string_foundation/convert_spec.rb
102
+ - spec/string_foundation/convertaile_spec.rb
103
+ - spec/string_foundation/like_spec.rb
104
+ - spec/string_foundation/version_spec.rb
105
+ - spec/string_foundation/with_spec.rb
106
+ - spec/support/enhanced_matchers_extension.rb