kindah 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODY0NDc2MWNjZDM0YjUxZDU2MTZlOWIyMjQ1ZTY5ZjU0ODE4NjZkNA==
4
+ MmExYmM3NGQ1MTVhOWM3NTI3OWExZjFkYWFiZDBiZDUwMTc0ZmViNA==
5
5
  data.tar.gz: !binary |-
6
- YjZhMWEwNDRlMTJlNzA0YTU5YjU0MTU5ZGMzOTFiOTY1NGZkNTU5Nw==
6
+ ZmRhYjg3MmY4ZWI2NzM3YTdiMTc1MDIxNTExY2Y4MWE3OWY5ODg2NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWVmMDcyZjM3MGRhZmM2NzcxOWRhMDcyZDg3ZDgyNTVkMzlhMWU5OGNkOGUx
10
- NjMyMDU5OTk0NTI5YTAzZWRmZjgzODJlMjljZGU0NjUxZTg3YjkyYmQxYjgz
11
- MmFiZDkzMjUzN2E2ZjdhMTFiZWVhNmU1NjMxM2ZjYjBmYzU1ZjE=
9
+ ODk0ZmQzZGVmYzE2MDk5MjQ4MTIzNDlmNDVlZmNkYjJlMmYyZTJjMWZmNGZi
10
+ MzIyZThhYTEzMDNhOGZiNGQwYjhkNjkyYWY2OTczMDEwZjExZDMxZTcxODU1
11
+ YzM2ZGFkODc0MmRlNzQ2YmYyNjY0OWU4MWJiOWViZjFhOTgxNDc=
12
12
  data.tar.gz: !binary |-
13
- ZmE4ZDljOGFlZWRhZWIyMTVkMjlhODAxMzFmYzM4MjIyNzgxZjY5NGRjODY2
14
- ZDUxMmVlNTE3MjJkMWY1MGM3NWUzMmNmMjNjMmUxZDMyYmMyYjljNDU3ZWFk
15
- NzQ1OTJmYTY4ZmNkYmRiNmQ0YjQ0ZjNmMWExY2QzZGFmZjRjMGU=
13
+ MDQ4NWUxYmEzMTEyNWJiYmI1ZjczZDgwNGU2OTU1N2YyY2E2OTU3YTcwOWM4
14
+ OGUzZjUyZjZhMGI5NmExZTRkOTI2Y2YwMmM5NzljNDlkYWUwMmNhNDJkMTJi
15
+ ODdkOTIxMzg1OTYxZTk5MDFmNzNlMmZiZDkwZWVjM2YzYmZiZjY=
@@ -28,7 +28,9 @@ module Kindah
28
28
  def compile!(location = Object)
29
29
  compiler = self # this trick carries the outer scope past ruby's stupid block-scoping rules.
30
30
 
31
- location.send(:define_method, compiler.class_name) do |*args|
31
+ method_type = location == Object ? :define_method : :define_singleton_method
32
+
33
+ location.send(method_type, compiler.class_name) do |*args|
32
34
  Kindah::Cache[compiler.class_name, *args] ||= compiler.create_klass_with_args *args
33
35
  end
34
36
 
@@ -1,3 +1,3 @@
1
1
  module Kindah
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Kindah do
4
+ before :all do
5
+ module TestModule; end
6
+ Kindah.class_template! :Test, location: TestModule do
7
+ class_methods do |bar|
8
+ def foo_class
9
+ bar + 1
10
+ end
11
+ end
12
+
13
+ instance_methods do
14
+ def foo_instance
15
+ bar + 1
16
+ end
17
+
18
+ def initialize
19
+ @ivar = 1
20
+ end
21
+
22
+ attr_reader :ivar
23
+ end
24
+ end
25
+ end
26
+
27
+ subject(:test_instance) { TestModule::Test(1).new }
28
+
29
+ it { should respond_to :bar }
30
+ it { should respond_to :foo_instance }
31
+ it { should respond_to :ivar }
32
+
33
+ its(:ivar) { should == 1 }
34
+
35
+ its(:class) { should respond_to :bar }
36
+ its(:class) { should respond_to :foo_class }
37
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kindah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Fredette
@@ -48,6 +48,7 @@ files:
48
48
  - lib/kindah/cache.rb
49
49
  - lib/kindah/compiler.rb
50
50
  - lib/kindah/version.rb
51
+ - spec/integration/namespaced_parameterized_class_spec.rb
51
52
  - spec/integration/parameterized_class_spec.rb
52
53
  - spec/spec_helper.rb
53
54
  homepage: ''
@@ -75,5 +76,6 @@ signing_key:
75
76
  specification_version: 4
76
77
  summary: Kindah is an implementation of Parameterized Classes for Ruby.
77
78
  test_files:
79
+ - spec/integration/namespaced_parameterized_class_spec.rb
78
80
  - spec/integration/parameterized_class_spec.rb
79
81
  - spec/spec_helper.rb