defined-by 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,4 +42,6 @@
42
42
  #=> [
43
43
  #<WidgetA:0x5c3348 @description="This widget does X", @name="widget_a">,
44
44
  #<WidgetB:0x5c2970 @description="This does Y", @name="widget_b">
45
- ]
45
+ ]
46
+
47
+ http://www.khelll.com/blog/ruby/stackoverflow-cool-ruby-questions-4/
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/gempackagetask'
5
5
  spec = Gem::Specification.new do |s|
6
6
  s.name = "defined-by"
7
7
  s.authors = ["Lance Pollard"]
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
  s.summary = "Advanced DSL and Dynamic class generation for Ruby"
10
10
  s.homepage = "http://github.com/viatropos/defined-by"
11
11
  s.email = "lancejpollard@gmail.com"
@@ -1,7 +1,9 @@
1
1
  def define_class(name, superclass = Object, &block)
2
2
  name = name.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
3
+ superclass = superclass.to_s.gsub(/^:*/, "::")
3
4
  eval("class #{name} < #{superclass}; end")
4
5
  clazz = eval(name)
6
+ clazz.unloadable if clazz.respond_to?(:unloadable)
5
7
  clazz.class_eval(&block) if block_given?
6
8
  clazz
7
9
  end
@@ -6,6 +6,17 @@ def define_module(name, &block)
6
6
  eval("module #{sub_name}; end")
7
7
  end
8
8
  clazz = eval(name)
9
+ clazz.unloadable if clazz.respond_to?(:unloadable)
9
10
  clazz.class_eval(&block) if block_given?
10
11
  clazz
11
12
  end
13
+
14
+ =begin
15
+ def add_module(name, &block)
16
+ define_module(name).class_eval do
17
+ class << self; self; end.send(:define_method, :included) { |base|
18
+ base.class_eval(&block)
19
+ }
20
+ end
21
+ end
22
+ =end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: defined-by
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lance Pollard
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-13 00:00:00 -05:00
18
+ date: 2010-09-20 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21