yuki 0.1.0 → 0.1.1

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.
Files changed (6) hide show
  1. data/.gitignore +1 -0
  2. data/VERSION +1 -1
  3. data/lib/yuki.rb +3 -4
  4. data/test/yuki_test.rb +23 -7
  5. data/yuki.rb +1 -1
  6. metadata +2 -2
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  .DS_Store
2
2
  pkg
3
3
  yuki.gemspec
4
+ test/data/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
data/lib/yuki.rb CHANGED
@@ -155,15 +155,14 @@ module Yuki
155
155
  # or
156
156
  # "Bar"
157
157
  def resolve(cls_def)
158
- if cls_def.kind_of? Hash
158
+ if cls_def.is_a? Hash
159
159
  class_key = cls_def.keys.first
160
160
  clazz = resolve(cls_def[class_key][:type])
161
- resource = clazz.new(info[class_key]) if clazz
162
161
  else
163
162
  clazz = begin
164
- cls_def.split("::").inject(Object) { |obj, const|
163
+ cls_def.to_s.split("::").inject(Object) { |obj, const|
165
164
  obj.const_get(const)
166
- } unless cls_def.strip.empty?
165
+ } unless cls_def.to_s.strip.empty?
167
166
  rescue NameError => e
168
167
  puts "given #{cls_def} got #{e.inspect}"
169
168
  raise e
data/test/yuki_test.rb CHANGED
@@ -81,6 +81,28 @@ class YukiTest < Test::Unit::TestCase
81
81
  end
82
82
  end
83
83
 
84
+ context "a module's type" do
85
+ module Moo
86
+ class Bar
87
+ include Yuki
88
+ end
89
+ end
90
+
91
+ should "be resolved given a hash with type attr" do
92
+ assert_equal Moo::Bar.resolve(
93
+ {
94
+ :class_id => {
95
+ :type => :"YukiTest::Moo::Bar"
96
+ }
97
+ }
98
+ ), Moo::Bar
99
+ end
100
+
101
+ should "be resolved given a string representation of the classes name" do
102
+ assert_equal Moo::Bar.resolve("YukiTest::Moo::Bar"), Moo::Bar
103
+ end
104
+ end
105
+
84
106
  context "a model's lifecyle operations" do
85
107
  should "provide callbacks" do
86
108
 
@@ -105,13 +127,7 @@ class YukiTest < Test::Unit::TestCase
105
127
 
106
128
  context "a model's serialized type" do
107
129
  should "default to the model's class name" do
108
- module Foo
109
- class Bar
110
- include Yuki
111
- end
112
- end
113
-
114
- assert "YukiTest::Foo::Bar", Foo::Bar.new.to_h['type']
130
+ assert "YukiTest::Moo::Bar", Moo::Bar.new.to_h['type']
115
131
  end
116
132
  end
117
133
 
data/yuki.rb CHANGED
@@ -1,2 +1,2 @@
1
- $: < File.join(File.dirname(__FILE__), 'lib')
1
+ $: << File.join(File.dirname(__FILE__), 'lib')
2
2
  require 'yuki'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yuki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - softprops
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-18 00:00:00 -05:00
12
+ date: 2009-12-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15