tins 1.6.0 → 1.7.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: ed79dcbb515c4d5229e047bcb260e3243b448f2b
4
- data.tar.gz: e3e9da91db2f26845ff35a3e9260d84d3c9ded40
3
+ metadata.gz: 8ecd733df6253b597dbb1a608e9742807c3ef216
4
+ data.tar.gz: 188199f14d20984005844b8b1e402951c33b39c1
5
5
  SHA512:
6
- metadata.gz: 5eec2559ab24063e9845891e5c91468f195fd0a2b258c9b5ae5e4edddc75825d11dc2e4ef8cec0a5848e528de2ec972c43e36e095419de5d43b0271100531437
7
- data.tar.gz: dbda4cf1da0a871e3ee133158b60cc262221f4e1f255a221bc81a99031f0df02e2c39bc74eec4df449f4405319f58f4d3dd6468baced4f50839126a7b6950383
6
+ metadata.gz: de07c3e82a429d764312bebce102997681d1349e79cbb70139010741069e4d0dccf079e0a5a356bf3919f4fd049387778c6f9b906853ec2c98b06d0b8e6ea615
7
+ data.tar.gz: cd3e40afb2b09e548f7e51d441904c80c30bca63088eb4f53d58db95c5f8c1ccdb214bfb22984ca1e28a546ea245bc917a8e808948582039b1b216ff440a3e2c
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  .AppleDouble
3
3
  .DS_Store
4
4
  .bundle
5
+ .byebug_history
5
6
  .rbx
6
7
  .rvmrc
7
8
  Gemfile.lock
@@ -12,3 +12,4 @@ matrix:
12
12
  - rvm: jruby-head
13
13
  env:
14
14
  - CODECLIMATE_REPO_TOKEN=62d082406430ccf662c2e401976b613c0091e26fcfb546f92b1f2b391951cf50
15
+ sudo: false
data/Gemfile CHANGED
@@ -4,8 +4,9 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- group :development do
7
+ group :development, :test do
8
8
  gem 'simplecov'
9
9
  gem 'term-ansicolor'
10
- gem "codeclimate-test-reporter", group: :test, require: nil
10
+ gem "codeclimate-test-reporter", require: nil
11
+ gem 'byebug', platform: :mri
11
12
  end
data/README.md CHANGED
@@ -12,6 +12,13 @@ Non yet.
12
12
 
13
13
  ## Changes
14
14
 
15
+ * 2015-11-09 Release 1.7.0
16
+ - Officially require ruby >= 2.0 and use new hash syntax.
17
+ - New feature attempt: sleep:-30 sleeps upto 30 seconds while retrying with
18
+ an exponential waiting pattern.
19
+ - Remove rotate and shuffle, recent rubies all support them.
20
+ - Add an object oriented view on method signatures and use it to create
21
+ method descriptions.
15
22
  * 2015-08-13 Release 1.6.0
16
23
  - Add complete method for readline completion
17
24
  * 2015-06-21 Release 1.5.4
data/Rakefile CHANGED
@@ -12,10 +12,11 @@ GemHadar do
12
12
  test_dir 'tests'
13
13
  test_files.concat Dir["#{test_dir}/*_test.rb"]
14
14
  ignore '.*.sw[pon]', 'pkg', 'Gemfile.lock', '.rvmrc', 'coverage', '.rbx',
15
- '.AppleDouble', '.DS_Store', 'tags', '.bundle'
15
+ '.AppleDouble', '.DS_Store', 'tags', '.bundle', '.byebug_history'
16
16
 
17
17
  readme 'README.md'
18
18
  licenses << 'MIT'
19
19
 
20
- development_dependency 'test-unit', '~>2.5'
20
+ required_ruby_version '>= 2.0'
21
+ development_dependency 'test-unit', '~>3.1'
21
22
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.6.0
1
+ 1.7.0
@@ -22,7 +22,6 @@ module Tins
22
22
  require 'tins/range_plus'
23
23
  require 'tins/require_maybe'
24
24
  require 'tins/secure_write'
25
- require 'tins/shuffle'
26
25
  require 'tins/string_camelize'
27
26
  require 'tins/string_underscore'
28
27
  require 'tins/string_version'
@@ -40,7 +39,6 @@ module Tins
40
39
  require 'tins/proc_compose'
41
40
  require 'tins/proc_prelude'
42
41
  require 'tins/concern'
43
- require 'tins/rotate'
44
42
  require 'tins/to'
45
43
  require 'tins/terminal'
46
44
  require 'tins/sexy_singleton'
@@ -7,8 +7,9 @@ module Tins
7
7
  attempts = opts
8
8
  else
9
9
  attempts = opts[:attempts] || 1
10
+ attempts >= 1 or raise ArgumentError, 'at least one attempt is required'
10
11
  exception_class = opts[:exception_class] if opts.key?(:exception_class)
11
- sleep = opts[:sleep]
12
+ sleep = interpret_sleep(opts[:sleep], attempts)
12
13
  reraise = opts[:reraise]
13
14
  end
14
15
  return if attempts <= 0
@@ -28,7 +29,7 @@ module Tins
28
29
  count += 1
29
30
  block.call(count)
30
31
  true
31
- rescue exception_class
32
+ rescue *exception_class
32
33
  if count < attempts
33
34
  sleep_duration(sleep, count)
34
35
  retry
@@ -48,5 +49,40 @@ module Tins
48
49
  sleep duration.call(count)
49
50
  end
50
51
  end
52
+
53
+ def compute_duration_base(sleep, attempts)
54
+ x1, x2 = 1, sleep
55
+ attempts <= sleep or raise ArgumentError,
56
+ "need less or equal number of attempts than sleep duration #{sleep}"
57
+ x1 >= x2 and raise ArgumentError, "invalid sleep argument: #{sleep.inspect}"
58
+ function = -> x { (0...attempts).inject { |s, i| s + x ** i } - sleep }
59
+ f, fmid = function[x1], function[x2]
60
+ f * fmid >= 0 and raise ArgumentError, "invalid sleep argument: #{sleep.inspect}"
61
+ n = 1 << 16
62
+ epsilon = 1E-16
63
+ root = if f < 0
64
+ dx = x2 - x1
65
+ x1
66
+ else
67
+ dx = x1 - x2
68
+ x2
69
+ end
70
+ n.times do
71
+ fmid = function[xmid = root + (dx *= 0.5)]
72
+ fmid < 0 and root = xmid
73
+ dx.abs < epsilon or fmid == 0 and return root
74
+ end
75
+ raise ArgumentError, "too many iterations (#{n})"
76
+ result
77
+ end
78
+
79
+ def interpret_sleep(sleep, attempts)
80
+ if Numeric === sleep && sleep < 0 && attempts > 1
81
+ sleep = -sleep
82
+ duration_base = compute_duration_base sleep, attempts
83
+ sleep = lambda { |i| duration_base ** i }
84
+ end
85
+ sleep
86
+ end
51
87
  end
52
88
  end
@@ -17,10 +17,10 @@ module Tins
17
17
  attr_accessor :default_options
18
18
  end
19
19
  self.default_options = {
20
- :offset => 0,
21
- :buffer_size => 2 ** 13,
22
- :percentage_binary => 30.0,
23
- :percentage_zeros => 0.0,
20
+ offset: 0,
21
+ buffer_size: 2 ** 13,
22
+ percentage_binary: 30.0,
23
+ percentage_zeros: 0.0,
24
24
  }
25
25
 
26
26
  # Returns true if this file is considered to be binary, false if it is not
@@ -1,48 +1,141 @@
1
1
  module Tins
2
2
  module MethodDescription
3
+ class Parameters
4
+ class Parameter < Struct.new(:type, :name)
5
+ def ==(other)
6
+ type == other.type
7
+ end
8
+
9
+ def inspect
10
+ "#<#{self.class} #{to_s.inspect}>"
11
+ end
12
+ end
13
+
14
+ class RestParameter < Parameter
15
+ def to_s
16
+ "*#{name}"
17
+ end
18
+ end
19
+
20
+ class KeyrestParameter < Parameter
21
+ def to_s
22
+ "**#{name}"
23
+ end
24
+ end
25
+
26
+ class ReqParameter < Parameter
27
+ def to_s
28
+ name.to_s
29
+ end
30
+ end
31
+
32
+ class OptParameter < Parameter
33
+ def to_s
34
+ "#{name}=?"
35
+ end
36
+ end
37
+
38
+ class KeyParameter < Parameter
39
+ def to_s
40
+ "#{name}:?"
41
+ end
42
+ end
43
+
44
+ class KeyreqParameter < Parameter
45
+ def to_s
46
+ "#{name}:"
47
+ end
48
+ end
49
+
50
+ class BlockParameter < Parameter
51
+ def to_s
52
+ "&#{name}"
53
+ end
54
+ end
55
+
56
+ class GenericParameter < Parameter
57
+ def to_s
58
+ [ name, type ] * ?:
59
+ end
60
+ end
61
+
62
+ def self.build(type, name)
63
+ parameter_classname = "#{type.to_s.capitalize}Parameter"
64
+ parameter_class =
65
+ if const_defined? parameter_classname
66
+ const_get parameter_classname
67
+ else
68
+ GenericParameter
69
+ end
70
+ parameter_class.new(type, name)
71
+ end
72
+ end
73
+
74
+ class Signature
75
+ def initialize(*parameters)
76
+ @parameters = parameters
77
+ end
78
+
79
+ attr_reader :parameters
80
+
81
+ def eql?(other)
82
+ @parameters.eql? other.parameters
83
+ end
84
+
85
+ def ==(other)
86
+ @parameters == other.parameters
87
+ end
88
+
89
+ def ===(method)
90
+ self == method.signature
91
+ end
92
+
93
+ def to_s
94
+ @parameters * ?,
95
+ end
96
+
97
+ def inspect
98
+ "#<#{self.class} (#{to_s})>"
99
+ end
100
+ end
101
+
102
+ def signature
103
+ description style: :parameters
104
+ end
105
+
3
106
  def description(style: :namespace)
4
107
  valid_styles = %i[ namespace name parameters ]
5
108
  valid_styles.include?(style) or
6
- raise ArgumentError, "style has to be one of #{valid_styles * ', '}"
109
+ raise ArgumentError,
110
+ "style has to be one of #{valid_styles * ', '}"
111
+ if respond_to?(:parameters)
112
+ generated_name = 'x0'
113
+ parameter_array = parameters.map { |p_type, p_name|
114
+ unless p_name
115
+ generated_name = generated_name.succ
116
+ p_name = generated_name
117
+ end
118
+ Parameters.build(p_type, p_name)
119
+ }
120
+ signature = Signature.new(*parameter_array)
121
+ if style == :parameters
122
+ return signature
123
+ end
124
+ end
7
125
  result = ''
8
126
  if style == :namespace
9
127
  if owner <= Module
10
- result << receiver.to_s << '.' # XXX Better to use owner here as well?
128
+ result << receiver.to_s << ?. # XXX Better to use owner here as well?
11
129
  else
12
- result << owner.name.to_s << '#'
130
+ result << owner.name.to_s << ?#
13
131
  end
14
132
  end
15
133
  if %i[ namespace name ].include?(style)
16
134
  result << name.to_s << '('
17
135
  end
18
- if respond_to?(:parameters)
19
- generated_name = 'x0'
20
- result << parameters.map { |p_type, p_name|
21
- p_name ||= generated_name.succ!.dup
22
- case p_type
23
- when :block
24
- "&#{p_name}"
25
- when :rest
26
- "*#{p_name}"
27
- when :keyrest
28
- "**#{p_name}"
29
- when :req
30
- p_name
31
- when :opt
32
- "#{p_name}=?"
33
- when :key
34
- "#{p_name}:?"
35
- when :keyreq
36
- "#{p_name}:"
37
- else
38
- [ p_name, p_type ] * ':'
39
- end
40
- } * ','
41
- else
42
- result << arity.to_s
43
- end
136
+ result << (signature || arity).to_s
44
137
  if %i[ namespace name ].include?(style)
45
- result << ')'
138
+ result << ?)
46
139
  end
47
140
  result
48
141
  end
@@ -20,29 +20,29 @@ module Tins
20
20
  def array
21
21
  lambda { |*list| list }
22
22
  end
23
- memoize_function :array, :freeze => true
23
+ memoize_function :array, freeze: true
24
24
 
25
25
  def first
26
26
  lambda { |*list| list.first }
27
27
  end
28
- memoize_function :first, :freeze => true
28
+ memoize_function :first, freeze: true
29
29
 
30
30
  alias head first
31
31
 
32
32
  def second
33
33
  lambda { |*list| list[1] }
34
34
  end
35
- memoize_function :second, :freeze => true
35
+ memoize_function :second, freeze: true
36
36
 
37
37
  def tail
38
38
  lambda { |*list| list[1..-1] }
39
39
  end
40
- memoize_function :tail, :freeze => true
40
+ memoize_function :tail, freeze: true
41
41
 
42
42
  def last
43
43
  lambda { |*list| list.last }
44
44
  end
45
- memoize_function :last, :freeze => true
45
+ memoize_function :last, freeze: true
46
46
 
47
47
  def rotate(n = 1)
48
48
  lambda { |*list| list.rotate(n) }
@@ -53,7 +53,7 @@ module Tins
53
53
  def id1
54
54
  lambda { |obj| obj }
55
55
  end
56
- memoize_function :id1, :freeze => true
56
+ memoize_function :id1, freeze: true
57
57
 
58
58
  def const(konst = nil, &my_proc)
59
59
  konst ||= my_proc.call
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.6.0'
3
+ VERSION = '1.7.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:
@@ -32,7 +32,6 @@ module Tins
32
32
  require 'tins/xt/responding'
33
33
  require 'tins/xt/proc_compose'
34
34
  require 'tins/xt/proc_prelude'
35
- require 'tins/xt/rotate'
36
35
  require 'tins/xt/sexy_singleton'
37
36
  require 'tins/xt/method_description'
38
37
  require 'tins/xt/annotate'
@@ -3,44 +3,46 @@ require 'tins/xt'
3
3
 
4
4
  module Tins
5
5
  class AttemptTest < Test::Unit::TestCase
6
+ class MyError < StandardError; end
6
7
 
7
- def test_attempt_block_condition
8
- assert attempt(:attempts => 1, :exception_class => nil) { |c| c == 1 }
9
- assert attempt(:attempts => 3, :exception_class => nil) { |c| c == 1 }
10
- assert_equal false, attempt(:attempts => 3, :exception_class => nil) { |c| c == 4 }
11
- assert_nil attempt(:attempts => 0, :exception_class => nil) { |c| c == 4 }
12
- assert_raise(Exception) { attempt(:attempts => 3, :exception_class => nil) { raise Exception } }
8
+ class MyException < Exception; end
9
+
10
+ def test_attempt_with_invalid_arguments
11
+ assert_raise(ArgumentError) { attempt(attempts: 0) { } }
13
12
  end
14
13
 
15
- class MyError < StandardError; end
16
- class MyException < Exception; end
14
+ def test_attempt_block_condition
15
+ assert attempt(attempts: 1, exception_class: nil) { |c| c == 1 }
16
+ assert attempt(attempts: 3, exception_class: nil) { |c| c == 1 }
17
+ assert_equal false, attempt(attempts: 3, exception_class: nil) { |c| c == 4 }
18
+ assert_raise(MyException) { attempt(attempts: 3, exception_class: nil) { raise MyException } }
19
+ end
17
20
 
18
21
  def test_attempt_default_exception
19
22
  assert attempt(1) { |c| c != 1 and raise MyError }
20
23
  assert attempt(3) { |c| c != 1 and raise MyError }
21
24
  assert_equal false, attempt(3) { |c| c != 4 and raise MyError }
22
- assert_nil attempt(0) { |c| c != 4 and raise MyError }
23
25
  assert_raise(Exception) { attempt(3) { raise Exception } }
24
26
  end
25
27
 
26
28
  def test_attempt_exception
27
- assert attempt(:attempts => 1, :exception_class => MyException) { |c| c != 1 and raise MyException }
28
- assert attempt(:attempts => 3, :exception_class => MyException) { |c| c != 1 and raise MyException }
29
- assert_nil attempt(:attempts => 0, :exception_class => MyException) { |c| c != 4 and raise MyException }
30
- assert_raise(Exception) { attempt(:attempts => 3, :exception_class => MyException) { raise Exception } }
29
+ assert_equal false,
30
+ attempt(attempts: 3, exception_class: MyException) { raise MyException }
31
+ assert_equal true,
32
+ attempt(attempts: 3, exception_class: MyException) { |c| c == 1 and raise MyException }
31
33
  end
32
34
 
33
35
  def test_reraise_exception
34
36
  tries = 0
35
37
  assert_raise(MyException) do
36
- attempt(:attempts => 3, :exception_class => MyException, :reraise => true) do |c|
38
+ attempt(attempts: 3, exception_class: MyException, reraise: true) do |c|
37
39
  tries = c; raise MyException
38
40
  end
39
41
  end
40
42
  assert_equal 3, tries
41
43
  end
42
44
 
43
- def test_reraise_exception_with_numeric_sleep
45
+ def test_reraise_exception_with_positive_sleep
44
46
  tries = 0
45
47
  singleton_class.class_eval do
46
48
  define_method(:sleep_duration) do |duration, count|
@@ -50,7 +52,7 @@ module Tins
50
52
  end
51
53
  end
52
54
  assert_raise(MyException) do
53
- attempt(:attempts => 3, :exception_class => MyException, :reraise => true, :sleep => 10) do |c|
55
+ attempt(attempts: 3, exception_class: MyException, reraise: true, sleep: 10) do |c|
54
56
  raise MyException
55
57
  end
56
58
  end
@@ -71,7 +73,29 @@ module Tins
71
73
  end
72
74
  end
73
75
  assert_raise(MyException) do
74
- attempt(:attempts => 3, :exception_class => MyException, :reraise => true, :sleep => lambda { |x| 0 }) do |c|
76
+ attempt(attempts: 3, exception_class: MyException, reraise: true, sleep: -> x { 0 }) do |c|
77
+ raise MyException
78
+ end
79
+ end
80
+ assert_equal 2, tries
81
+ ensure
82
+ singleton_class.class_eval do
83
+ method_defined?(:sleep_duration) and remove_method :sleep_duration
84
+ end
85
+ end
86
+
87
+ def test_reraise_exception_with_negative_sleep
88
+ tries = 0
89
+ sleeps = [ 2.701, 7.298 ]
90
+ singleton_class.class_eval do
91
+ define_method(:sleep_duration) do |duration, count|
92
+ assert_in_delta sleeps[tries], duration.call(count), 1E-3
93
+ tries = count
94
+ super 0, count # Let's not really sleep that long…
95
+ end
96
+ end
97
+ assert_raise(MyException) do
98
+ attempt(attempts: 3, exception_class: MyException, reraise: true, sleep: -10) do |c|
75
99
  raise MyException
76
100
  end
77
101
  end
@@ -14,7 +14,7 @@ module Tins
14
14
  assert Set[].blank?
15
15
  assert !Set[23].blank?
16
16
  assert({}.blank?)
17
- assert !{ :foo => 23 }.blank?
17
+ assert !{ foo: 23 }.blank?
18
18
  assert "".blank?
19
19
  assert " ".blank?
20
20
  assert !"foo".blank?
@@ -29,7 +29,7 @@ module Tins
29
29
  assert !Set[].present?
30
30
  assert Set[23].present?
31
31
  assert !{}.present?
32
- assert({ :foo => 23 }.present?)
32
+ assert({ foo: 23 }.present?)
33
33
  assert !"".present?
34
34
  assert !" ".present?
35
35
  assert "foo".present?
@@ -44,7 +44,7 @@ module Tins
44
44
  assert_nil Set[].full?
45
45
  assert_equal Set[23], Set[23].full?
46
46
  assert_nil({}.full?)
47
- assert_equal({ :foo => 23 }, { :foo => 23 }.full?)
47
+ assert_equal({ foo: 23 }, { foo: 23 }.full?)
48
48
  assert_nil "".full?
49
49
  assert_nil " ".full?
50
50
  assert_equal "foo", "foo".full?
@@ -20,9 +20,9 @@ module Tins
20
20
  end
21
21
 
22
22
  def test_argument_array_witt_options
23
- arguments = [ 1, 2, 3, { :foo => :bar } ]
23
+ arguments = [ 1, 2, 3, { foo: :bar } ]
24
24
  result = arguments.extract_last_argument_options
25
- assert_equal [ [ 1, 2, 3 ], { :foo => :bar } ], result
25
+ assert_equal [ [ 1, 2, 3 ], { foo: :bar } ], result
26
26
  assert_not_same arguments, result.first
27
27
  assert_not_same arguments.last, result.last
28
28
  end
@@ -7,10 +7,10 @@ module Tins
7
7
  def test_ascii_buffer_size
8
8
  write_file do |file|
9
9
  file.write "A" * 10 + "\x00"
10
- assert_equal true, file.ascii?(:buffer_size => 10)
11
- assert_equal true, File.ascii?(file.path, :buffer_size => 10)
12
- assert_equal false, file.binary?(:buffer_size => 10)
13
- assert_equal false, File.binary?(file.path, :buffer_size => 10)
10
+ assert_equal true, file.ascii?(buffer_size: 10)
11
+ assert_equal true, File.ascii?(file.path, buffer_size: 10)
12
+ assert_equal false, file.binary?(buffer_size: 10)
13
+ assert_equal false, File.binary?(file.path, buffer_size: 10)
14
14
  end
15
15
  end
16
16
 
@@ -27,10 +27,10 @@ module Tins
27
27
  def test_ascii_offset
28
28
  write_file do |file|
29
29
  file.write "\x01" * 31 + "A" * 70
30
- assert_equal false, file.binary?(:offset => 1)
31
- assert_equal false, File.binary?(file.path, :offset => 1)
32
- assert_equal true, file.ascii?(:offset => 1)
33
- assert_equal true, File.ascii?(file.path, :offset => 1)
30
+ assert_equal false, file.binary?(offset: 1)
31
+ assert_equal false, File.binary?(file.path, offset: 1)
32
+ assert_equal true, file.ascii?(offset: 1)
33
+ assert_equal true, File.ascii?(file.path, offset: 1)
34
34
  end
35
35
  end
36
36
 
@@ -17,18 +17,18 @@ module Tins
17
17
  end
18
18
 
19
19
  def test_raising_errors
20
- assert_equal [], find(File.join(@work_dir, 'nix'), :raise_errors => false).to_a
20
+ assert_equal [], find(File.join(@work_dir, 'nix'), raise_errors: false).to_a
21
21
  assert_equal [], find(File.join(@work_dir, 'nix')).to_a
22
22
  assert_raise(Errno::ENOENT) do
23
- find(File.join(@work_dir, 'nix'), :raise_errors => true).to_a
23
+ find(File.join(@work_dir, 'nix'), raise_errors: true).to_a
24
24
  end
25
25
  end
26
26
 
27
27
  def test_showing_hidden
28
28
  touch file = File.join(@work_dir, '.foo')
29
- assert_equal [ @work_dir ], find(@work_dir, :show_hidden => false).to_a
29
+ assert_equal [ @work_dir ], find(@work_dir, show_hidden: false).to_a
30
30
  assert_equal [ @work_dir, file ], find(@work_dir).to_a
31
- assert_equal [ @work_dir, file ], find(@work_dir, :show_hidden => true).to_a
31
+ assert_equal [ @work_dir, file ], find(@work_dir, show_hidden: true).to_a
32
32
  end
33
33
 
34
34
  def test_check_directory_without_access
@@ -42,10 +42,10 @@ module Tins
42
42
  mkdir_p directory2 = File.join(directory1, 'bar')
43
43
  touch file = File.join(directory2, 'file')
44
44
  chmod 0, directory2
45
- assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir, :raise_errors => false).to_a
45
+ assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir, raise_errors: false).to_a
46
46
  assert_equal [ @work_dir, directory1, directory2 ], find(@work_dir).to_a
47
47
  assert_raise(Errno::EACCES) do
48
- find(@work_dir, :raise_errors => true).to_a
48
+ find(@work_dir, raise_errors: true).to_a
49
49
  end
50
50
  ensure
51
51
  File.exist?(directory2) and chmod 0777, directory2
@@ -58,9 +58,9 @@ module Tins
58
58
  mkdir_p directory3 = File.join(directory1, 'bar')
59
59
  touch file = File.join(directory3, 'foo')
60
60
  ln_s directory3, link = File.join(directory2, 'baz')
61
- assert_equal [ directory2, link ], find(directory2, :follow_symlinks => false).to_a
61
+ assert_equal [ directory2, link ], find(directory2, follow_symlinks: false).to_a
62
62
  assert_equal [ directory2, link, linked = File.join(link, 'foo') ], find(directory2).to_a
63
- assert_equal [ directory2, link, linked ], find(directory2, :follow_symlinks => true).to_a
63
+ assert_equal [ directory2, link, linked ], find(directory2, follow_symlinks: true).to_a
64
64
  end
65
65
 
66
66
  def test_path_file
@@ -89,7 +89,7 @@ module Tins
89
89
  end
90
90
 
91
91
  def test_suffix
92
- finder = Tins::Find::Finder.new(:suffix => 'bar')
92
+ finder = Tins::Find::Finder.new(suffix: 'bar')
93
93
  f = File.open(fpath = File.join(@work_dir, 'foo.bar'), 'w')
94
94
  g = File.open(gpath = File.join(@work_dir, 'foo.baz'), 'w')
95
95
  fpath = finder.prepare_path fpath
@@ -25,7 +25,7 @@ class FromModuleTest < Test::Unit::TestCase
25
25
  class DerivedKlass < MyKlass
26
26
  extend Tins::FromModule
27
27
 
28
- include from :module => MyIncludedModule, :methods => [ :foo ]
28
+ include from module: MyIncludedModule, methods: [ :foo ]
29
29
  end
30
30
 
31
31
  module MyModule
@@ -44,7 +44,7 @@ class FromModuleTest < Test::Unit::TestCase
44
44
 
45
45
  extend Tins::FromModule
46
46
 
47
- include from :module => MyIncludedModule, :methods => :foo
47
+ include from module: MyIncludedModule, methods: :foo
48
48
  end
49
49
 
50
50
  def test_derived_klass
@@ -3,10 +3,6 @@ require 'tins'
3
3
 
4
4
  module Tins
5
5
  class LimitedTest < Test::Unit::TestCase
6
- class ::Array
7
- include Tins::Shuffle
8
- end
9
-
10
6
  def test_limited
11
7
  count = {}
12
8
  limited = Tins::Limited.new(5)
@@ -21,6 +21,15 @@ module Tins
21
21
  class B
22
22
  def foo(x, y = 1, *r, &b)
23
23
  end
24
+
25
+ def bar(x, y = 2, *r, &b)
26
+ end
27
+
28
+ def bar2(x, z = 2, *r, &b)
29
+ end
30
+
31
+ def baz(x, y = 2, z = 3, *r, &b)
32
+ end
24
33
  end
25
34
 
26
35
  def test_standard_parameters_namespace
@@ -33,30 +42,50 @@ module Tins
33
42
  B.instance_method(:foo).description(style: :name)
34
43
  end
35
44
 
36
- def test_standard_parameters_parameters
37
- assert_equal 'x,y=?,*r,&b',
38
- B.instance_method(:foo).description(style: :parameters)
45
+ def test_standard_parameters_signature
46
+ assert_kind_of Tins::MethodDescription::Signature,
47
+ B.instance_method(:foo).signature
48
+ end
49
+
50
+ def test_signature_equalitites
51
+ assert_equal(
52
+ B.instance_method(:foo).signature,
53
+ B.instance_method(:bar).signature
54
+ )
55
+ assert_equal(
56
+ B.instance_method(:foo).signature,
57
+ B.instance_method(:bar2).signature
58
+ )
59
+ assert_false\
60
+ B.instance_method(:foo).signature.eql?(
61
+ B.instance_method(:bar2).signature
62
+ )
63
+ assert_operator(
64
+ B.instance_method(:foo).signature,
65
+ :===,
66
+ B.instance_method(:bar2)
67
+ )
68
+ assert_not_equal(
69
+ B.instance_method(:bar).signature,
70
+ B.instance_method(:baz).signature
71
+ )
39
72
  end
40
73
 
41
74
  def test_a_cstyle_method_from_hash
42
75
  assert_equal "Hash#store(x1,x2)", ({}.method(:store).description)
43
76
  end
44
77
 
45
- if RUBY_VERSION >= "2.0"
46
- eval %{
47
- class C
48
- def foo(x, k: true, &b)
49
- end
78
+ class C
79
+ def foo(x, k: true, &b)
80
+ end
50
81
 
51
- def bar(x, **k, &b)
52
- end
53
- end
82
+ def bar(x, **k, &b)
83
+ end
84
+ end
54
85
 
55
- def test_keyword_parameters
56
- assert_equal 'Tins::MethodDescriptionTest::C#foo(x,k:?,&b)', C.instance_method(:foo).to_s
57
- assert_equal 'Tins::MethodDescriptionTest::C#bar(x,**k,&b)', C.instance_method(:bar).to_s
58
- end
59
- }
86
+ def test_keyword_parameters
87
+ assert_equal 'Tins::MethodDescriptionTest::C#foo(x,k:?,&b)', C.instance_method(:foo).to_s
88
+ assert_equal 'Tins::MethodDescriptionTest::C#bar(x,**k,&b)', C.instance_method(:bar).to_s
60
89
  end
61
90
 
62
91
  if RUBY_VERSION >= "2.1"
@@ -25,10 +25,10 @@ module Tins
25
25
  end
26
26
 
27
27
  def test_null_plus
28
- assert_equal 1, null_plus(:value => 1)
29
- assert_equal 1, NullPlus(:value => 1)
30
- assert_kind_of Tins::NullPlus, null_plus(:value => nil)
31
- assert_kind_of Tins::NullPlus, NullPlus(:value => nil)
28
+ assert_equal 1, null_plus(value: 1)
29
+ assert_equal 1, NullPlus(value: 1)
30
+ assert_kind_of Tins::NullPlus, null_plus(value: nil)
31
+ assert_kind_of Tins::NullPlus, NullPlus(value: nil)
32
32
  assert_kind_of Tins::NullPlus, null_plus
33
33
  assert_kind_of Tins::NullPlus, NullPlus()
34
34
  assert_kind_of Tins::NullPlus, null_plus.foo
@@ -48,7 +48,7 @@ module Tins
48
48
  def foo
49
49
  1 / 0
50
50
  rescue => e
51
- null_plus(:error => e)
51
+ null_plus(error: e)
52
52
  end
53
53
 
54
54
  def test_null_plus_caller_and_misc
@@ -4,32 +4,32 @@ require 'tins'
4
4
  module Tins
5
5
  class TokenTest < Test::Unit::TestCase
6
6
  def test_token_failures
7
- assert_raises(ArgumentError) { Tins::Token.new(:bits => 0) }
8
- assert_raises(ArgumentError) { Tins::Token.new(:length => 0) }
9
- assert_raises(ArgumentError) { Tins::Token.new(:alphabet => %w[0]) }
7
+ assert_raises(ArgumentError) { Tins::Token.new(bits: 0) }
8
+ assert_raises(ArgumentError) { Tins::Token.new(length: 0) }
9
+ assert_raises(ArgumentError) { Tins::Token.new(alphabet: %w[0]) }
10
10
  end
11
11
 
12
12
  def test_token_for_length
13
- token = Tins::Token.new(:length => 22)
13
+ token = Tins::Token.new(length: 22)
14
14
  assert_equal 22, token.length
15
15
  assert_equal 130, token.bits
16
16
  end
17
17
 
18
18
  def test_token_for_bits
19
- token = Tins::Token.new(:bits => 128)
19
+ token = Tins::Token.new(bits: 128)
20
20
  assert_equal 22, token.length
21
21
  # can differ from bits argument depending on alphabet:
22
22
  assert_equal 130, token.bits
23
23
  end
24
24
 
25
25
  def test_alphabet
26
- token = Tins::Token.new(:alphabet => %w[0 1])
26
+ token = Tins::Token.new(alphabet: %w[0 1])
27
27
  assert_equal 128, token.length
28
28
  assert_equal 128, token.bits
29
- token = Tins::Token.new(:alphabet => %w[0 1 2 3])
29
+ token = Tins::Token.new(alphabet: %w[0 1 2 3])
30
30
  assert_equal 64, token.length
31
31
  assert_equal 128, token.bits
32
- token = Tins::Token.new(:length => 128, :alphabet => %w[0 1 2 3])
32
+ token = Tins::Token.new(length: 128, alphabet: %w[0 1 2 3])
33
33
  assert_equal 128, token.length
34
34
  assert_equal 256, token.bits
35
35
  end
@@ -1,37 +1,38 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.6.0 ruby lib
2
+ # stub: tins 1.7.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins"
6
- s.version = "1.6.0"
6
+ s.version = "1.7.0"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
10
10
  s.authors = ["Florian Frank"]
11
- s.date = "2015-08-13"
11
+ s.date = "2015-11-10"
12
12
  s.description = "All the stuff that isn't good/big enough for a real library."
13
13
  s.email = "flori@ping.de"
14
- s.extra_rdoc_files = ["README.md", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "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/case_predicate.rb", "lib/tins/complete.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/shuffle.rb", "lib/tins/string_byte_order_mark.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/thread_local.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/case_predicate.rb", "lib/tins/xt/complete.rb", "lib/tins/xt/concern.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.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/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb"]
15
- s.files = [".gitignore", ".travis.yml", "COPYING", "Gemfile", "README.md", "Rakefile", "TODO", "VERSION", "examples/add_one.png", "examples/add_one.stm", "examples/bb3.png", "examples/bb3.stm", "examples/concatenate_compare.mtm", "examples/concatenate_compare.png", "examples/length_difference.mtm", "examples/length_difference.png", "examples/let.rb", "examples/mail.rb", "examples/minsky.rb", "examples/multiply.reg", "examples/null_pattern.rb", "examples/ones_difference-mtm.png", "examples/ones_difference-stm.png", "examples/ones_difference.mtm", "examples/ones_difference.stm", "examples/prefix-equals-suffix-reversed-with-infix.png", "examples/prefix-equals-suffix-reversed-with-infix.stm", "examples/recipe.rb", "examples/recipe2.rb", "examples/recipe_common.rb", "examples/subtract.reg", "examples/turing-graph.rb", "examples/turing.rb", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "lib/spruz", "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/case_predicate.rb", "lib/tins/complete.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/shuffle.rb", "lib/tins/string_byte_order_mark.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/thread_local.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/case_predicate.rb", "lib/tins/xt/complete.rb", "lib/tins/xt/concern.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.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/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_byte_order_mark_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/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb", "tins.gemspec"]
14
+ s.extra_rdoc_files = ["README.md", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "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/case_predicate.rb", "lib/tins/complete.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/string_byte_order_mark.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/thread_local.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/case_predicate.rb", "lib/tins/xt/complete.rb", "lib/tins/xt/concern.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.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/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb"]
15
+ s.files = [".gitignore", ".travis.yml", "COPYING", "Gemfile", "README.md", "Rakefile", "TODO", "VERSION", "examples/add_one.png", "examples/add_one.stm", "examples/bb3.png", "examples/bb3.stm", "examples/concatenate_compare.mtm", "examples/concatenate_compare.png", "examples/length_difference.mtm", "examples/length_difference.png", "examples/let.rb", "examples/mail.rb", "examples/minsky.rb", "examples/multiply.reg", "examples/null_pattern.rb", "examples/ones_difference-mtm.png", "examples/ones_difference-stm.png", "examples/ones_difference.mtm", "examples/ones_difference.stm", "examples/prefix-equals-suffix-reversed-with-infix.png", "examples/prefix-equals-suffix-reversed-with-infix.stm", "examples/recipe.rb", "examples/recipe2.rb", "examples/recipe_common.rb", "examples/subtract.reg", "examples/turing-graph.rb", "examples/turing.rb", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "lib/spruz", "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/case_predicate.rb", "lib/tins/complete.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/string_byte_order_mark.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/thread_local.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/case_predicate.rb", "lib/tins/xt/complete.rb", "lib/tins/xt/concern.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/dslkit.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/implement.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/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.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/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/string_byte_order_mark_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/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb", "tins.gemspec"]
16
16
  s.homepage = "https://github.com/flori/tins"
17
17
  s.licenses = ["MIT"]
18
18
  s.rdoc_options = ["--title", "Tins - Useful stuff.", "--main", "README.md"]
19
- s.rubygems_version = "2.4.6"
19
+ s.required_ruby_version = Gem::Requirement.new(">= 2.0")
20
+ s.rubygems_version = "2.5.0"
20
21
  s.summary = "Useful stuff."
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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_byte_order_mark_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/time_freezer_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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/shuffle_test.rb", "tests/string_byte_order_mark_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/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb"]
22
+ 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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/string_byte_order_mark_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/time_freezer_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/case_predicate_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/delegate_test.rb", "tests/dslkit_test.rb", "tests/dynamic_scope_test.rb", "tests/extract_last_argument_options_test.rb", "tests/file_binary_test.rb", "tests/find_test.rb", "tests/from_module_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/implement_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/scope_test.rb", "tests/secure_write_test.rb", "tests/sexy_singleton_test.rb", "tests/string_byte_order_mark_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/time_freezer_test.rb", "tests/to_test.rb", "tests/token_test.rb", "tests/uniq_by_test.rb"]
22
23
 
23
24
  if s.respond_to? :specification_version then
24
25
  s.specification_version = 4
25
26
 
26
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<gem_hadar>, ["~> 1.2.0"])
28
- s.add_development_dependency(%q<test-unit>, ["~> 2.5"])
28
+ s.add_development_dependency(%q<gem_hadar>, ["~> 1.3.1"])
29
+ s.add_development_dependency(%q<test-unit>, ["~> 3.1"])
29
30
  else
30
- s.add_dependency(%q<gem_hadar>, ["~> 1.2.0"])
31
- s.add_dependency(%q<test-unit>, ["~> 2.5"])
31
+ s.add_dependency(%q<gem_hadar>, ["~> 1.3.1"])
32
+ s.add_dependency(%q<test-unit>, ["~> 3.1"])
32
33
  end
33
34
  else
34
- s.add_dependency(%q<gem_hadar>, ["~> 1.2.0"])
35
- s.add_dependency(%q<test-unit>, ["~> 2.5"])
35
+ s.add_dependency(%q<gem_hadar>, ["~> 1.3.1"])
36
+ s.add_dependency(%q<test-unit>, ["~> 3.1"])
36
37
  end
37
38
  end
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: 1.6.0
4
+ version: 1.7.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: 2015-08-13 00:00:00.000000000 Z
11
+ date: 2015-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2.0
19
+ version: 1.3.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2.0
26
+ version: 1.3.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '3.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '3.1'
41
41
  description: All the stuff that isn't good/big enough for a real library.
42
42
  email: flori@ping.de
43
43
  executables: []
@@ -88,10 +88,8 @@ extra_rdoc_files:
88
88
  - lib/tins/range_plus.rb
89
89
  - lib/tins/require_maybe.rb
90
90
  - lib/tins/responding.rb
91
- - lib/tins/rotate.rb
92
91
  - lib/tins/secure_write.rb
93
92
  - lib/tins/sexy_singleton.rb
94
- - lib/tins/shuffle.rb
95
93
  - lib/tins/string_byte_order_mark.rb
96
94
  - lib/tins/string_camelize.rb
97
95
  - lib/tins/string_underscore.rb
@@ -141,7 +139,6 @@ extra_rdoc_files:
141
139
  - lib/tins/xt/rotate.rb
142
140
  - lib/tins/xt/secure_write.rb
143
141
  - lib/tins/xt/sexy_singleton.rb
144
- - lib/tins/xt/shuffle.rb
145
142
  - lib/tins/xt/string.rb
146
143
  - lib/tins/xt/string_byte_order_mark.rb
147
144
  - lib/tins/xt/string_camelize.rb
@@ -232,10 +229,8 @@ files:
232
229
  - lib/tins/range_plus.rb
233
230
  - lib/tins/require_maybe.rb
234
231
  - lib/tins/responding.rb
235
- - lib/tins/rotate.rb
236
232
  - lib/tins/secure_write.rb
237
233
  - lib/tins/sexy_singleton.rb
238
- - lib/tins/shuffle.rb
239
234
  - lib/tins/string_byte_order_mark.rb
240
235
  - lib/tins/string_camelize.rb
241
236
  - lib/tins/string_underscore.rb
@@ -285,7 +280,6 @@ files:
285
280
  - lib/tins/xt/rotate.rb
286
281
  - lib/tins/xt/secure_write.rb
287
282
  - lib/tins/xt/sexy_singleton.rb
288
- - lib/tins/xt/shuffle.rb
289
283
  - lib/tins/xt/string.rb
290
284
  - lib/tins/xt/string_byte_order_mark.rb
291
285
  - lib/tins/xt/string_camelize.rb
@@ -343,7 +337,6 @@ files:
343
337
  - tests/scope_test.rb
344
338
  - tests/secure_write_test.rb
345
339
  - tests/sexy_singleton_test.rb
346
- - tests/shuffle_test.rb
347
340
  - tests/string_byte_order_mark_test.rb
348
341
  - tests/string_camelize_test.rb
349
342
  - tests/string_underscore_test.rb
@@ -372,7 +365,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
372
365
  requirements:
373
366
  - - ">="
374
367
  - !ruby/object:Gem::Version
375
- version: '0'
368
+ version: '2.0'
376
369
  required_rubygems_version: !ruby/object:Gem::Requirement
377
370
  requirements:
378
371
  - - ">="
@@ -380,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
380
373
  version: '0'
381
374
  requirements: []
382
375
  rubyforge_project:
383
- rubygems_version: 2.4.6
376
+ rubygems_version: 2.5.0
384
377
  signing_key:
385
378
  specification_version: 4
386
379
  summary: Useful stuff.
@@ -430,7 +423,6 @@ test_files:
430
423
  - tests/scope_test.rb
431
424
  - tests/secure_write_test.rb
432
425
  - tests/sexy_singleton_test.rb
433
- - tests/shuffle_test.rb
434
426
  - tests/string_byte_order_mark_test.rb
435
427
  - tests/string_camelize_test.rb
436
428
  - tests/string_underscore_test.rb
@@ -1,16 +0,0 @@
1
- module Tins
2
- module Rotate
3
- def rotate!(n = 1)
4
- if n >= 0
5
- n.times { push shift }
6
- else
7
- (-n).times { unshift pop }
8
- end
9
- self
10
- end
11
-
12
- def rotate(n = 1)
13
- clone.rotate!(n)
14
- end
15
- end
16
- end
@@ -1,18 +0,0 @@
1
- module Tins
2
- module Shuffle
3
- # :nocov:
4
- def shuffle!
5
- (size - 1) .downto(1) do |i|
6
- j = rand(i + 1)
7
- self[i], self[j] = self[j], self[i]
8
- end
9
- self
10
- end
11
-
12
- def shuffle
13
- dup.shuffle!
14
- end
15
- end
16
- end
17
-
18
- require 'tins/alias'
@@ -1,11 +0,0 @@
1
- require 'tins/shuffle'
2
-
3
- module Tins
4
- class ::Array
5
- if method_defined?(:shuffle)
6
- warn "#{self}#shuffle already defined, didn't include at #{__FILE__}:#{__LINE__}"
7
- else
8
- include Shuffle
9
- end
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
- require 'tins/xt'
3
-
4
- module Tins
5
- if Tins::Shuffle === Array
6
- class ShuffleTest < Test::Unit::TestCase
7
-
8
- def setup
9
- @a = [ 1, 2, 3 ]
10
- srand 666
11
- end
12
-
13
- def test_shuffle
14
- assert_equal(a = [2, 3, 1], a = @a.shuffle)
15
- assert_not_same @a, a
16
- assert_equal(b = [3, 1, 2], b = @a.shuffle)
17
- assert_not_same a, b
18
- assert_not_same @a, b
19
- end
20
-
21
- def test_shuffle_bang
22
- assert_equal([2, 3, 1], a = @a.shuffle!)
23
- assert_same @a, a
24
- assert_equal([1, 2, 3], b = @a.shuffle!)
25
- assert_same a, b
26
- assert_same @a, b
27
- end
28
- end
29
- end
30
- end