value 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -7
- data/lib/value/version.rb +3 -8
- metadata +31 -11
- data/lib/value/yard-1.0.rb +0 -55
- data/test/unit/value/yard-1.0.rb +0 -166
data/Rakefile
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
|
-
require 'inventory/rake
|
4
|
-
require 'lookout/rake
|
3
|
+
require 'inventory/rake-1.0'
|
4
|
+
require 'lookout/rake-3.0'
|
5
5
|
|
6
|
-
|
7
|
-
require 'value/version'
|
6
|
+
load File.expand_path('../lib/value/version.rb', __FILE__)
|
8
7
|
|
9
8
|
Inventory::Rake::Tasks.define Value::Version, :gem => proc{ |_, s|
|
10
9
|
s.author = 'Nikolai Weibull'
|
11
10
|
s.email = 'now@bitwi.se'
|
12
11
|
s.homepage = 'https://github.com/now/value'
|
13
12
|
}
|
14
|
-
|
15
|
-
# TODO: Silence warnings generated from YARD (remove this once we plug them)
|
16
|
-
Lookout::Rake::Tasks::Test.new :options => []
|
13
|
+
Lookout::Rake::Tasks::Test.new
|
data/lib/value/version.rb
CHANGED
@@ -3,10 +3,12 @@
|
|
3
3
|
require 'inventory-1.0'
|
4
4
|
|
5
5
|
module Value
|
6
|
-
Version = Inventory.new(1,
|
6
|
+
Version = Inventory.new(1, 1, 0){
|
7
7
|
def dependencies
|
8
8
|
super + Inventory::Dependencies.new{
|
9
|
+
development 'inventory-rake', 1, 2, 0
|
9
10
|
development 'lookout', 3, 0, 0
|
11
|
+
development 'lookout-rake', 3, 0, 0
|
10
12
|
development 'yard', 0, 7, 0
|
11
13
|
}
|
12
14
|
end
|
@@ -17,12 +19,5 @@ module Value
|
|
17
19
|
value/values.rb
|
18
20
|
'
|
19
21
|
end
|
20
|
-
|
21
|
-
def additional_libs
|
22
|
-
super +
|
23
|
-
%w'
|
24
|
-
value/yard-1.0.rb
|
25
|
-
'
|
26
|
-
end
|
27
22
|
}
|
28
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: value
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,44 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: inventory
|
16
|
-
requirement: &
|
16
|
+
requirement: &15789612 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
21
|
+
version: '1.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *15789612
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: inventory-rake
|
27
|
+
requirement: &15788556 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.2'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *15788556
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: lookout
|
27
|
-
requirement: &
|
38
|
+
requirement: &15787416 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '3.0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *15787416
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: lookout-rake
|
49
|
+
requirement: &15786384 !ruby/object:Gem::Requirement
|
28
50
|
none: false
|
29
51
|
requirements:
|
30
52
|
- - ~>
|
@@ -32,10 +54,10 @@ dependencies:
|
|
32
54
|
version: '3.0'
|
33
55
|
type: :development
|
34
56
|
prerelease: false
|
35
|
-
version_requirements: *
|
57
|
+
version_requirements: *15786384
|
36
58
|
- !ruby/object:Gem::Dependency
|
37
59
|
name: yard
|
38
|
-
requirement: &
|
60
|
+
requirement: &15785652 !ruby/object:Gem::Requirement
|
39
61
|
none: false
|
40
62
|
requirements:
|
41
63
|
- - ~>
|
@@ -43,7 +65,7 @@ dependencies:
|
|
43
65
|
version: 0.7.0
|
44
66
|
type: :development
|
45
67
|
prerelease: false
|
46
|
-
version_requirements: *
|
68
|
+
version_requirements: *15785652
|
47
69
|
description: ! " Value\n\n Value is a library
|
48
70
|
for defining value objects in Ruby.\n"
|
49
71
|
email: now@bitwi.se
|
@@ -55,12 +77,10 @@ files:
|
|
55
77
|
- lib/value/values.rb
|
56
78
|
- lib/value-1.0.rb
|
57
79
|
- lib/value/version.rb
|
58
|
-
- lib/value/yard-1.0.rb
|
59
80
|
- test/unit/value/comparable.rb
|
60
81
|
- test/unit/value/values.rb
|
61
82
|
- test/unit/value-1.0.rb
|
62
83
|
- test/unit/value/version.rb
|
63
|
-
- test/unit/value/yard-1.0.rb
|
64
84
|
- README
|
65
85
|
- Rakefile
|
66
86
|
homepage: https://github.com/now/value
|
data/lib/value/yard-1.0.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'yard'
|
4
|
-
|
5
|
-
class YARD::Handlers::Ruby::ValuesHandler < YARD::Handlers::Ruby::Base
|
6
|
-
handles method_call('Value')
|
7
|
-
namespace_only
|
8
|
-
|
9
|
-
process do
|
10
|
-
parameters = statement.parameters(false)
|
11
|
-
if YARD::Parser::Ruby::AstNode === parameters[-1][0] and
|
12
|
-
parameters[-1][0].type == :assoc and
|
13
|
-
comparable = parameters[-1].find{ |e| e.jump(:ident).source == 'comparable' }
|
14
|
-
parameters.pop
|
15
|
-
comparables = (comparable[1].type == :array and comparable[1][0].map{ |e| e.jump(:ident).source })
|
16
|
-
ancestor 'Comparable'
|
17
|
-
ancestor 'Value::Comparable'
|
18
|
-
end
|
19
|
-
ancestor 'Value'
|
20
|
-
initialize = define('initialize', parameters.map{ |e| [e.jump(:ident).source, e.type == :array ? e[0][1].source : nil] })
|
21
|
-
initialize.docstring.tags(:param).select{ |e| e.text and not e.text.empty? }.each do |e|
|
22
|
-
define e.name.sub(/\A[&*]/, ''), [],
|
23
|
-
'@return [%s] %s' % [e.types ? e.types.join(', ') : '', e.text], :protected
|
24
|
-
e.text = ''
|
25
|
-
end
|
26
|
-
initialize.docstring.add_tag(YARD::Tags::Tag.new(:note, 'Comparisons between instances are made between %s.' % join(comparables))) if comparables
|
27
|
-
end
|
28
|
-
|
29
|
-
def ancestor(name)
|
30
|
-
modul = Proxy.new(:root, name).tap{ |m| m.type = :module }
|
31
|
-
namespace.mixins(scope).unshift(modul) unless namespace.mixins(scope).include? modul
|
32
|
-
end
|
33
|
-
|
34
|
-
def define(name, parameters, docstring = nil, visibility = :public)
|
35
|
-
YARD::CodeObjects::MethodObject.new(namespace, name).tap{ |m|
|
36
|
-
register(m)
|
37
|
-
m.signature = 'def %s%s' %
|
38
|
-
[name,
|
39
|
-
parameters.empty? ?
|
40
|
-
'' :
|
41
|
-
'(%s)' % parameters.map{ |n, d| d ? '%s = %s' % [n, d] : n }.join(', ')]
|
42
|
-
m.parameters = parameters
|
43
|
-
m.docstring = docstring if docstring
|
44
|
-
m.visibility = visibility
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
def join(items)
|
49
|
-
return items.join('') if items.size < 2
|
50
|
-
return items.join(' and ') if items.size < 3
|
51
|
-
return '%s, and %s' % [items[0..-2].join(', '), items[-1]]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
YARD::Handlers::Ruby::MacroHandler::IGNORE_METHODS['Value'] = true
|
data/test/unit/value/yard-1.0.rb
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
require 'value/yard-1.0'
|
4
|
-
|
5
|
-
Expectations do
|
6
|
-
expect [YARD::CodeObjects::Proxy.new(:root, 'Value')] do
|
7
|
-
YARD::Registry.clear
|
8
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
9
|
-
class A
|
10
|
-
# @param [String] a
|
11
|
-
# @param [Integer] b The b
|
12
|
-
Value(:a, :b)
|
13
|
-
end
|
14
|
-
EOS
|
15
|
-
YARD::Registry.at('A').mixins(:instance)
|
16
|
-
end
|
17
|
-
|
18
|
-
expect 'Represents As.' do
|
19
|
-
YARD::Registry.clear
|
20
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
21
|
-
class A
|
22
|
-
# Represents As.
|
23
|
-
Value(:a, :b)
|
24
|
-
end
|
25
|
-
EOS
|
26
|
-
YARD::Registry.at('A#initialize').docstring
|
27
|
-
end
|
28
|
-
|
29
|
-
expect [['a', nil], ['b', '3']] do
|
30
|
-
YARD::Registry.clear
|
31
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
32
|
-
class A
|
33
|
-
Value(:a, [:b, 3])
|
34
|
-
end
|
35
|
-
EOS
|
36
|
-
YARD::Registry.at('A#initialize').parameters
|
37
|
-
end
|
38
|
-
|
39
|
-
expect [:b, :initialize] do
|
40
|
-
YARD::Registry.clear
|
41
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
42
|
-
class A
|
43
|
-
# @param [String] a
|
44
|
-
# @param [Integer] b The b
|
45
|
-
Value(:a, :b)
|
46
|
-
end
|
47
|
-
EOS
|
48
|
-
YARD::Registry.all(:method).map(&:name).sort
|
49
|
-
end
|
50
|
-
|
51
|
-
expect [:b, :initialize] do
|
52
|
-
YARD::Registry.clear
|
53
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
54
|
-
class A
|
55
|
-
# @param [String] a
|
56
|
-
# @param [Integer] *b The b
|
57
|
-
Value(:a, :'*b')
|
58
|
-
end
|
59
|
-
EOS
|
60
|
-
YARD::Registry.all(:method).map(&:name).sort
|
61
|
-
end
|
62
|
-
|
63
|
-
expect [:b, :initialize] do
|
64
|
-
YARD::Registry.clear
|
65
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
66
|
-
class A
|
67
|
-
# @param [String] a
|
68
|
-
# @param [Integer] &b The b
|
69
|
-
Value(:a, :'&b')
|
70
|
-
end
|
71
|
-
EOS
|
72
|
-
YARD::Registry.all(:method).map(&:name).sort
|
73
|
-
end
|
74
|
-
|
75
|
-
expect nil do
|
76
|
-
YARD::Registry.clear
|
77
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
78
|
-
class A
|
79
|
-
# @param [String] a
|
80
|
-
# @param [Integer] b The b
|
81
|
-
Value(:a, :b)
|
82
|
-
end
|
83
|
-
EOS
|
84
|
-
YARD::Registry.at('A#a')
|
85
|
-
end
|
86
|
-
|
87
|
-
expect '@return [Integer] The b' do
|
88
|
-
YARD::Registry.clear
|
89
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
90
|
-
class A
|
91
|
-
# @param [String] a
|
92
|
-
# @param [Integer] b The b
|
93
|
-
Value(:a, :b)
|
94
|
-
end
|
95
|
-
EOS
|
96
|
-
YARD::Registry.at('A#b').docstring.to_raw
|
97
|
-
end
|
98
|
-
|
99
|
-
expect %w'Value Value::Comparable Comparable' do
|
100
|
-
YARD::Registry.clear
|
101
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
102
|
-
class A
|
103
|
-
# @param [String] a
|
104
|
-
Value(:a, :comparable => true)
|
105
|
-
end
|
106
|
-
EOS
|
107
|
-
YARD::Registry.at('A').inheritance_tree(true)[1..3].map(&:path)
|
108
|
-
end
|
109
|
-
|
110
|
-
expect %w'Value Value::Comparable Comparable' do
|
111
|
-
YARD::Registry.clear
|
112
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
113
|
-
module A
|
114
|
-
# @param [String] a
|
115
|
-
Value(:a, :comparable => true)
|
116
|
-
end
|
117
|
-
class B
|
118
|
-
include A
|
119
|
-
# @param [String] a
|
120
|
-
# @param [String] b
|
121
|
-
Value(:a, :b, :comparable => true)
|
122
|
-
end
|
123
|
-
EOS
|
124
|
-
YARD::Registry.at('B').inheritance_tree(true)[1..3].map(&:path)
|
125
|
-
end
|
126
|
-
|
127
|
-
expect 'Comparisons between instances are made between a.' do
|
128
|
-
YARD::Registry.clear
|
129
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
130
|
-
class A
|
131
|
-
# This is A.
|
132
|
-
# @param [String] a
|
133
|
-
# @param [String] b
|
134
|
-
Value(:a, :b, :other => true, :comparable => [:a])
|
135
|
-
end
|
136
|
-
EOS
|
137
|
-
YARD::Registry.at('A#initialize').docstring.tag(:note).text
|
138
|
-
end
|
139
|
-
|
140
|
-
expect 'Comparisons between instances are made between a and b.' do
|
141
|
-
YARD::Registry.clear
|
142
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
143
|
-
class A
|
144
|
-
# @param [String] a
|
145
|
-
# @param [String] b
|
146
|
-
# @param [String] c
|
147
|
-
Value(:a, :b, :c, :comparable => [:a, :b])
|
148
|
-
end
|
149
|
-
EOS
|
150
|
-
YARD::Registry.at('A#initialize').docstring.tag(:note).text
|
151
|
-
end
|
152
|
-
|
153
|
-
expect 'Comparisons between instances are made between a, b, and c.' do
|
154
|
-
YARD::Registry.clear
|
155
|
-
YARD::Parser::SourceParser.parse_string(<<EOS)
|
156
|
-
class A
|
157
|
-
# @param [String] a
|
158
|
-
# @param [String] b
|
159
|
-
# @param [String] c
|
160
|
-
# @param [String] d
|
161
|
-
Value(:a, :b, :c, :d, :comparable => [:a, :b, :c])
|
162
|
-
end
|
163
|
-
EOS
|
164
|
-
YARD::Registry.at('A#initialize').docstring.tag(:note).text
|
165
|
-
end
|
166
|
-
end
|