tbpgr_utils 0.0.119 → 0.0.120

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
2
  SHA1:
3
- metadata.gz: 301f70598d82e95a8d3c8c12fd5124fe0d9c727e
4
- data.tar.gz: bbf1d3e429d5fa77d3ecf7daa614fcfc49867fa5
3
+ metadata.gz: e1b70999803bbab64b871782e8db0234e4a2bdb0
4
+ data.tar.gz: 9caf56eb84d02338a121dd04d846d24cb0cf097d
5
5
  SHA512:
6
- metadata.gz: 19c3395812d4b548758f61808a48af515e6bfb9e1e868656757ff2acaa65c8fa9b18a65db304f45fe683a51504ce3e6c67bbff573addca0fe40eea53dc3bd233
7
- data.tar.gz: 740c179183022572cdc3e981a81b8ceee698edf19dd2d6c545fb481605e142e2d1c31d91d9dcab919c3904615ddc1b4a89d89c261235bc2fb457e89f2c74e000
6
+ metadata.gz: 8f5f7a0730044402893300645e6a500ea0ba950b955f8de9899778665ff6d78238690f15eb49479d8ecf653c7b38d632fe185d2a1e4ab33b8658855e4592f2b8
7
+ data.tar.gz: 5a61fe413bde0ebc771603c17aae78e3289c3d1d1a91982fbc025006df3dd8a33b5e35ce39c1f690edce023bbae97bc2ffc94630b31542714db663affce9ce0f
data/README.md CHANGED
@@ -26,6 +26,7 @@ Or install it yourself as:
26
26
  |:----------- |:------------ |
27
27
  |[TbpgrUtils Array#>>](#array) |alias of map(&:method_symbol) |
28
28
  |[TbpgrUtils Array#kernel_send](#arraykernel_send) |alias of map {|v|send :some_kernel_method, v} |
29
+ |[TbpgrUtils Array#sum](#arraysum) |alias of Array#reduce(&:+). |
29
30
  |[TbpgrUtils Array#to_table](#arrayto_table) |Array(Array, Array...) to table format. |
30
31
  |[TbpgrUtils Array#to_html_table](#arrayto_html_table) |Array(Array, Array...) to html table format. |
31
32
  |[TbpgrUtils Array#together](#arraytogether) |loop all arrays by block |
@@ -3555,6 +3556,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3555
3556
  https://github.com/tbpgr/tbpgr_utils_snippets
3556
3557
 
3557
3558
  ## History
3559
+ * version 0.0.120 : add Array#sum
3558
3560
  * version 0.0.119 : add Kernel#exchange
3559
3561
  * version 0.0.118 : add String#uniq
3560
3562
  * version 0.0.117 : add Array#kernel_send
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require 'open_classes/array/gte_gte'
3
3
  require 'open_classes/array/kernel_send'
4
+ require 'open_classes/array/sum'
4
5
  require 'open_classes/array/to_html_table'
5
6
  require 'open_classes/array/to_table'
6
7
  require 'open_classes/array/together'
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ # Array
4
+ class Array
5
+ # alias of Array#reduce(&:+)
6
+ #
7
+ # === Example
8
+ #
9
+ # [*1..5].reduce(&:+) # => 15
10
+ # [*'a'..'z'].reduce(&:+) # => 'abcdefghijklmnopqrstuvwxyz'
11
+ #
12
+ def sum
13
+ reduce(&:+)
14
+ end
15
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.119'
5
+ VERSION = '0.0.120'
6
6
  end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'tbpgr_utils'
4
+
5
+ describe Array do
6
+ context :sum do
7
+ cases = [
8
+ {
9
+ case_no: 1,
10
+ case_title: 'numbers case',
11
+ input: [*1..5],
12
+ expected: 15,
13
+ },
14
+ {
15
+ case_no: 2,
16
+ case_title: 'charactors case',
17
+ input: [*'a'..'z'],
18
+ expected: 'abcdefghijklmnopqrstuvwxyz',
19
+ },
20
+ ]
21
+
22
+ cases.each do |c|
23
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
24
+ begin
25
+ case_before c
26
+
27
+ # -- given --
28
+ # nothing
29
+
30
+ # -- when/then --
31
+ actual = c[:input].sum
32
+
33
+ expect(actual).to eq(c[:expected])
34
+ ensure
35
+ case_after c
36
+ end
37
+ end
38
+
39
+ def case_before(c)
40
+ # implement each case before
41
+ end
42
+
43
+ def case_after(c)
44
+ # implement each case after
45
+ end
46
+ end
47
+ end
48
+ 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.119
4
+ version: 0.0.120
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-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -137,6 +137,7 @@ files:
137
137
  - lib/open_classes/array.rb
138
138
  - lib/open_classes/array/gte_gte.rb
139
139
  - lib/open_classes/array/kernel_send.rb
140
+ - lib/open_classes/array/sum.rb
140
141
  - lib/open_classes/array/to_html_table.rb
141
142
  - lib/open_classes/array/to_table.rb
142
143
  - lib/open_classes/array/together.rb
@@ -271,6 +272,7 @@ files:
271
272
  - spec/metasyntactic_variable_spec.rb
272
273
  - spec/open_classes/array/gte_gte_spec.rb
273
274
  - spec/open_classes/array/kernel_send_spec.rb
275
+ - spec/open_classes/array/sum_spec.rb
274
276
  - spec/open_classes/array/to_html_table_spec.rb
275
277
  - spec/open_classes/array/to_table_spec.rb
276
278
  - spec/open_classes/array/together_at_spec.rb
@@ -421,6 +423,7 @@ test_files:
421
423
  - spec/metasyntactic_variable_spec.rb
422
424
  - spec/open_classes/array/gte_gte_spec.rb
423
425
  - spec/open_classes/array/kernel_send_spec.rb
426
+ - spec/open_classes/array/sum_spec.rb
424
427
  - spec/open_classes/array/to_html_table_spec.rb
425
428
  - spec/open_classes/array/to_table_spec.rb
426
429
  - spec/open_classes/array/together_at_spec.rb