dizzy 1.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/dizzy/core.rb +4 -0
- data/lib/dizzy/dsl.rb +56 -0
- data/lib/dizzy/rule.rb +13 -0
- data/lib/dizzy.rb +2 -0
- metadata +47 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c43df022ef1a289584a66cf8143b6ed7c850c4f
|
4
|
+
data.tar.gz: c9659f5c7095fe456c4770412bb521df44fa7ed9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3bb5848677977e34edc588055da8c6d65d4a44330c2cc19f9b9f607a76e23b7af1b821f4defda0546fc08df2b6542ca9c9e8e808047f17ecb3a297d5c5422857
|
7
|
+
data.tar.gz: 0f6526c2ba17d5a839a11eb78027bc38a1454e596e92b6db223deea744396089cc30d13088884269b77e402d231c169090c9d4e9a631f2c8ccc5da7125cfa2ae
|
data/lib/dizzy/core.rb
ADDED
data/lib/dizzy/dsl.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
|
2
|
+
require 'dizzy/core'
|
3
|
+
require 'dizzy/rule'
|
4
|
+
|
5
|
+
module Dizzy::DSL
|
6
|
+
|
7
|
+
class RuleContext
|
8
|
+
|
9
|
+
attr_reader :rule
|
10
|
+
|
11
|
+
def initialize(rule)
|
12
|
+
@rule = rule
|
13
|
+
end
|
14
|
+
|
15
|
+
def init(&block)
|
16
|
+
rule.init_proc = block
|
17
|
+
end
|
18
|
+
|
19
|
+
def wire(&block)
|
20
|
+
rule.wire_proc = block
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def di(name, clazz = nil, *args, &block)
|
26
|
+
___method_name = name.to_sym
|
27
|
+
___variable_name = "@#{name}".to_sym
|
28
|
+
|
29
|
+
|
30
|
+
rule = Dizzy::Rule.new
|
31
|
+
|
32
|
+
if clazz
|
33
|
+
rule.init_proc = lambda{ clazz.new(*args) }
|
34
|
+
rule.wire_proc = block || lambda{|x| }
|
35
|
+
else
|
36
|
+
rc = ::Dizzy::DSL::RuleContext.new(rule)
|
37
|
+
rc.instance_exec(&block)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
define_method ___method_name do
|
42
|
+
unless instance_variable_defined? ___variable_name
|
43
|
+
value = self.instance_exec(&rule.init_proc)
|
44
|
+
instance_variable_set(___variable_name, value)
|
45
|
+
|
46
|
+
self.instance_exec(value, &rule.wire_proc)
|
47
|
+
end
|
48
|
+
instance_variable_get(___variable_name)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
end
|
data/lib/dizzy/rule.rb
ADDED
data/lib/dizzy.rb
ADDED
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dizzy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lauber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Dependency Injection that won't make your head spin
|
14
|
+
email: constructible.truth@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/dizzy.rb
|
20
|
+
- lib/dizzy/core.rb
|
21
|
+
- lib/dizzy/dsl.rb
|
22
|
+
- lib/dizzy/rule.rb
|
23
|
+
homepage:
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata: {}
|
27
|
+
post_install_message:
|
28
|
+
rdoc_options: []
|
29
|
+
require_paths:
|
30
|
+
- lib
|
31
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '0'
|
36
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.3.1
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 2.2.2
|
44
|
+
signing_key:
|
45
|
+
specification_version: 4
|
46
|
+
summary: Dependency Injection that won't make your head spin
|
47
|
+
test_files: []
|