tbpgr_utils 0.0.118 → 0.0.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bdc866278f30602046eacc114095ccf40bf10d95
4
- data.tar.gz: b1035b2b9baae0c6bb163a4e28298f7e3770e26f
3
+ metadata.gz: 301f70598d82e95a8d3c8c12fd5124fe0d9c727e
4
+ data.tar.gz: bbf1d3e429d5fa77d3ecf7daa614fcfc49867fa5
5
5
  SHA512:
6
- metadata.gz: 706a1169f5a97e1d060fc7dadf67664dc4a8fdbb5c24fcb7258d21ec0c03316b943b740eecd95cd9adc2b5119e12deed76f1e75335ef96e1d233c2d595819331
7
- data.tar.gz: a070d66982be48a65f1287f48b264cfe7ee1f05ad4136846b016430f6f5316db9df93f7505a7c480bfd725f519db54c2644a37c140e43bd799562ee18c0720ef
6
+ metadata.gz: 19c3395812d4b548758f61808a48af515e6bfb9e1e868656757ff2acaa65c8fa9b18a65db304f45fe683a51504ce3e6c67bbff573addca0fe40eea53dc3bd233
7
+ data.tar.gz: 740c179183022572cdc3e981a81b8ceee698edf19dd2d6c545fb481605e142e2d1c31d91d9dcab919c3904615ddc1b4a89d89c261235bc2fb457e89f2c74e000
data/README.md CHANGED
@@ -90,8 +90,9 @@ Or install it yourself as:
90
90
  |[TestToolbox Kernel#dp_line](#kerneldp_line) |debug print line for print-debugging |
91
91
  |[TbpgrUtils Kernel#aa_ancestors](#kernelaa_ancestors) |Ascii Art Ancestors |
92
92
  |[TbpgrUtils Kernel#bulk_puts_eval](#kernelbulk_puts_eval) |Puts each-line-code + eval result |
93
- |[TbpgrUtils Kernel#evalb](#kernelevalb) |set attributes from hash |
94
- |[TbpgrUtils Kernel#hash_to_attributes](#kernelhash_to_attributes) |eval block version |
93
+ |[TbpgrUtils Kernel#evalb](#kernelevalb) |eval block version |
94
+ |[TbpgrUtils Kernel#exchange](#kernelexchange) |exchange variable a for b |
95
+ |[TbpgrUtils Kernel#hash_to_attributes](#kernelhash_to_attributes) |set attributes from hash |
95
96
  |[TbpgrUtils Kernel#null](#kernelnull) |null is alias of nil |
96
97
  |[TbpgrUtils Kernel#print_eval](#kernelprint_eval) |Print code + eval result |
97
98
  |[TbpgrUtils Kernel#puts_eval](#kernelputs_eval) |Puts code + eval result |
@@ -1623,6 +1624,17 @@ print actual # => 4
1623
1624
 
1624
1625
  [back to list](#list)
1625
1626
 
1627
+ ### Kernel#exchange
1628
+ ~~~ruby
1629
+ a = 1
1630
+ b = 2
1631
+ a, b = exchange(a, b)
1632
+ a # => 2
1633
+ b # => 1
1634
+ ~~~
1635
+
1636
+ [back to list](#list)
1637
+
1626
1638
  ### Kernel#hash_to_attributes
1627
1639
  ~~~ruby
1628
1640
  require 'tbpgr_utils'
@@ -3543,6 +3555,7 @@ if you are Sublime Text2 user, you can use snippet for TbpgrUtils.
3543
3555
  https://github.com/tbpgr/tbpgr_utils_snippets
3544
3556
 
3545
3557
  ## History
3558
+ * version 0.0.119 : add Kernel#exchange
3546
3559
  * version 0.0.118 : add String#uniq
3547
3560
  * version 0.0.117 : add Array#kernel_send
3548
3561
  * version 0.0.116 : add Array#>>
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+
3
+ # Kernel
4
+ module Kernel
5
+ # exchange variable a for b
6
+ #
7
+ # === Example
8
+ #
9
+ # a = 1
10
+ # b = 2
11
+ # a, b = exchange(a, b)
12
+ # a # => 2
13
+ # b # => 1
14
+ #
15
+ def exchange(one, other)
16
+ tmp = one
17
+ one = other
18
+ other = tmp
19
+ [one, other]
20
+ end
21
+ end
@@ -4,6 +4,7 @@ require 'open_classes/kernel/aa_ancestors'
4
4
  require 'open_classes/kernel/booleans'
5
5
  require 'open_classes/kernel/bulk_define_methods'
6
6
  require 'open_classes/kernel/evalb'
7
+ require 'open_classes/kernel/exchange'
7
8
  require 'open_classes/kernel/hash_to_attributes'
8
9
  require 'open_classes/kernel/null'
9
10
  require 'open_classes/kernel/p_evals'
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Tbpgr Utilities
4
4
  module TbpgrUtils
5
- VERSION = '0.0.118'
5
+ VERSION = '0.0.119'
6
6
  end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require 'spec_helper'
3
+ require 'open_classes/kernel'
4
+
5
+ describe Kernel do
6
+ context :exchange do
7
+
8
+ cases = [
9
+ {
10
+ case_no: 1,
11
+ case_title: 'valid case',
12
+ input_a: 'aaa',
13
+ input_b: 'bbb',
14
+ expected_a: 'bbb',
15
+ expected_b: 'aaa',
16
+ },
17
+ ]
18
+
19
+ cases.each do |c|
20
+ it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
21
+ begin
22
+ case_before c
23
+
24
+ # -- given --
25
+ # nothing
26
+
27
+ # -- when --
28
+ actual_a, actual_b = exchange c[:input_a], c[:input_b]
29
+
30
+ # -- then --
31
+ expect(actual_a).to eq(c[:expected_a])
32
+ expect(actual_b).to eq(c[:expected_b])
33
+ ensure
34
+ case_after c
35
+ end
36
+ end
37
+
38
+ def case_before(c)
39
+ # implement each case before
40
+ end
41
+
42
+ def case_after(c)
43
+ # implement each case after
44
+ end
45
+ end
46
+ end
47
+ 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.118
4
+ version: 0.0.119
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-05 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -178,6 +178,7 @@ files:
178
178
  - lib/open_classes/kernel/booleans.rb
179
179
  - lib/open_classes/kernel/bulk_define_methods.rb
180
180
  - lib/open_classes/kernel/evalb.rb
181
+ - lib/open_classes/kernel/exchange.rb
181
182
  - lib/open_classes/kernel/hash_to_attributes.rb
182
183
  - lib/open_classes/kernel/null.rb
183
184
  - lib/open_classes/kernel/p_evals.rb
@@ -307,6 +308,7 @@ files:
307
308
  - spec/open_classes/kernel/bulk_define_methods_spec.rb
308
309
  - spec/open_classes/kernel/bulk_puts_eval_spec.rb
309
310
  - spec/open_classes/kernel/evalb_spec.rb
311
+ - spec/open_classes/kernel/exchange_spec.rb
310
312
  - spec/open_classes/kernel/hash_to_attributes_spec.rb
311
313
  - spec/open_classes/kernel/null_spec.rb
312
314
  - spec/open_classes/kernel/print_eval_spec.rb
@@ -456,6 +458,7 @@ test_files:
456
458
  - spec/open_classes/kernel/bulk_define_methods_spec.rb
457
459
  - spec/open_classes/kernel/bulk_puts_eval_spec.rb
458
460
  - spec/open_classes/kernel/evalb_spec.rb
461
+ - spec/open_classes/kernel/exchange_spec.rb
459
462
  - spec/open_classes/kernel/hash_to_attributes_spec.rb
460
463
  - spec/open_classes/kernel/null_spec.rb
461
464
  - spec/open_classes/kernel/print_eval_spec.rb