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 +8 -8
- data/lib/kindah/compiler.rb +3 -1
- data/lib/kindah/version.rb +1 -1
- data/spec/integration/namespaced_parameterized_class_spec.rb +37 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmExYmM3NGQ1MTVhOWM3NTI3OWExZjFkYWFiZDBiZDUwMTc0ZmViNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmRhYjg3MmY4ZWI2NzM3YTdiMTc1MDIxNTExY2Y4MWE3OWY5ODg2NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODk0ZmQzZGVmYzE2MDk5MjQ4MTIzNDlmNDVlZmNkYjJlMmYyZTJjMWZmNGZi
|
10
|
+
MzIyZThhYTEzMDNhOGZiNGQwYjhkNjkyYWY2OTczMDEwZjExZDMxZTcxODU1
|
11
|
+
YzM2ZGFkODc0MmRlNzQ2YmYyNjY0OWU4MWJiOWViZjFhOTgxNDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDQ4NWUxYmEzMTEyNWJiYmI1ZjczZDgwNGU2OTU1N2YyY2E2OTU3YTcwOWM4
|
14
|
+
OGUzZjUyZjZhMGI5NmExZTRkOTI2Y2YwMmM5NzljNDlkYWUwMmNhNDJkMTJi
|
15
|
+
ODdkOTIxMzg1OTYxZTk5MDFmNzNlMmZiZDkwZWVjM2YzYmZiZjY=
|
data/lib/kindah/compiler.rb
CHANGED
@@ -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
|
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
|
|
data/lib/kindah/version.rb
CHANGED
@@ -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.
|
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
|