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 +4 -4
- data/VERSION +1 -1
- data/lib/tins/implement.rb +7 -1
- data/lib/tins/method_description.rb +17 -7
- data/lib/tins/version.rb +1 -1
- data/tests/implement_test.rb +9 -7
- data/tests/method_description_test.rb +13 -2
- data/tins.gemspec +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08cea9acd60cfcd4453eab5c92b0ed56ae0a974d
|
4
|
+
data.tar.gz: 71b120c34f22426c7f1e8fc38192a46106efc3ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d93c2db5859eb9058c69df4ca38527cb55286075bf1ff041bda1d10cad5ee8e1386fba3c992d8f7256cf194980f614daacb719673c34d62dd1b2c515e09c8155
|
7
|
+
data.tar.gz: be65dc0bebc790432ef98f4f1361cb8c5c9981f3f8601e6aca904893ee33679ac14d8dbf854bde06e9239919ec23aec16beaf98d59e06874ccab57d8010c6d93
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.2
|
data/lib/tins/implement.rb
CHANGED
@@ -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:
|
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
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
44
|
+
if %i[ namespace name ].include?(style)
|
45
|
+
result << ')'
|
46
|
+
end
|
47
|
+
result
|
38
48
|
end
|
39
49
|
end
|
40
50
|
end
|
data/lib/tins/version.rb
CHANGED
data/tests/implement_test.rb
CHANGED
@@ -16,7 +16,7 @@ module Tins
|
|
16
16
|
|
17
17
|
implement :quux, 'blab'
|
18
18
|
|
19
|
-
implement def foobar(
|
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
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
28
|
-
assert_equal 'Tins::MethodDescriptionTest::B#foo(x,y=?,*r,&b)',
|
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"
|
data/tins.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: tins 1.4.
|
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.
|
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.
|
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
|
-
-
|
157
|
-
-
|
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
|
-
-
|
361
|
+
- --title
|
362
362
|
- Tins - Useful stuff.
|
363
|
-
-
|
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: []
|