tins 0.10.0 → 0.11.0

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: e99b317c9c57007fcef885c2d32eda25b3d6a47a
4
- data.tar.gz: 629ee48b18c90d505ac1f1bb8eb1de579fbb5d7c
3
+ metadata.gz: 12264ea33708e81738c94b7d0287e23feb459f0e
4
+ data.tar.gz: 61f6f19e07c1f6a0f0afdcf8579f0fe408240cbc
5
5
  SHA512:
6
- metadata.gz: dd3b545cdd961d3ce78c08422e4bb15a7607d9f979714e433d17c9d1e60e55712066a16f3aecc76e782c20c721dcacfbe1001cc64b1a2da8c7a5105699ea6b14
7
- data.tar.gz: 272aab734332239ee7ba2d66ddcc598af0eb15480c345f7949da1db5214c563cda122ff1ebe688186f05850c8a7d3ee26c73a82300199dda10d114adf43286e5
6
+ metadata.gz: 646c5fbd40c43724d0c0d058b3afe852df784caf1ef3fe397fcec9db50d60683572b924c1f7240d86ec8d495dc0ba0e68e836d9f3ceac0c1f501d5b472b456e4
7
+ data.tar.gz: 2c072dc9e7c4683f66faa9b7ed43828437f258eb3608073ccd04bdf5f17bff33dd27b56eaff90c0eae88e477cf9ee92d15dd25c6fd2322ac7ef0e0c1778815f8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.0
1
+ 0.11.0
@@ -50,9 +50,23 @@ module Tins
50
50
  end
51
51
 
52
52
  module Kernel
53
- def Null(value = nil)
53
+ def null(value = nil)
54
54
  value.nil? ? Tins::NULL : value
55
55
  end
56
+
57
+ alias Null null
58
+
59
+ def null_plus(opts = {})
60
+ value = opts[:value]
61
+ opts[:caller] = caller
62
+ if respond_to?(:caller_locations, true)
63
+ opts[:caller_locations] = caller_locations
64
+ end
65
+
66
+ value.nil? ? Tins::NullPlus.new(opts) : value
67
+ end
68
+
69
+ alias NullPlus null_plus
56
70
  end
57
71
  end
58
72
 
@@ -61,6 +75,18 @@ module Tins
61
75
  end
62
76
 
63
77
  NULL = NullClass.new.freeze
78
+
79
+ class NullPlus
80
+ include Tins::Null
81
+
82
+ def initialize(opts = {})
83
+ class << self; self; end.class_eval do
84
+ opts.each do |name, value|
85
+ define_method(name) { value }
86
+ end
87
+ end
88
+ end
89
+ end
64
90
  end
65
91
 
66
92
  require 'tins/alias'
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '0.10.0'
3
+ VERSION = '0.11.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -13,11 +13,46 @@ module Tins
13
13
  assert_equal 0, NULL.to_i
14
14
  assert_equal 0.0, NULL.to_f
15
15
  assert_equal [], NULL.to_a
16
+ assert_equal 1, null(1)
16
17
  assert_equal 1, Null(1)
18
+ assert_equal NULL, null(nil)
17
19
  assert_equal NULL, Null(nil)
18
20
  assert_equal NULL, NULL::NULL
19
21
  assert NULL.nil?
20
22
  assert NULL.blank?
21
23
  end
24
+
25
+ def test_null_plus
26
+ assert_equal 1, null_plus(:value => 1)
27
+ assert_equal 1, NullPlus(:value => 1)
28
+ assert_kind_of Tins::NullPlus, null_plus(:value => nil)
29
+ assert_kind_of Tins::NullPlus, NullPlus(:value => nil)
30
+ assert_kind_of Tins::NullPlus, null_plus
31
+ assert_kind_of Tins::NullPlus, NullPlus()
32
+ assert_kind_of Tins::NullPlus, null_plus.foo
33
+ assert_kind_of Tins::NullPlus, null_plus.foo.bar
34
+ assert_kind_of Tins::NullPlus, NullPlus().foo
35
+ assert_kind_of Tins::NullPlus, NullPlus().foo.bar
36
+ assert null_plus.nil?
37
+ assert null_plus().blank?
38
+ assert NullPlus().nil?
39
+ assert NullPlus().blank?
40
+ end
41
+
42
+ def foo
43
+ 1 / 0
44
+ rescue => e
45
+ null_plus(:error => e)
46
+ end
47
+
48
+ def test_null_plus_caller_and_misc
49
+ assert_match /foo/, foo.caller.first
50
+ if foo.respond_to?(:caller_locations)
51
+ assert_kind_of Thread::Backtrace::Location, foo.caller_locations.first
52
+ assert_match /foo/, foo.caller_locations.first.to_s
53
+ end
54
+ assert_match /foo/, foo.caller.first
55
+ assert_kind_of ZeroDivisionError, foo.error
56
+ end
22
57
  end
23
58
  end
@@ -1,12 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
+ # stub: tins 0.11.0 ruby lib
2
3
 
3
4
  Gem::Specification.new do |s|
4
5
  s.name = "tins"
5
- s.version = "0.10.0"
6
+ s.version = "0.11.0"
6
7
 
7
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
9
  s.authors = ["Florian Frank"]
9
- s.date = "2013-09-18"
10
+ s.date = "2013-09-25"
10
11
  s.description = "All the stuff that isn't good/big enough for a real library."
11
12
  s.email = "flori@ping.de"
12
13
  s.extra_rdoc_files = ["README.rdoc", "lib/spruz.rb", "lib/tins.rb", "lib/tins/alias.rb", "lib/tins/annotate.rb", "lib/tins/ask_and_send.rb", "lib/tins/attempt.rb", "lib/tins/bijection.rb", "lib/tins/concern.rb", "lib/tins/count_by.rb", "lib/tins/date_dummy.rb", "lib/tins/date_time_dummy.rb", "lib/tins/deep_const_get.rb", "lib/tins/deep_dup.rb", "lib/tins/extract_last_argument_options.rb", "lib/tins/file_binary.rb", "lib/tins/find.rb", "lib/tins/generator.rb", "lib/tins/go.rb", "lib/tins/hash_symbolize_keys_recursive.rb", "lib/tins/hash_union.rb", "lib/tins/if_predicate.rb", "lib/tins/limited.rb", "lib/tins/lines_file.rb", "lib/tins/memoize.rb", "lib/tins/method_description.rb", "lib/tins/minimize.rb", "lib/tins/module_group.rb", "lib/tins/named_set.rb", "lib/tins/null.rb", "lib/tins/once.rb", "lib/tins/p.rb", "lib/tins/partial_application.rb", "lib/tins/proc_compose.rb", "lib/tins/proc_prelude.rb", "lib/tins/range_plus.rb", "lib/tins/require_maybe.rb", "lib/tins/responding.rb", "lib/tins/rotate.rb", "lib/tins/round.rb", "lib/tins/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/shuffle.rb", "lib/tins/string_camelize.rb", "lib/tins/string_underscore.rb", "lib/tins/string_version.rb", "lib/tins/subhash.rb", "lib/tins/terminal.rb", "lib/tins/time_dummy.rb", "lib/tins/to.rb", "lib/tins/to_proc.rb", "lib/tins/token.rb", "lib/tins/uniq_by.rb", "lib/tins/version.rb", "lib/tins/write.rb", "lib/tins/xt.rb", "lib/tins/xt/annotate.rb", "lib/tins/xt/ask_and_send.rb", "lib/tins/xt/attempt.rb", "lib/tins/xt/blank.rb", "lib/tins/xt/count_by.rb", "lib/tins/xt/date_dummy.rb", "lib/tins/xt/date_time_dummy.rb", "lib/tins/xt/deep_const_get.rb", "lib/tins/xt/deep_dup.rb", "lib/tins/xt/extract_last_argument_options.rb", "lib/tins/xt/file_binary.rb", "lib/tins/xt/full.rb", "lib/tins/xt/hash_symbolize_keys_recursive.rb", "lib/tins/xt/hash_union.rb", "lib/tins/xt/if_predicate.rb", "lib/tins/xt/irb.rb", "lib/tins/xt/method_description.rb", "lib/tins/xt/named.rb", "lib/tins/xt/null.rb", "lib/tins/xt/p.rb", "lib/tins/xt/partial_application.rb", "lib/tins/xt/proc_compose.rb", "lib/tins/xt/proc_prelude.rb", "lib/tins/xt/range_plus.rb", "lib/tins/xt/require_maybe.rb", "lib/tins/xt/responding.rb", "lib/tins/xt/rotate.rb", "lib/tins/xt/round.rb", "lib/tins/xt/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_camelize.rb", "lib/tins/xt/string_underscore.rb", "lib/tins/xt/string_version.rb", "lib/tins/xt/subhash.rb", "lib/tins/xt/symbol_to_proc.rb", "lib/tins/xt/time_dummy.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb"]
@@ -15,7 +16,7 @@ Gem::Specification.new do |s|
15
16
  s.licenses = ["MIT"]
16
17
  s.rdoc_options = ["--title", "Tins - Useful stuff.", "--main", "README.rdoc"]
17
18
  s.require_paths = ["lib"]
18
- s.rubygems_version = "2.0.6"
19
+ s.rubygems_version = "2.1.4"
19
20
  s.summary = "Useful stuff."
20
21
  s.test_files = ["tests/annotate_test.rb", "tests/ask_and_send_test.rb", "tests/attempt_test.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/concern_test.rb", "tests/count_by_test.rb", "tests/date_dummy_test.rb", "tests/date_time_dummy_test.rb", "tests/deep_const_get_test.rb", "tests/deep_dup_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/generator_test.rb", "tests/go_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/if_predicate_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/method_description_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_set_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/p_test.rb", "tests/partial_application_test.rb", "tests/proc_compose_test.rb", "tests/proc_prelude_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/responding_test.rb", "tests/rotate_test.rb", "tests/round_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/test_helper.rb", "tests/time_dummy_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb", "tests/annotate_test.rb", "tests/ask_and_send_test.rb", "tests/attempt_test.rb", "tests/bijection_test.rb", "tests/blank_full_test.rb", "tests/concern_test.rb", "tests/count_by_test.rb", "tests/date_dummy_test.rb", "tests/date_time_dummy_test.rb", "tests/deep_const_get_test.rb", "tests/deep_dup_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/generator_test.rb", "tests/go_test.rb", "tests/hash_symbolize_keys_recursive_test.rb", "tests/hash_union_test.rb", "tests/if_predicate_test.rb", "tests/limited_test.rb", "tests/lines_file_test.rb", "tests/memoize_test.rb", "tests/method_description_test.rb", "tests/minimize_test.rb", "tests/module_group_test.rb", "tests/named_set_test.rb", "tests/named_test.rb", "tests/null_test.rb", "tests/p_test.rb", "tests/partial_application_test.rb", "tests/proc_compose_test.rb", "tests/proc_prelude_test.rb", "tests/range_plus_test.rb", "tests/require_maybe_test.rb", "tests/responding_test.rb", "tests/rotate_test.rb", "tests/round_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_camelize_test.rb", "tests/string_underscore_test.rb", "tests/string_version_test.rb", "tests/subhash_test.rb", "tests/time_dummy_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb"]
21
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-18 00:00:00.000000000 Z
11
+ date: 2013-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -333,7 +333,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
333
  version: '0'
334
334
  requirements: []
335
335
  rubyforge_project:
336
- rubygems_version: 2.0.6
336
+ rubygems_version: 2.1.4
337
337
  signing_key:
338
338
  specification_version: 4
339
339
  summary: Useful stuff.