wirer 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,14 @@
1
- # dependency :foo, Class, :features => [:feature, :feature], :optional => true
2
- # dependency :foo, Class, :features => [:feature, :feature], :multiple => true
3
- #
4
- # dependency :foo, Class, :optional => true
5
- # dependency :foo, :feature, :another_feature, :optional => true, :constructor => true
6
-
7
1
  module Wirer
8
2
 
3
+
4
+ # Models a dependency, and has class methods for interpreting dsl-like argument
5
+ # lists that declare dependencies.
6
+ #
7
+ # dependency :foo, Class, :features => [:feature, :feature], :optional => true
8
+ # dependency :foo, Class, :features => [:feature, :feature], :multiple => true
9
+ #
10
+ # dependency :foo, Class, :optional => true
11
+ # dependency :foo, :feature, :another_feature, :optional => true, :constructor => true
9
12
  class Dependency
10
13
  def self.new_from_args(*args)
11
14
  new(normalise_args(*args))
data/lib/wirer/errors.rb CHANGED
@@ -1,24 +1,26 @@
1
- module Wirer
1
+ # coding: utf-8
2
2
 
3
+ module Wirer
3
4
  # Thank you to http://rubyforge.org/projects/nestegg for the pattern
4
5
  class Error < StandardError
5
-
6
6
  attr_reader :cause
7
- alias :wrapped_error :cause
7
+ alias_method :wrapped_error, :cause
8
8
 
9
- def initialize(msg, cause=nil)
9
+ def initialize(msg, cause = $ERROR_INFO)
10
10
  @cause = cause
11
- super(msg)
11
+ super(msg || cause && cause.message)
12
12
  end
13
13
 
14
14
  def set_backtrace(bt)
15
15
  if cause
16
+ cause.backtrace.reverse.each do |line|
17
+ bt.last == line ? bt.pop : break
18
+ end
16
19
  bt << "cause: #{cause.class.name}: #{cause}"
17
20
  bt.concat cause.backtrace
18
21
  end
19
22
  super(bt)
20
23
  end
21
-
22
24
  end
23
25
 
24
26
  class DependencyFindingError < Error; end
@@ -26,5 +28,4 @@ module Wirer
26
28
 
27
29
  # raised when a dependency could be found, but failed to be constructed.
28
30
  class DependencyConstructionError < Error; end
29
-
30
31
  end
@@ -29,9 +29,9 @@ module Wirer
29
29
  end
30
30
  end
31
31
 
32
- # A more convenient form of Wirer::Factory::ClassMixin, this additionally adds some
33
- # private DSL methods which let you declare your constructor_dependencies,
34
- # setter_dependencies and provides_features.
32
+ # A more convenient form of {Wirer::Factory::ClassMixin}, this additionally adds some
33
+ # private DSL methods which let you declare your {#constructor_dependencies},
34
+ # {#setter_dependencies} and {#provides_features}.
35
35
  #
36
36
  # The DSL works nicely with respect to subclassing, so you can add extra dependencies
37
37
  # or features in a subclass.
@@ -64,7 +64,9 @@ module Wirer
64
64
  deps_hash[arg_name] = Dependency.new_from_args(*dependency_args)
65
65
  end
66
66
 
67
- # as a convenience, will additionally define an attr_reader for this dependency name
67
+ # Declares a constructor dependency, also aliased as {#dependency}. See
68
+ # {Wirer::Dependency} for documentation on how to declare dependencies.
69
+ # As a convenience, will additionally define an attr_reader for this dependency name
68
70
  # unless you specify :getter => false. by default it will be private, but :getter => :public
69
71
  # will make it public.
70
72
  def constructor_dependency(name, *args)
@@ -88,7 +90,11 @@ module Wirer
88
90
  constructor_dependency(name, *args)
89
91
  end
90
92
 
91
- # will additionally define a attr_writer method of this name, unless :setter => false
93
+ # Delcare a setter dependency. Setter dependencies, as the name suggests,
94
+ # are given to an instance using a setter method, rather than passing it in
95
+ # to the constructor.
96
+ #
97
+ # It will additionally define a attr_writer method of this name, unless :setter => false
92
98
  # is specified. this is private by default but made public if you specify :setter => :public.
93
99
  #
94
100
  # and a corresponding public attr_reader too if :accessor => true if specified.
@@ -55,7 +55,7 @@ module Wirer
55
55
  # since this allows it to stay instance-sensitive. see #setter_dependencies.
56
56
  @extended_static_setter_dependencies ||= setter_dependencies
57
57
  else
58
- raise Error, "No constructor_dependency or static setter_dependency #{arg_name.inspect} found to extend on the wrapped factory"
58
+ raise Error, "No constructor_dependency or static setter_dependency #{dep_name.inspect} found to extend on the wrapped factory"
59
59
  end
60
60
  end
61
61
 
data/lib/wirer/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wirer
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
metadata CHANGED
@@ -1,142 +1,157 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wirer
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 5
9
- - 0
10
- version: 0.5.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Matthew Willson
14
9
  - Tom Chipchase
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-07-27 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
13
+ date: 2014-07-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
22
16
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
33
23
  type: :development
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: minitest
37
24
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: minitest
33
+ requirement: !ruby/object:Gem::Requirement
39
34
  none: false
40
- requirements:
35
+ requirements:
41
36
  - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 11
44
- segments:
45
- - 2
46
- - 1
47
- - 0
37
+ - !ruby/object:Gem::Version
48
38
  version: 2.1.0
49
39
  type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: mocha
53
40
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 2.1.0
47
+ - !ruby/object:Gem::Dependency
48
+ name: mocha
49
+ requirement: !ruby/object:Gem::Requirement
55
50
  none: false
56
- requirements:
51
+ requirements:
57
52
  - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 35
60
- segments:
61
- - 0
62
- - 9
63
- - 12
53
+ - !ruby/object:Gem::Version
64
54
  version: 0.9.12
65
55
  type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: 0.9.12
63
+ - !ruby/object:Gem::Dependency
68
64
  name: rcov
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 0.9.9
71
+ type: :development
69
72
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
73
+ version_requirements: !ruby/object:Gem::Requirement
71
74
  none: false
72
- requirements:
75
+ requirements:
73
76
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 41
76
- segments:
77
- - 0
78
- - 9
79
- - 9
77
+ - !ruby/object:Gem::Version
80
78
  version: 0.9.9
79
+ - !ruby/object:Gem::Dependency
80
+ name: yard
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: redcarpet
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
81
103
  type: :development
82
- version_requirements: *id004
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  description:
84
- email:
112
+ email:
85
113
  - matthew@playlouder.com
86
114
  - tom.chipchase@gmail.com
87
115
  executables: []
88
-
89
116
  extensions: []
90
-
91
117
  extra_rdoc_files: []
92
-
93
- files:
118
+ files:
94
119
  - lib/wirer.rb
95
- - lib/wirer/construction_session.rb
96
120
  - lib/wirer/version.rb
97
- - lib/wirer/service.rb
121
+ - lib/wirer/dependency.rb
122
+ - lib/wirer/construction_session.rb
98
123
  - lib/wirer/errors.rb
124
+ - lib/wirer/service.rb
99
125
  - lib/wirer/container.rb
126
+ - lib/wirer/factory/interface.rb
100
127
  - lib/wirer/factory/class_mixins.rb
101
128
  - lib/wirer/factory/curried_dependencies.rb
102
129
  - lib/wirer/factory/wrapped.rb
103
130
  - lib/wirer/factory/from_instance.rb
104
- - lib/wirer/factory/interface.rb
105
131
  - lib/wirer/factory/from_args.rb
106
- - lib/wirer/dependency.rb
107
132
  - README.rb
108
133
  homepage:
109
134
  licenses: []
110
-
111
135
  post_install_message:
112
136
  rdoc_options: []
113
-
114
- require_paths:
137
+ require_paths:
115
138
  - lib
116
- required_ruby_version: !ruby/object:Gem::Requirement
139
+ required_ruby_version: !ruby/object:Gem::Requirement
117
140
  none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- hash: 3
122
- segments:
123
- - 0
124
- version: "0"
125
- required_rubygems_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
146
  none: false
127
- requirements:
128
- - - ">="
129
- - !ruby/object:Gem::Version
130
- hash: 3
131
- segments:
132
- - 0
133
- version: "0"
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
134
151
  requirements: []
135
-
136
152
  rubyforge_project:
137
- rubygems_version: 1.8.24
153
+ rubygems_version: 1.8.23
138
154
  signing_key:
139
155
  specification_version: 3
140
156
  summary: A lightweight dependency injection framework to help wire up objects in Ruby
141
157
  test_files: []
142
-