micon 0.1.24 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/micon.rb +5 -14
- data/lib/micon/class.rb +0 -8
- data/lib/micon/config.rb +1 -0
- data/lib/micon/core.rb +26 -1
- data/lib/micon/support.rb +17 -11
- data/spec/config_spec.rb +1 -0
- data/spec/spec_helper.rb +1 -4
- metadata +2 -4
- data/lib/micon/helper.rb +0 -23
- data/lib/micon/module.rb +0 -13
data/lib/micon.rb
CHANGED
@@ -1,22 +1,13 @@
|
|
1
|
-
require '
|
1
|
+
require 'micon/support'
|
2
2
|
|
3
3
|
module Micon
|
4
|
+
autoload :Metadata, 'micon/metadata'
|
5
|
+
autoload :Config, 'micon/config'
|
6
|
+
autoload :Core, 'micon/core'
|
7
|
+
autoload :Metadata, 'micon/metadata'
|
4
8
|
end
|
5
9
|
|
6
|
-
%w{
|
7
|
-
support
|
8
|
-
|
9
|
-
metadata
|
10
|
-
config
|
11
|
-
core
|
12
|
-
helper
|
13
|
-
|
14
|
-
module
|
15
|
-
class
|
16
|
-
}.each{|f| require "micon/#{f}"}
|
17
|
-
|
18
10
|
# Initializing Micon.
|
19
|
-
Micon::Core.send :include, Micon::Helper
|
20
11
|
micon = Micon::Core.new
|
21
12
|
micon.initialize!
|
22
13
|
|
data/lib/micon/class.rb
CHANGED
data/lib/micon/config.rb
CHANGED
data/lib/micon/core.rb
CHANGED
@@ -153,7 +153,6 @@ class Micon::Core
|
|
153
153
|
|
154
154
|
def register key, options = {}, &initializer
|
155
155
|
raise "key should not be nil or false value!" unless key
|
156
|
-
options = options.symbolize_keys
|
157
156
|
|
158
157
|
sname = options.delete(:scope) || :application
|
159
158
|
dependencies = Array(options.delete(:require) || options.delete(:depends_on))
|
@@ -359,4 +358,30 @@ class Micon::Core
|
|
359
358
|
""
|
360
359
|
end
|
361
360
|
end
|
361
|
+
|
362
|
+
def raise_without_self message
|
363
|
+
raise RuntimeError, message, caller.select{|path| path !~ /\/lib\/micon\//}
|
364
|
+
end
|
365
|
+
|
366
|
+
# Generates helper methods, so you can use `micon.logger` instead of `micon[:logger]`
|
367
|
+
def method_missing m, *args, &block
|
368
|
+
super if args.size > 1 or block
|
369
|
+
|
370
|
+
key = m.to_s.sub(/[?=]$/, '').to_sym
|
371
|
+
self.class.class_eval do
|
372
|
+
define_method key do
|
373
|
+
self[key]
|
374
|
+
end
|
375
|
+
|
376
|
+
define_method "#{key}=" do |value|
|
377
|
+
self[key] = value
|
378
|
+
end
|
379
|
+
|
380
|
+
define_method "#{key}?" do
|
381
|
+
include? key
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
385
|
+
send m, *args
|
386
|
+
end
|
362
387
|
end
|
data/lib/micon/support.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
|
-
class
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Class
|
2
|
+
# Usage:
|
3
|
+
# register_as :session, scope: :request
|
4
|
+
# register_as :loggger
|
5
|
+
def register_as *args
|
6
|
+
::MICON.register(*args){self.new}
|
7
|
+
end
|
6
8
|
end
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
Module.class_eval do
|
11
|
+
# Usage: `inject logger: :logger`.
|
12
|
+
def inject attributes
|
13
|
+
::MICON.raise_without_self "Invalid argument!" unless attributes.is_a? Hash
|
14
|
+
attributes.each do |name, specificator|
|
15
|
+
::MICON.raise_without_self "Attribute name should be a Symbol!" unless name.is_a? Symbol
|
16
|
+
|
17
|
+
define_method(name){::MICON[specificator]}
|
18
|
+
define_method("#{name}="){|value| ::MICON[specificator] = value}
|
19
|
+
define_method("#{name}?"){::MICON.include? specificator}
|
14
20
|
end
|
15
21
|
end
|
16
22
|
end
|
data/spec/config_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.1.25
|
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-10-
|
12
|
+
date: 2011-10-27 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -22,9 +22,7 @@ files:
|
|
22
22
|
- lib/micon/class.rb
|
23
23
|
- lib/micon/config.rb
|
24
24
|
- lib/micon/core.rb
|
25
|
-
- lib/micon/helper.rb
|
26
25
|
- lib/micon/metadata.rb
|
27
|
-
- lib/micon/module.rb
|
28
26
|
- lib/micon/spec.rb
|
29
27
|
- lib/micon/support.rb
|
30
28
|
- lib/micon.rb
|
data/lib/micon/helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# Generates helper methods for Micon, so you can use micon.logger instead of micon[:logger]
|
2
|
-
module Micon::Helper
|
3
|
-
def method_missing m, *args, &block
|
4
|
-
super if args.size > 1 or block
|
5
|
-
|
6
|
-
key = m.to_s.sub(/[?=]$/, '').to_sym
|
7
|
-
self.class.class_eval do
|
8
|
-
define_method key do
|
9
|
-
self[key]
|
10
|
-
end
|
11
|
-
|
12
|
-
define_method "#{key}=" do |value|
|
13
|
-
self[key] = value
|
14
|
-
end
|
15
|
-
|
16
|
-
define_method "#{key}?" do
|
17
|
-
include? key
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
send m, *args
|
22
|
-
end
|
23
|
-
end
|
data/lib/micon/module.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
Module.class_eval do
|
2
|
-
# Usage: `inject logger: :logger`.
|
3
|
-
def inject attributes
|
4
|
-
::MICON.raise_without_self "Invalid argument!" unless attributes.is_a? Hash
|
5
|
-
attributes.each do |name, specificator|
|
6
|
-
::MICON.raise_without_self "Attribute name should be a Symbol!" unless name.is_a? Symbol
|
7
|
-
|
8
|
-
define_method(name){::MICON[specificator]}
|
9
|
-
define_method("#{name}="){|value| ::MICON[specificator] = value}
|
10
|
-
define_method("#{name}?"){::MICON.include? specificator}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|