value 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require 'inventory/rake/tasks'
4
- require 'lookout/rake/tasks'
3
+ require 'inventory/rake/tasks-1.0'
4
+ require 'lookout/rake/tasks-3.0'
5
5
 
6
6
  $:.unshift File.expand_path('../lib', __FILE__)
7
7
  require 'value/version'
@@ -11,9 +11,10 @@ Inventory::Rake::Tasks.define Value::Version, :gem => proc{ |_, s|
11
11
  s.email = 'now@bitwi.se'
12
12
  s.homepage = 'https://github.com/now/value'
13
13
 
14
+ s.add_development_dependency 'lookout', '~> 3.0'
14
15
  s.add_development_dependency 'yard', '~> 0.7.0'
15
16
 
16
- s.add_runtime_dependency 'inventory', '~> 0.2.0'
17
+ s.add_runtime_dependency 'inventory', '~> 1.0'
17
18
  }
18
19
 
19
20
  # TODO: Silence warnings generated from YARD (remove this once we plug them)
data/lib/value/version.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require 'inventory'
3
+ require 'inventory-1.0'
4
4
 
5
5
  module Value
6
- Version = Inventory.new(0, 2, 0){
6
+ Version = Inventory.new(1, 0, 0){
7
7
  def libs
8
8
  %w'
9
9
  value/comparable.rb
@@ -14,7 +14,7 @@ module Value
14
14
  def additional_libs
15
15
  super +
16
16
  %w'
17
- value/yard.rb
17
+ value/yard-1.0.rb
18
18
  '
19
19
  end
20
20
  }
@@ -10,18 +10,20 @@ class YARD::Handlers::Ruby::ValuesHandler < YARD::Handlers::Ruby::Base
10
10
  parameters = statement.parameters(false)
11
11
  if YARD::Parser::Ruby::AstNode === parameters[-1][0] and
12
12
  parameters[-1][0].type == :assoc and
13
- parameters[-1].jump(:ident).source == 'comparable'
13
+ comparable = parameters[-1].find{ |e| e.jump(:ident).source == 'comparable' }
14
14
  parameters.pop
15
+ comparables = (comparable[1].type == :array and comparable[1][0].map{ |e| e.jump(:ident).source })
15
16
  ancestor 'Comparable'
16
17
  ancestor 'Value::Comparable'
17
18
  end
18
19
  ancestor 'Value'
19
- define('initialize', parameters.map{ |e| [e.jump(:ident).source, e.type == :array ? e[0][1].source : nil] }).
20
- docstring.tags(:param).select{ |e| e.text and not e.text.empty? }.each do |e|
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|
21
22
  define e.name.sub(/\A[&*]/, ''), [],
22
- '@return [%s] %s' % [e.types.join(', '), e.text], :protected
23
+ '@return [%s] %s' % [e.types ? e.types.join(', ') : '', e.text], :protected
23
24
  e.text = ''
24
25
  end
26
+ initialize.docstring.add_tag(YARD::Tags::Tag.new(:note, 'Comparisons between instances are made between %s.' % join(comparables))) if comparables
25
27
  end
26
28
 
27
29
  def ancestor(name)
@@ -42,6 +44,12 @@ class YARD::Handlers::Ruby::ValuesHandler < YARD::Handlers::Ruby::Base
42
44
  m.visibility = visibility
43
45
  }
44
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
45
53
  end
46
54
 
47
55
  YARD::Handlers::Ruby::MacroHandler::IGNORE_METHODS['Value'] = true
File without changes
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
- require 'value/yard'
3
+ require 'value/yard-1.0'
4
4
 
5
5
  Expectations do
6
6
  expect [YARD::CodeObjects::Proxy.new(:root, 'Value')] do
@@ -104,7 +104,7 @@ class A
104
104
  Value(:a, :comparable => true)
105
105
  end
106
106
  EOS
107
- YARD::Registry.at('A').inheritance_tree(true)[1..3].map(&:path)
107
+ YARD::Registry.at('A').inheritance_tree(true)[1..3].map(&:path)
108
108
  end
109
109
 
110
110
  expect %w'Value Value::Comparable Comparable' do
@@ -121,6 +121,46 @@ class B
121
121
  Value(:a, :b, :comparable => true)
122
122
  end
123
123
  EOS
124
- YARD::Registry.at('B').inheritance_tree(true)[1..3].map(&:path)
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
125
165
  end
126
166
  end
File without changes
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: 0.2.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-23 00:00:00.000000000 Z
12
+ date: 2012-04-25 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: lookout
16
+ requirement: &14302368 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *14302368
14
25
  - !ruby/object:Gem::Dependency
15
26
  name: yard
16
- requirement: &2152363560 !ruby/object:Gem::Requirement
27
+ requirement: &14303892 !ruby/object:Gem::Requirement
17
28
  none: false
18
29
  requirements:
19
30
  - - ~>
@@ -21,18 +32,18 @@ dependencies:
21
32
  version: 0.7.0
22
33
  type: :development
23
34
  prerelease: false
24
- version_requirements: *2152363560
35
+ version_requirements: *14303892
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: inventory
27
- requirement: &2152363060 !ruby/object:Gem::Requirement
38
+ requirement: &13859280 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ~>
31
42
  - !ruby/object:Gem::Version
32
- version: 0.2.0
43
+ version: '1.0'
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *2152363060
46
+ version_requirements: *13859280
36
47
  description: ! " Value\n\n Value is a library
37
48
  for defining value objects in Ruby.\n"
38
49
  email: now@bitwi.se
@@ -42,18 +53,19 @@ extra_rdoc_files: []
42
53
  files:
43
54
  - lib/value/comparable.rb
44
55
  - lib/value/values.rb
45
- - lib/value.rb
56
+ - lib/value-1.0.rb
46
57
  - lib/value/version.rb
47
- - lib/value/yard.rb
58
+ - lib/value/yard-1.0.rb
48
59
  - test/unit/value/comparable.rb
49
60
  - test/unit/value/values.rb
50
- - test/unit/value.rb
61
+ - test/unit/value-1.0.rb
51
62
  - test/unit/value/version.rb
52
- - test/unit/value/yard.rb
63
+ - test/unit/value/yard-1.0.rb
53
64
  - README
54
65
  - Rakefile
55
66
  homepage: https://github.com/now/value
56
67
  licenses: []
68
+ metadata: {}
57
69
  post_install_message:
58
70
  rdoc_options: []
59
71
  require_paths:
@@ -72,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
84
  version: '0'
73
85
  requirements: []
74
86
  rubyforge_project:
75
- rubygems_version: 1.8.11
87
+ rubygems_version: 1.8.10
76
88
  signing_key:
77
- specification_version: 3
89
+ specification_version: 4
78
90
  summary: Value is a library for defining value objects in Ruby.
79
91
  test_files: []