micon 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake_ext'
3
3
  project(
4
4
  name: "micon",
5
5
  gem: true,
6
- summary: "Silent and invisible Killer of dependencies and configs",
6
+ summary: "Silent killer of dependencies and configs",
7
7
 
8
8
  author: "Alexey Petrushin",
9
9
  homepage: "http://github.com/alexeypetrushin/micon"
data/lib/micon/core.rb CHANGED
@@ -244,7 +244,7 @@ class Micon::Core
244
244
  end
245
245
 
246
246
  # Micon::Core is independent itself and there can be multiple Cores simultaneously.
247
- # But some of it's extensions can work only with one global instance, and them need to know how to get it,
247
+ # But some of its extensions can work only with one global instance, and them need to know how to get it,
248
248
  # the MICON constant references this global instance.
249
249
  Object.send(:remove_const, :MICON) if Object.const_defined?(:MICON)
250
250
  Object.const_set :MICON, self
@@ -296,7 +296,7 @@ class Micon::Core
296
296
  initializer, dependencies, config = @metadata.initializers[key]
297
297
  raise "no initializer for :#{key} component!" unless initializer
298
298
 
299
- raise "component :#{key} used before it's initialization is finished!" if @stack.include? key
299
+ raise "component :#{key} used before its initialization is finished!" if @stack.include? key
300
300
  begin
301
301
  dependencies.each{|d| self[d]}
302
302
  @metadata.call_before key
data/lib/micon/support.rb CHANGED
@@ -13,19 +13,4 @@ class Hash
13
13
  r
14
14
  end
15
15
  end
16
- end
17
-
18
- # class Module
19
- # unless respond_to? :namespace_for
20
- # # TODO3 cache it?
21
- # def self.namespace_for class_name
22
- # list = class_name.split("::")
23
- # if list.size > 1
24
- # list.pop
25
- # return eval(list.join("::"), TOPLEVEL_BINDING, __FILE__, __LINE__)
26
- # else
27
- # return nil
28
- # end
29
- # end
30
- # end
31
- # end
16
+ end
data/readme.md CHANGED
@@ -1,6 +1,6 @@
1
- # Micon - silent and invisible Killer of dependencies and configs
1
+ # Micon - silent killer of dependencies and configs
2
2
 
3
- Micon allows You easilly and transparently eliminate dependencies and configs in Your Application. Usually, when You are building complex system there are following tasks should be solved:
3
+ Micon allows You easilly and transparently eliminate dependencies and configs. Usually, when You are building complex system there are following tasks should be solved:
4
4
 
5
5
  - where the component's code is located
6
6
  - in what order should it be loaded
@@ -18,23 +18,22 @@ Micon allows You easilly and transparently eliminate dependencies and configs in
18
18
 
19
19
  Micon **solves all these tasks automatically**, and has the following **price** - You has to:
20
20
 
21
- - use the *register component_name, &initialization_block* method for component initialization
22
- - use the *inject component_name* to whire components toghether
23
- - place component definition to the lib/components folder
21
+ - use the *register(component_name, &initialization_block)* method for component initialization
22
+ - use the *inject(component_name)* to whire components toghether
23
+ - place component definitions to the "lib/components" folder
24
24
 
25
25
  That's all the price, not a big one, compared to the value, eh?
26
26
  That all You need to know to use 95% of it, there are also 2-3 more specific methods, but they are needed very rarelly.
27
27
 
28
- Techincally Micon is sort of Dependency Injector, but because of it's simplicity and invisibility it looks like an alien compared to it's complex and bloated IoC / DI cousins.
28
+ Techincally Micon is sort of Dependency Injector, but because of its simplicity and invisibility it looks like an alien compared to its complex and bloated IoC / DI cousins.
29
29
 
30
30
  ## Basic example
31
31
 
32
32
  ``` ruby
33
33
  require 'micon'
34
- # standard ruby logger
35
- require 'logger'
34
+ require 'logger' # standard ruby logger
36
35
 
37
- micon.register(:logger){Logger.new}
36
+ micon.register(:logger){Logger.new STDOUT}
38
37
 
39
38
  class Application
40
39
  inject logger: :logger
@@ -44,21 +43,28 @@ class Application
44
43
  end
45
44
  end
46
45
 
47
- Application.new.run # => running ...
46
+ Application.new.run
47
+ # You should see something like this in the console:
48
+ # [2011-08-16T19:09:05.921238 #24944] INFO -- : running ...
48
49
  ```
49
50
 
50
51
  Code in examples/basics.rb
51
52
 
52
- ## Advanced example: let's build the Ultima - an Ultimate Web Framework
53
+ ## Advanced example: let's build Web Framework
53
54
 
54
55
  This example is more complicated and requires about 3-7 minutes.
55
56
 
56
- Let's pretend that we are building an Ultimate Framework, the RoR Killer. There will be lot's of modules and dependencies, let's see how Micon can eliminate them.
57
- There will be two steps, at the first we'll build it as usual, and at the second refactor it using Micon.
57
+ Let's pretend that we are building an Ultimate Framework, the RoR Killer. There will be lot's of modules and dependencies, let's see how Micon can eliminate them. There will be only two components: router, request.
58
+ Let's build it in two steps, at the first we'll build it as usual, and at the second refactor it using Micon.
58
59
 
59
- There will be following components: router, request.
60
+ First step, building our framework **without Micon**.
60
61
 
61
62
  ``` ruby
63
+ # setting load paths
64
+ dir = File.dirname __FILE__
65
+ $LOAD_PATH << "#{dir}/lib"
66
+
67
+
62
68
  # Assembling Ultima Framework
63
69
  module Ultima
64
70
  class << self
@@ -76,14 +82,17 @@ module Ultima
76
82
  end
77
83
  end
78
84
 
85
+ # reading application config
79
86
  require 'yaml'
80
87
  Ultima.config = YAML.load_file "#{dir}/config/config.yml"
81
88
 
89
+ # initializing router
82
90
  require 'router'
83
91
  router = Router.new
84
92
  router.url_root = Ultima.config['url_root']
85
93
  Ultima.router = router
86
94
 
95
+ # loading request and controller
87
96
  require 'request'
88
97
  require 'controller'
89
98
 
@@ -102,7 +111,7 @@ Ultima.run '/index'
102
111
 
103
112
  Code in examples/ultima1/run.rb
104
113
 
105
- Below are the same example but done with Micon. As You can see there's no any assembling or configuration code, because all the components are auto-discovered, auto-loaded and auto-configured.
114
+ Below are the same example but refactored **with using Micon**. As You can see there's no any assembling or configuration code, because all the components are auto-discovered, auto-loaded and auto-configured.
106
115
 
107
116
  ``` ruby
108
117
  # Assembling Ultima Framework
@@ -24,7 +24,7 @@ describe "Miscellaneous" do
24
24
  micon[:kit]
25
25
  'kit'
26
26
  end
27
- lambda{micon[:kit]}.should raise_error(/component :kit used before it's initialization is finished/)
27
+ lambda{micon[:kit]}.should raise_error(/component :kit used before its initialization is finished/)
28
28
  end
29
29
 
30
30
  it "should not initialize twice if called from dependency (from error)" do
@@ -37,7 +37,7 @@ describe "Miscellaneous" do
37
37
  'router'
38
38
  end
39
39
 
40
- -> {micon[:router]}.should raise_error(/component .* used before it's initialization is finished/)
40
+ -> {micon[:router]}.should raise_error(/component .* used before its initialization is finished/)
41
41
  end
42
42
 
43
43
  it "should allow to use circullar dependency in :after callback" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: micon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-16 00:00:00.000000000Z
12
+ date: 2011-09-22 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email:
@@ -70,5 +70,5 @@ rubyforge_project:
70
70
  rubygems_version: 1.8.6
71
71
  signing_key:
72
72
  specification_version: 3
73
- summary: Silent and invisible Killer of dependencies and configs
73
+ summary: Silent killer of dependencies and configs
74
74
  test_files: []