tbpgr_utils 0.0.125 → 0.0.126
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/lib/open_classes/array/uniq_size.rb +16 -0
- data/lib/open_classes/array.rb +1 -0
- data/lib/tbpgr_utils/version.rb +1 -1
- data/spec/open_classes/array/uniq_size_spec.rb +54 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b0fcf8a3c81962a24a4ea0a5e6e92c2ac19eff1
|
4
|
+
data.tar.gz: f71b640fbba3be074cd181e6cae211d1d79397fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a0d4e6902e2646ecf200770cfe3b81951cec14467931af6caabf1afa7afbc63165cd91630fcb68245a0680adec9b6152c4e52e6283759764079f15617f0787e
|
7
|
+
data.tar.gz: 2af0dfce8a2c49c14f35e671e42245cb7fcda1adb79c106c91829ef9e9efb9f547938133ded1613e3dc53a0a35bd1e9c83192dcfffbd1c83b6ef8ab2a7d2e314
|
data/README.md
CHANGED
@@ -58,6 +58,7 @@ Or install it yourself as:
|
|
58
58
|
|[TbpgrUtils Array#together_shuffle](#arraytogether_shuffleor-tshuffle) |together version of Array#shuffle. together_shuffle has alias :tshuffle |
|
59
59
|
|[TbpgrUtils Array#together_slice](#arraytogether_sliceor-tslice) |together version of Array#slice. together_slice has alias :tslice |
|
60
60
|
|[TbpgrUtils Array#together_with_index](#arraytogether_with_index) |loop all arrays by block with index |
|
61
|
+
|[TbpgrUtils Array#uniq_size](#arrayuniq_size) |return uniq size |
|
61
62
|
|[AttributesHashable.to_hash](#attributeshashableto_hash) |define to_hash method for get instance_values |
|
62
63
|
|[AttributesInitializable::ClassMethods.attr_accessor_init](#attributesinitializableclassmethodsattr_accessor_init) |generate attr_accessor + initializer |
|
63
64
|
|[AttributesInitializable::ClassMethods.attr_reader_init](#attributesinitializableclassmethodsattr_reader_init) |generate attr_reader + initializer |
|
@@ -1068,6 +1069,17 @@ end
|
|
1068
1069
|
|
1069
1070
|
[back to list](#list)
|
1070
1071
|
|
1072
|
+
### Array#uniq_size
|
1073
|
+
~~~ruby
|
1074
|
+
require 'tbpgr_utils'
|
1075
|
+
|
1076
|
+
([*1..6] + [2,3]).uniq_size # => 6
|
1077
|
+
[*1..6].uniq_size # => 6
|
1078
|
+
[].uniq_size # => 0
|
1079
|
+
~~~
|
1080
|
+
|
1081
|
+
[back to list](#list)
|
1082
|
+
|
1071
1083
|
### AttributesHashable.to_hash
|
1072
1084
|
~~~ruby
|
1073
1085
|
require 'attributes_initializable'
|
@@ -3614,6 +3626,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
|
|
3614
3626
|
https://github.com/tbpgr/tbpgr_utils_snippets
|
3615
3627
|
|
3616
3628
|
## History
|
3629
|
+
* version 0.0.126 : add Array#uniq_size
|
3617
3630
|
* version 0.0.125 : add Hash#>>
|
3618
3631
|
* version 0.0.124 : change spec of Array#>>, String#>>
|
3619
3632
|
* version 0.0.123 : add String#>>
|
data/lib/open_classes/array.rb
CHANGED
data/lib/tbpgr_utils/version.rb
CHANGED
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'tbpgr_utils'
|
4
|
+
|
5
|
+
describe Array do
|
6
|
+
context :uniq_size do
|
7
|
+
cases = [
|
8
|
+
{
|
9
|
+
case_no: 1,
|
10
|
+
case_title: 'normal case',
|
11
|
+
input: [*1..6] + [2, 3],
|
12
|
+
expected: 6,
|
13
|
+
},
|
14
|
+
{
|
15
|
+
case_no: 2,
|
16
|
+
case_title: 'not exist duplicate value case',
|
17
|
+
input: [*1..6],
|
18
|
+
expected: 6,
|
19
|
+
},
|
20
|
+
{
|
21
|
+
case_no: 3,
|
22
|
+
case_title: 'empty case',
|
23
|
+
input: [],
|
24
|
+
expected: 0,
|
25
|
+
},
|
26
|
+
]
|
27
|
+
|
28
|
+
cases.each do |c|
|
29
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
30
|
+
begin
|
31
|
+
case_before c
|
32
|
+
|
33
|
+
# -- given --
|
34
|
+
# nothing
|
35
|
+
|
36
|
+
# -- when/then --
|
37
|
+
actual = c[:input].uniq_size
|
38
|
+
|
39
|
+
expect(actual).to eq(c[:expected])
|
40
|
+
ensure
|
41
|
+
case_after c
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def case_before(c)
|
46
|
+
# implement each case before
|
47
|
+
end
|
48
|
+
|
49
|
+
def case_after(c)
|
50
|
+
# implement each case after
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tbpgr_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.126
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- lib/open_classes/array/together_shuffle.rb
|
168
168
|
- lib/open_classes/array/together_slice.rb
|
169
169
|
- lib/open_classes/array/together_with_index.rb
|
170
|
+
- lib/open_classes/array/uniq_size.rb
|
170
171
|
- lib/open_classes/fixnum.rb
|
171
172
|
- lib/open_classes/fixnum/to_fixnum_html_table.rb
|
172
173
|
- lib/open_classes/fixnum/to_fixnum_table.rb
|
@@ -305,6 +306,7 @@ files:
|
|
305
306
|
- spec/open_classes/array/together_slice_spec.rb
|
306
307
|
- spec/open_classes/array/together_spec.rb
|
307
308
|
- spec/open_classes/array/together_with_index_spec.rb
|
309
|
+
- spec/open_classes/array/uniq_size_spec.rb
|
308
310
|
- spec/open_classes/fixnum/to_fixnum_html_table_spec.rb
|
309
311
|
- spec/open_classes/fixnum/to_fixnum_table_spec.rb
|
310
312
|
- spec/open_classes/hash/gte_gte_spec.rb
|
@@ -460,6 +462,7 @@ test_files:
|
|
460
462
|
- spec/open_classes/array/together_slice_spec.rb
|
461
463
|
- spec/open_classes/array/together_spec.rb
|
462
464
|
- spec/open_classes/array/together_with_index_spec.rb
|
465
|
+
- spec/open_classes/array/uniq_size_spec.rb
|
463
466
|
- spec/open_classes/fixnum/to_fixnum_html_table_spec.rb
|
464
467
|
- spec/open_classes/fixnum/to_fixnum_table_spec.rb
|
465
468
|
- spec/open_classes/hash/gte_gte_spec.rb
|