tins 1.42.0 → 1.44.0

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.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.contexts/code_comment.rb +5 -8
  3. data/.contexts/lib.rb +0 -2
  4. data/.contexts/yard.md +0 -1
  5. data/CHANGES.md +18 -0
  6. data/README.md +158 -6
  7. data/Rakefile +19 -16
  8. data/examples/let.rb +8 -40
  9. data/examples/mail.rb +0 -1
  10. data/examples/turing.rb +3 -1
  11. data/lib/tins/alias.rb +1 -0
  12. data/lib/tins/annotate.rb +37 -27
  13. data/lib/tins/ask_and_send.rb +41 -0
  14. data/lib/tins/attempt.rb +39 -0
  15. data/lib/tins/bijection.rb +34 -0
  16. data/lib/tins/case_predicate.rb +21 -0
  17. data/lib/tins/complete.rb +16 -0
  18. data/lib/tins/concern.rb +64 -0
  19. data/lib/tins/date_dummy.rb +36 -4
  20. data/lib/tins/date_time_dummy.rb +34 -2
  21. data/lib/tins/deep_dup.rb +9 -2
  22. data/lib/tins/deprecate.rb +12 -0
  23. data/lib/tins/dslkit.rb +563 -59
  24. data/lib/tins/duration.rb +120 -5
  25. data/lib/tins/expose.rb +54 -5
  26. data/lib/tins/extract_last_argument_options.rb +9 -0
  27. data/lib/tins/file_binary.rb +104 -21
  28. data/lib/tins/find.rb +114 -11
  29. data/lib/tins/generator.rb +10 -2
  30. data/lib/tins/go.rb +81 -4
  31. data/lib/tins/hash_bfs.rb +4 -2
  32. data/lib/tins/hash_symbolize_keys_recursive.rb +62 -4
  33. data/lib/tins/hash_union.rb +47 -2
  34. data/lib/tins/if_predicate.rb +31 -0
  35. data/lib/tins/implement.rb +50 -0
  36. data/lib/tins/limited.rb +54 -5
  37. data/lib/tins/lines_file.rb +81 -2
  38. data/lib/tins/lru_cache.rb +54 -17
  39. data/lib/tins/memoize.rb +86 -58
  40. data/lib/tins/method_description.rb +87 -4
  41. data/lib/tins/minimize.rb +39 -11
  42. data/lib/tins/module_group.rb +27 -2
  43. data/lib/tins/named_set.rb +20 -0
  44. data/lib/tins/null.rb +86 -15
  45. data/lib/tins/once.rb +61 -4
  46. data/lib/tins/p.rb +44 -8
  47. data/lib/tins/partial_application.rb +66 -7
  48. data/lib/tins/proc_compose.rb +58 -1
  49. data/lib/tins/proc_prelude.rb +97 -10
  50. data/lib/tins/range_plus.rb +30 -2
  51. data/lib/tins/require_maybe.rb +36 -0
  52. data/lib/tins/responding.rb +39 -0
  53. data/lib/tins/secure_write.rb +24 -4
  54. data/lib/tins/sexy_singleton.rb +45 -48
  55. data/lib/tins/string_byte_order_mark.rb +33 -2
  56. data/lib/tins/string_camelize.rb +31 -2
  57. data/lib/tins/string_underscore.rb +33 -2
  58. data/lib/tins/string_version.rb +179 -10
  59. data/lib/tins/subhash.rb +35 -10
  60. data/lib/tins/temp_io.rb +7 -0
  61. data/lib/tins/temp_io_enum.rb +19 -0
  62. data/lib/tins/terminal.rb +31 -9
  63. data/lib/tins/thread_local.rb +67 -5
  64. data/lib/tins/time_dummy.rb +46 -21
  65. data/lib/tins/to.rb +15 -0
  66. data/lib/tins/to_proc.rb +17 -4
  67. data/lib/tins/token.rb +56 -1
  68. data/lib/tins/unit.rb +288 -149
  69. data/lib/tins/version.rb +1 -1
  70. data/lib/tins/write.rb +14 -3
  71. data/lib/tins/xt/blank.rb +81 -2
  72. data/lib/tins/xt/concern.rb +51 -0
  73. data/lib/tins/xt/full.rb +56 -11
  74. data/lib/tins/xt/irb.rb +46 -2
  75. data/lib/tins/xt/method_description.rb +0 -12
  76. data/lib/tins/xt/minimize.rb +7 -0
  77. data/lib/tins/xt/named.rb +71 -16
  78. data/lib/tins/xt/proc_compose.rb +4 -0
  79. data/lib/tins/xt/subhash.rb +11 -0
  80. data/lib/tins/xt/time_freezer.rb +43 -6
  81. data/lib/tins/xt.rb +1 -3
  82. data/lib/tins.rb +16 -3
  83. data/tests/dslkit_test.rb +15 -0
  84. data/tests/duration_test.rb +4 -0
  85. data/tests/from_module_test.rb +30 -2
  86. data/tests/implement_test.rb +6 -8
  87. data/tests/lines_file_test.rb +2 -0
  88. data/tests/lru_cache_test.rb +12 -0
  89. data/tests/method_description_test.rb +14 -20
  90. data/tests/partial_application_test.rb +4 -0
  91. data/tests/proc_prelude_test.rb +1 -1
  92. data/tests/scope_test.rb +1 -1
  93. data/tests/string_version_test.rb +2 -0
  94. data/tests/to_test.rb +6 -6
  95. data/tins.gemspec +9 -9
  96. metadata +23 -41
  97. data/lib/tins/count_by.rb +0 -21
  98. data/lib/tins/deep_const_get.rb +0 -64
  99. data/lib/tins/timed_cache.rb +0 -51
  100. data/lib/tins/uniq_by.rb +0 -23
  101. data/lib/tins/xt/count_by.rb +0 -7
  102. data/lib/tins/xt/deep_const_get.rb +0 -7
  103. data/lib/tins/xt/uniq_by.rb +0 -25
  104. data/tests/count_by_test.rb +0 -17
  105. data/tests/deep_const_get_test.rb +0 -37
  106. data/tests/uniq_by_test.rb +0 -31
  107. /data/{COPYING → LICENSE} +0 -0
data/lib/tins/uniq_by.rb DELETED
@@ -1,23 +0,0 @@
1
- require 'tins/string_version'
2
-
3
- module Tins
4
- module UniqBy
5
- if Tins::StringVersion.compare(RUBY_VERSION, :<=, "1.8")
6
- def uniq_by(&block)
7
- block ||= lambda { |x| x }
8
- inject({}) { |h, e| h[ block.call(e) ] ||= e; h }.values
9
- end
10
- else
11
- require 'tins/deprecate'
12
- extend Tins::Deprecate
13
-
14
- deprecate method:
15
- def uniq_by(&block)
16
- uniq(&block)
17
- end,
18
- new_method: :uniq
19
- end
20
- end
21
- end
22
-
23
- require 'tins/alias'
@@ -1,7 +0,0 @@
1
- require 'tins/count_by'
2
-
3
- module Tins
4
- module ::Enumerable
5
- include CountBy
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'tins/deep_const_get'
2
-
3
- module Tins
4
- class ::Object
5
- include DeepConstGet
6
- end
7
- end
@@ -1,25 +0,0 @@
1
- require 'tins/string_version'
2
- require 'tins/uniq_by'
3
-
4
- module Tins
5
- module ::Enumerable
6
- include UniqBy
7
- end
8
-
9
- class ::Array
10
- if Tins::StringVersion.compare(RUBY_VERSION, :<=, "1.8")
11
- include UniqBy
12
-
13
- def uniq_by!(&b)
14
- replace uniq_by(&b)
15
- end
16
- else
17
- require 'tins/deprecate'
18
- extend Tins::Deprecate
19
-
20
- deprecate method:
21
- alias_method(:uniq_by!, :uniq!),
22
- new_method: :uniq!
23
- end
24
- end
25
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt'
3
-
4
- module Tins
5
- class CountByTest < Test::Unit::TestCase
6
-
7
- def test_count_by
8
- assert_equal 0, [].count_by { |x| x % 2 == 0 }
9
- assert_equal 0, [ 1 ].count_by { |x| x % 2 == 0 }
10
- assert_equal 1, [ 1 ].count_by { |x| x % 2 == 1 }
11
- assert_equal 1, [ 1, 2 ].count_by { |x| x % 2 == 0 }
12
- assert_equal 1, [ 1, 2 ].count_by { |x| x % 2 == 1 }
13
- assert_equal 2, [ 1, 2, 3, 4, 5 ].count_by { |x| x % 2 == 0 }
14
- assert_equal 3, [ 1, 2, 3, 4, 5 ].count_by { |x| x % 2 == 1 }
15
- end
16
- end
17
- end
@@ -1,37 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt/deep_const_get'
3
-
4
- module Tins
5
- class DeepConstGetTest < Test::Unit::TestCase
6
- module A
7
- module B
8
- end
9
- end
10
-
11
- module C
12
- module NotB
13
- end
14
-
15
- def self.const_missing(c)
16
- NotB
17
- end
18
- end
19
-
20
- def test_deep_const_get_with_start_module
21
- assert_raise(ArgumentError) { deep_const_get '::B', A }
22
- assert_equal A::B, deep_const_get('B', A)
23
- end
24
-
25
- def test_deep_const_get_without_start_module
26
- assert_equal Tins::DeepConstGetTest::A::B, deep_const_get('::Tins::DeepConstGetTest::A::B')
27
- assert_equal Tins::DeepConstGetTest::A::B, deep_const_get('Tins::DeepConstGetTest::A::B')
28
- assert_equal Array, deep_const_get('::Array')
29
- assert_equal Array, deep_const_get('Array')
30
- end
31
-
32
- def test_deep_const_get_with_const_missing
33
- assert_raise(ArgumentError) { deep_const_get '::Tins::DeepConstGetTest::A::NIXDA' }
34
- assert_equal Tins::DeepConstGetTest::C::NotB, deep_const_get('::Tins::DeepConstGetTest::C::B')
35
- end
36
- end
37
- end
@@ -1,31 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt'
3
-
4
- module Tins
5
- class UniqByTest < Test::Unit::TestCase
6
-
7
- unless defined?(Point)
8
- class Point < Struct.new :x, :y
9
- end
10
- end
11
-
12
- def test_uniq_by
13
- assert_equal [ 1, 2, 3 ], [ 1, 2, 2, 3 ].uniq_by.sort
14
- a = [ 1, 2, 2, 3 ]; a.uniq_by!
15
- assert_equal [ 1, 2, 3 ], a.sort
16
- p1 = Point.new 1, 2
17
- p2 = Point.new 2, 2
18
- p3 = Point.new 2, 2
19
- p4 = Point.new 3, 3
20
- a = [ p1, p2, p3, p4 ]
21
- a_uniq = a.uniq_by { |p| p.y }
22
- assert_equal 2, a_uniq.size
23
- assert a_uniq.include?(p4)
24
- assert [ p1, p2, p3 ].any? { |p| a_uniq.include? p }
25
- a.uniq_by! { |p| p.y }
26
- assert_equal 2, a.size
27
- assert a.include?(p4)
28
- assert [ p1, p2, p3 ].any? { |p| a.include? p }
29
- end
30
- end
31
- end
File without changes