diy 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/History.txt +3 -0
  2. data/Manifest.txt +53 -0
  3. data/README.txt +148 -0
  4. data/Rakefile +17 -0
  5. data/lib/diy.rb +249 -0
  6. data/test/diy_test.rb +482 -0
  7. data/test/files/broken_construction.yml +7 -0
  8. data/test/files/cat/cat.rb +4 -0
  9. data/test/files/cat/extra_conflict.yml +5 -0
  10. data/test/files/cat/heritage.rb +2 -0
  11. data/test/files/cat/needs_input.yml +3 -0
  12. data/test/files/cat/the_cat_lineage.rb +1 -0
  13. data/test/files/dog/dog_model.rb +4 -0
  14. data/test/files/dog/dog_presenter.rb +4 -0
  15. data/test/files/dog/dog_view.rb +2 -0
  16. data/test/files/dog/file_resolver.rb +2 -0
  17. data/test/files/dog/other_thing.rb +2 -0
  18. data/test/files/dog/simple.yml +11 -0
  19. data/test/files/donkey/foo.rb +8 -0
  20. data/test/files/donkey/foo/bar/qux.rb +7 -0
  21. data/test/files/fud/objects.yml +13 -0
  22. data/test/files/fud/toy.rb +15 -0
  23. data/test/files/gnu/objects.yml +14 -0
  24. data/test/files/gnu/thinger.rb +8 -0
  25. data/test/files/goat/base.rb +8 -0
  26. data/test/files/goat/can.rb +6 -0
  27. data/test/files/goat/goat.rb +6 -0
  28. data/test/files/goat/objects.yml +12 -0
  29. data/test/files/goat/paper.rb +6 -0
  30. data/test/files/goat/plane.rb +8 -0
  31. data/test/files/goat/shirt.rb +6 -0
  32. data/test/files/goat/wings.rb +8 -0
  33. data/test/files/horse/holder_thing.rb +4 -0
  34. data/test/files/horse/objects.yml +7 -0
  35. data/test/files/non_singleton/air.rb +2 -0
  36. data/test/files/non_singleton/fat_cat.rb +4 -0
  37. data/test/files/non_singleton/objects.yml +19 -0
  38. data/test/files/non_singleton/pig.rb +4 -0
  39. data/test/files/non_singleton/thread_spinner.rb +4 -0
  40. data/test/files/non_singleton/tick.rb +4 -0
  41. data/test/files/non_singleton/yard.rb +2 -0
  42. data/test/files/yak/core_model.rb +4 -0
  43. data/test/files/yak/core_presenter.rb +4 -0
  44. data/test/files/yak/core_view.rb +1 -0
  45. data/test/files/yak/data_source.rb +1 -0
  46. data/test/files/yak/fringe_model.rb +4 -0
  47. data/test/files/yak/fringe_presenter.rb +4 -0
  48. data/test/files/yak/fringe_view.rb +1 -0
  49. data/test/files/yak/giant_squid.rb +4 -0
  50. data/test/files/yak/krill.rb +2 -0
  51. data/test/files/yak/my_objects.yml +21 -0
  52. data/test/files/yak/sub_sub_context_test.yml +27 -0
  53. data/test/test_helper.rb +38 -0
  54. metadata +118 -0
@@ -0,0 +1,7 @@
1
+
2
+ dog_presenter:
3
+ model: dog_model
4
+ view: dog_view
5
+
6
+ dog_model:
7
+ # VIEW IS MISSING, PRESENTER SHOULD CRASH
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class Cat
3
+ constructor :heritage, :food, :strict => true, :accessors => true
4
+ end
@@ -0,0 +1,5 @@
1
+ the_cat_lineage:
2
+
3
+ cat:
4
+ heritage: the_cat_lineage
5
+ food: some_meat
@@ -0,0 +1,2 @@
1
+ class Heritage
2
+ end
@@ -0,0 +1,3 @@
1
+ cat:
2
+ heritage: the_cat_lineage
3
+ food: some_meat
@@ -0,0 +1 @@
1
+ class TheCatLineage; end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class DogModel
3
+ constructor :file_resolver, :other_thing, :strict => true, :accessors => true
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class DogPresenter
3
+ constructor :model, :view, :strict => true, :accessors => true
4
+ end
@@ -0,0 +1,2 @@
1
+ class DogView
2
+ end
@@ -0,0 +1,2 @@
1
+ class FileResolver
2
+ end
@@ -0,0 +1,2 @@
1
+ class OtherThing
2
+ end
@@ -0,0 +1,11 @@
1
+ dog_presenter:
2
+ model: dog_model
3
+ view: dog_view
4
+
5
+ file_resolver:
6
+ other_thing:
7
+
8
+ dog_model:
9
+ compose: file_resolver, other_thing
10
+
11
+ dog_view:
@@ -0,0 +1,8 @@
1
+
2
+ module DiyTesting
3
+ module Bar
4
+ class Foo
5
+ end
6
+ end
7
+ end
8
+
@@ -0,0 +1,7 @@
1
+
2
+ module Foo
3
+ module Bar
4
+ class Qux
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ widget:
2
+ lib: toy
3
+
4
+ trinket:
5
+ lib: toy
6
+ compose: thing_ama_jack
7
+
8
+ thing_ama_jack:
9
+ lib: toy
10
+
11
+ toy:
12
+ lib: toy
13
+ compose: widget, trinket
@@ -0,0 +1,15 @@
1
+ require 'constructor'
2
+
3
+ class Toy
4
+ constructor :widget, :trinket, :accessors => true, :strict => true
5
+ end
6
+
7
+ class Widget
8
+ end
9
+
10
+ class ThingAmaJack
11
+ end
12
+
13
+ class Trinket
14
+ constructor :thing_ama_jack, :accessors => true, :strict => true
15
+ end
@@ -0,0 +1,14 @@
1
+
2
+ injected:
3
+
4
+ thinger:
5
+ compose: injected
6
+
7
+ +inny:
8
+ inner_injected:
9
+
10
+ inner_thinger:
11
+ injected: inner_injected
12
+ lib: thinger
13
+ class: Thinger
14
+
@@ -0,0 +1,8 @@
1
+
2
+ require 'constructor'
3
+
4
+ class Thinger
5
+ constructor :injected
6
+ attr_reader :injected
7
+ end
8
+
@@ -0,0 +1,8 @@
1
+ class Base
2
+ def test_output(name)
3
+ # See diy_context_test.rb
4
+ File.open($goat_test_output_file, "a") do |f|
5
+ f.puts "#{name} built"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ require 'base'
2
+ class Can < Base
3
+ def initialize
4
+ test_output "can"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require 'base'
2
+ class Goat < Base
3
+ def initialize
4
+ test_output "goat"
5
+ end
6
+ end
@@ -0,0 +1,12 @@
1
+ can:
2
+
3
+ paper:
4
+
5
+ shirt:
6
+
7
+ goat:
8
+
9
+ +the_sub_context:
10
+ plane:
11
+ compose: wings
12
+ wings:
@@ -0,0 +1,6 @@
1
+ require 'base'
2
+ class Paper < Base
3
+ def initialize
4
+ test_output "paper"
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ require 'base'
2
+ require 'constructor'
3
+ class Plane < Base
4
+ constructor :wings, :strict => true
5
+ def setup
6
+ test_output "plane"
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ require 'base'
2
+ class Shirt < Base
3
+ def initialize
4
+ test_output "shirt"
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+ require 'base'
2
+ class Wings < Base
3
+ def initialize
4
+ test_output "wings"
5
+ end
6
+ def stay_on; end
7
+ def fall_off; end
8
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class HolderThing
3
+ constructor :thing_held, :strict => true, :accessors => true
4
+ end
@@ -0,0 +1,7 @@
1
+ holder_thing:
2
+ thing_held: this_context
3
+
4
+ +repeater:
5
+ other_thing:
6
+ class: HolderThing
7
+ thing_held: this_context
@@ -0,0 +1,2 @@
1
+ class Air
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class FatCat
3
+ constructor :thread_spinner, :tick, :yard, :accessors => true
4
+ end
@@ -0,0 +1,19 @@
1
+ air:
2
+
3
+ thread_spinner:
4
+ compose: air
5
+ singleton: false
6
+
7
+ yard:
8
+
9
+ pig:
10
+ compose: thread_spinner, yard
11
+
12
+ +inner_sanctum:
13
+ tick:
14
+ compose: thread_spinner
15
+ singleton: false
16
+
17
+ fat_cat:
18
+ compose: thread_spinner, tick, yard
19
+
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class Pig
3
+ constructor :thread_spinner, :yard, :accessors => true
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class ThreadSpinner
3
+ constructor :air, :accessors => true
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class Tick
3
+ constructor :thread_spinner, :accessors => true
4
+ end
@@ -0,0 +1,2 @@
1
+ class Yard
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class CoreModel
3
+ constructor :data_source, :strict => true
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class CorePresenter
3
+ constructor :model, :view, :strict => true
4
+ end
@@ -0,0 +1 @@
1
+ class CoreView; end
@@ -0,0 +1 @@
1
+ class DataSource; end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class FringeModel
3
+ constructor :connected, :accessors => true, :strict => true
4
+ end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class FringePresenter
3
+ constructor :fringe_model, :fringe_view, :strict => true
4
+ end
@@ -0,0 +1 @@
1
+ class FringeView; end
@@ -0,0 +1,4 @@
1
+ require 'constructor'
2
+ class GiantSquid
3
+ constructor :fringe_view, :core_model, :krill, :accessors => true
4
+ end
@@ -0,0 +1,2 @@
1
+ class Krill
2
+ end
@@ -0,0 +1,21 @@
1
+
2
+ core_model:
3
+ compose: data_source
4
+
5
+ core_view:
6
+
7
+ core_presenter:
8
+ model: core_model
9
+ view: core_view
10
+
11
+ data_source:
12
+
13
+ +fringe_context:
14
+
15
+ fringe_model:
16
+ connected: core_model
17
+
18
+ fringe_view:
19
+
20
+ fringe_presenter:
21
+ compose: fringe_model, fringe_view
@@ -0,0 +1,27 @@
1
+
2
+ core_model:
3
+ compose: data_source
4
+
5
+ core_view:
6
+
7
+ core_presenter:
8
+ model: core_model
9
+ view: core_view
10
+
11
+ data_source:
12
+
13
+ +fringe_context:
14
+
15
+ fringe_model:
16
+ connected: core_model
17
+
18
+ fringe_view:
19
+
20
+ fringe_presenter:
21
+ compose: fringe_model, fringe_view
22
+
23
+ +deep_context:
24
+ krill:
25
+
26
+ giant_squid:
27
+ compose: fringe_view, core_model, krill
@@ -0,0 +1,38 @@
1
+ here = File.expand_path(File.dirname(__FILE__))
2
+ PROJ_ROOT = File.expand_path("#{here}/..")
3
+ $: << "#{PROJ_ROOT}/lib"
4
+ require 'test/unit'
5
+ require 'fileutils'
6
+ require 'find'
7
+ require 'yaml'
8
+ require 'ostruct'
9
+
10
+ class Test::Unit::TestCase
11
+ include FileUtils
12
+
13
+ def path_to(file)
14
+ File.expand_path(File.dirname(__FILE__)) + file
15
+ end
16
+
17
+ def not_done
18
+ flunk "IMPLEMENT ME"
19
+ end
20
+ alias :implement_me :not_done
21
+
22
+ def poll(time_limit)
23
+ (time_limit * 10).to_i.times do
24
+ return true if yield
25
+ sleep 0.1
26
+ end
27
+ return false
28
+ end
29
+
30
+ def self.method_added(msym)
31
+ # Prevent duplicate test methods
32
+ if msym.to_s =~ /^test_/
33
+ @_tracked_tests ||= {}
34
+ raise "Duplicate test #{msym}" if @_tracked_tests[msym]
35
+ @_tracked_tests[msym] = true
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: diy
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-11-20 00:00:00 -05:00
8
+ summary: Constructor-based dependency injection container using YAML input.
9
+ require_paths:
10
+ - lib
11
+ email: dev@atomicobject.com
12
+ homepage:
13
+ rubyforge_project: atomicobjectrb
14
+ description: "== DESCRIPTION: DIY (Dependency Injection in Yaml) is a simple dependency injection library which focuses on declarative composition of objects through constructor injection. Currently, all objects that get components put into them must have a constructor that gets a hash with symbols as keys. Best used with constructor.rb Auto-naming and auto-library support is done."
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Atomic Object
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - lib/diy.rb
37
+ - test/diy_test.rb
38
+ - test/files/broken_construction.yml
39
+ - test/files/cat/cat.rb
40
+ - test/files/cat/extra_conflict.yml
41
+ - test/files/cat/heritage.rb
42
+ - test/files/cat/needs_input.yml
43
+ - test/files/cat/the_cat_lineage.rb
44
+ - test/files/dog/dog_model.rb
45
+ - test/files/dog/dog_presenter.rb
46
+ - test/files/dog/dog_view.rb
47
+ - test/files/dog/file_resolver.rb
48
+ - test/files/dog/other_thing.rb
49
+ - test/files/dog/simple.yml
50
+ - test/files/donkey/foo.rb
51
+ - test/files/donkey/foo/bar/qux.rb
52
+ - test/files/fud/objects.yml
53
+ - test/files/fud/toy.rb
54
+ - test/files/gnu/objects.yml
55
+ - test/files/gnu/thinger.rb
56
+ - test/files/goat/base.rb
57
+ - test/files/goat/can.rb
58
+ - test/files/goat/goat.rb
59
+ - test/files/goat/objects.yml
60
+ - test/files/goat/paper.rb
61
+ - test/files/goat/plane.rb
62
+ - test/files/goat/shirt.rb
63
+ - test/files/goat/wings.rb
64
+ - test/files/horse/holder_thing.rb
65
+ - test/files/horse/objects.yml
66
+ - test/files/non_singleton/air.rb
67
+ - test/files/non_singleton/fat_cat.rb
68
+ - test/files/non_singleton/objects.yml
69
+ - test/files/non_singleton/pig.rb
70
+ - test/files/non_singleton/thread_spinner.rb
71
+ - test/files/non_singleton/tick.rb
72
+ - test/files/non_singleton/yard.rb
73
+ - test/files/yak/core_model.rb
74
+ - test/files/yak/core_presenter.rb
75
+ - test/files/yak/core_view.rb
76
+ - test/files/yak/data_source.rb
77
+ - test/files/yak/fringe_model.rb
78
+ - test/files/yak/fringe_presenter.rb
79
+ - test/files/yak/fringe_view.rb
80
+ - test/files/yak/giant_squid.rb
81
+ - test/files/yak/krill.rb
82
+ - test/files/yak/my_objects.yml
83
+ - test/files/yak/sub_sub_context_test.yml
84
+ - test/test_helper.rb
85
+ test_files:
86
+ - test/diy_test.rb
87
+ rdoc_options:
88
+ - --main
89
+ - README.txt
90
+ extra_rdoc_files:
91
+ - History.txt
92
+ - Manifest.txt
93
+ - README.txt
94
+ executables: []
95
+
96
+ extensions: []
97
+
98
+ requirements: []
99
+
100
+ dependencies:
101
+ - !ruby/object:Gem::Dependency
102
+ name: constructor
103
+ version_requirement:
104
+ version_requirements: !ruby/object:Gem::Version::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.0.0
109
+ version:
110
+ - !ruby/object:Gem::Dependency
111
+ name: hoe
112
+ version_requirement:
113
+ version_requirements: !ruby/object:Gem::Version::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 1.3.0
118
+ version: