tins 1.4.1 → 1.4.2

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: d7179c6d716a137637e5911d4acc12b00535fdc2
4
- data.tar.gz: 34a2983eaf2d5290a38f789ae66274d79c550a11
3
+ metadata.gz: 08cea9acd60cfcd4453eab5c92b0ed56ae0a974d
4
+ data.tar.gz: 71b120c34f22426c7f1e8fc38192a46106efc3ef
5
5
  SHA512:
6
- metadata.gz: 13ae38a401a666814bb1077e6ddd904dccd9469c0211a3be135a39c92c39b85005d9db0fdf0ee2fec00e10c3bb183074a6b6eee50694de338726b754a3580e7c
7
- data.tar.gz: 1f7157f970f167a0f7b2ac0cdeee59498f0c296f0687ae3324b7638746b711e8a016dec018d386f856ede0e4212b97852b11546b096d544d8a835fa62c6747e2
6
+ metadata.gz: d93c2db5859eb9058c69df4ca38527cb55286075bf1ff041bda1d10cad5ee8e1386fba3c992d8f7256cf194980f614daacb719673c34d62dd1b2c515e09c8155
7
+ data.tar.gz: be65dc0bebc790432ef98f4f1361cb8c5c9981f3f8601e6aca904893ee33679ac14d8dbf854bde06e9239919ec23aec16beaf98d59e06874ccab57d8010c6d93
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.1
1
+ 1.4.2
@@ -9,14 +9,20 @@ module Tins
9
9
  }
10
10
 
11
11
  def implement(method_name, msg = :default)
12
+ method_name.nil? and return
12
13
  case msg
13
14
  when ::Symbol
14
15
  msg = MESSAGES.fetch(msg)
15
16
  when ::Hash
16
17
  return implement method_name, msg.fetch(:in)
17
18
  end
19
+ display_method_name = method_name
20
+ if m = instance_method(method_name) rescue nil
21
+ m.extend Tins::MethodDescription
22
+ display_method_name = m.description(style: :name)
23
+ end
18
24
  begin
19
- msg = msg % { method_name: method_name, module: self }
25
+ msg = msg % { method_name: display_method_name, module: self }
20
26
  rescue KeyError
21
27
  end
22
28
  define_method(method_name) do |*|
@@ -1,13 +1,20 @@
1
1
  module Tins
2
2
  module MethodDescription
3
- def description
3
+ def description(style: :namespace)
4
+ valid_styles = %i[ namespace name parameters ]
5
+ valid_styles.include?(style) or
6
+ raise ArgumentError, "style has to be one of #{valid_styles * ', '}"
4
7
  result = ''
5
- if owner <= Module
6
- result << receiver.to_s << '.' # XXX Better to use owner here as well?
7
- else
8
- result << owner.name.to_s << '#'
8
+ if style == :namespace
9
+ if owner <= Module
10
+ result << receiver.to_s << '.' # XXX Better to use owner here as well?
11
+ else
12
+ result << owner.name.to_s << '#'
13
+ end
14
+ end
15
+ if %i[ namespace name ].include?(style)
16
+ result << name.to_s << '('
9
17
  end
10
- result << name.to_s << '('
11
18
  if respond_to?(:parameters)
12
19
  generated_name = 'x0'
13
20
  result << parameters.map { |p_type, p_name|
@@ -34,7 +41,10 @@ module Tins
34
41
  else
35
42
  result << arity.to_s
36
43
  end
37
- result << ')'
44
+ if %i[ namespace name ].include?(style)
45
+ result << ')'
46
+ end
47
+ result
38
48
  end
39
49
  end
40
50
  end
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.4.1'
3
+ VERSION = '1.4.2'
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:
@@ -16,7 +16,7 @@ module Tins
16
16
 
17
17
  implement :quux, 'blab'
18
18
 
19
- implement def foobar(x1, x2)
19
+ implement def foobar(arg1, arg2: :baz)
20
20
  end, in: :subclass
21
21
  end
22
22
 
@@ -54,12 +54,14 @@ module Tins
54
54
  assert_equal('blab', error_message { A.new.quux })
55
55
  end
56
56
 
57
- def test_implement_def_subclass
58
- assert_equal(
59
- 'method foobar has to be implemented in subclasses of '\
60
- 'Tins::ImplementTest::A',
61
- error_message { A.new.foobar }
62
- )
57
+ if RUBY_VERSION >= "2.1"
58
+ def test_implement_def_subclass
59
+ assert_equal(
60
+ 'method foobar(arg1,arg2:?) has to be '\
61
+ 'implemented in subclasses of Tins::ImplementTest::A',
62
+ error_message { A.new.foobar }
63
+ )
64
+ end
63
65
  end
64
66
 
65
67
  private
@@ -24,8 +24,19 @@ if RUBY_VERSION >= "1.9"
24
24
  end
25
25
  end
26
26
 
27
- def test_standard_parameters
28
- assert_equal 'Tins::MethodDescriptionTest::B#foo(x,y=?,*r,&b)', B.instance_method(:foo).to_s
27
+ def test_standard_parameters_namespace
28
+ assert_equal 'Tins::MethodDescriptionTest::B#foo(x,y=?,*r,&b)',
29
+ B.instance_method(:foo).to_s
30
+ end
31
+
32
+ def test_standard_parameters_name
33
+ assert_equal 'foo(x,y=?,*r,&b)',
34
+ B.instance_method(:foo).description(style: :name)
35
+ end
36
+
37
+ def test_standard_parameters_parameters
38
+ assert_equal 'x,y=?,*r,&b',
39
+ B.instance_method(:foo).description(style: :parameters)
29
40
  end
30
41
 
31
42
  if RUBY_VERSION >= "2.0"
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.4.1 ruby lib
2
+ # stub: tins 1.4.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins"
6
- s.version = "1.4.1"
6
+ s.version = "1.4.2"
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"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -14,28 +14,28 @@ dependencies:
14
14
  name: gem_hadar
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.0.0
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
26
  version: 1.0.0
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
33
  version: '2.5'
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
40
  version: '2.5'
41
41
  description: All the stuff that isn't good/big enough for a real library.
@@ -153,8 +153,8 @@ extra_rdoc_files:
153
153
  - lib/tins/xt/uniq_by.rb
154
154
  - lib/tins/xt/write.rb
155
155
  files:
156
- - ".gitignore"
157
- - ".travis.yml"
156
+ - .gitignore
157
+ - .travis.yml
158
158
  - COPYING
159
159
  - Gemfile
160
160
  - README.md
@@ -358,20 +358,20 @@ licenses:
358
358
  metadata: {}
359
359
  post_install_message:
360
360
  rdoc_options:
361
- - "--title"
361
+ - --title
362
362
  - Tins - Useful stuff.
363
- - "--main"
363
+ - --main
364
364
  - README.md
365
365
  require_paths:
366
366
  - lib
367
367
  required_ruby_version: !ruby/object:Gem::Requirement
368
368
  requirements:
369
- - - ">="
369
+ - - '>='
370
370
  - !ruby/object:Gem::Version
371
371
  version: '0'
372
372
  required_rubygems_version: !ruby/object:Gem::Requirement
373
373
  requirements:
374
- - - ">="
374
+ - - '>='
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
377
  requirements: []