dm-is-indexed 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ ### 0.1.1 / 2011-03-21
2
+
3
+ * Use `DataMapper::Property#valid?` to check if a key is compatible with a
4
+ Property.
5
+
1
6
  ### 0.1.0 / 2011-03-21
2
7
 
3
8
  * Initial release.
data/Gemfile CHANGED
@@ -98,6 +98,10 @@ end
98
98
 
99
99
  gem 'dm-core', DM_VERSION, :git => "#{DATAMAPPER}/dm-core.git"
100
100
 
101
+ group :test do
102
+ gem 'dm-types', DM_VERSION, :git => "#{DATAMAPPER}/dm-types.git"
103
+ end
104
+
101
105
  group :development do
102
106
  gem 'rake', '~> 0.8.7'
103
107
 
@@ -1,5 +1,5 @@
1
1
  name: dm-is-indexed
2
- version: 0.1.0
2
+ version: 0.1.1
3
3
  summary: Query DataMapper Resources via their indexed properties.
4
4
  description:
5
5
  dm-is-indexed overloads the Model[] method, and allows querying Resources
@@ -33,7 +33,7 @@ module DataMapper
33
33
 
34
34
  properties.each do |field|
35
35
  if (field.index || field.unique?)
36
- if field.primitive?(key)
36
+ if field.valid?(key)
37
37
  resource = first(field => key)
38
38
 
39
39
  break if resource
@@ -8,43 +8,50 @@ describe DataMapper::Is::Indexed do
8
8
  Atom.create(
9
9
  :symbol => 'He',
10
10
  :name => 'Helium',
11
- :atomic_weight => 4.002602
11
+ :atomic_weight => 4.002602,
12
+ :url => 'http://www.webelements.com/helium/'
12
13
  )
13
14
 
14
15
  Atom.create(
15
16
  :symbol => 'Ne',
16
17
  :name => 'Neon',
17
- :atomic_weight => 20.1797
18
+ :atomic_weight => 20.1797,
19
+ :url => 'http://www.webelements.com/neon/'
18
20
  )
19
21
 
20
22
  Atom.create(
21
23
  :symbol => 'Ar',
22
24
  :name => 'Argon',
23
- :atomic_weight => 39.948
25
+ :atomic_weight => 39.948,
26
+ :url => 'http://www.webelements.com/argon/'
24
27
  )
25
28
 
26
29
  Atom.create(
27
30
  :symbol => 'Kr',
28
31
  :name => 'Krypton',
29
- :atomic_weight => 83.798
32
+ :atomic_weight => 83.798,
33
+ :url => 'http://www.webelements.com/krypton/'
30
34
  )
31
35
 
32
36
  Atom.create(
33
37
  :symbol => 'Xe',
34
38
  :name => 'Xeon',
35
- :atomic_weight => 131.293
39
+ :atomic_weight => 131.293,
40
+ :url => 'http://www.webelements.com/xenon/'
36
41
  )
37
42
 
38
43
  Atom.create(
39
44
  :symbol => 'Rn',
40
45
  :name => 'Radon',
41
- :atomic_weight => 222.0
46
+ :atomic_weight => 222.0,
47
+ :url => 'http://www.webelements.com/radon/'
42
48
  )
43
49
 
44
50
  Atom.create(
45
51
  :symbol => 'Uuo',
46
52
  :name => 'Ununoctium',
47
- :atomic_weight => 294.0
53
+ :atomic_weight => 294.0,
54
+ :url => 'http://www.webelements.com/ununoctium/'
48
55
  )
49
56
  end
50
57
 
@@ -84,5 +91,9 @@ describe DataMapper::Is::Indexed do
84
91
  it "should select the properties to query based on the key type" do
85
92
  subject[83.798].symbol.should == 'Kr'
86
93
  end
94
+
95
+ it "should select the properties to query based on supported key types" do
96
+ subject['http://www.webelements.com/ununoctium/'].symbol.should == 'Uuo'
97
+ end
87
98
  end
88
99
  end
@@ -1,4 +1,5 @@
1
1
  require 'dm-core'
2
+ require 'dm-types'
2
3
  require 'dm-is-indexed'
3
4
 
4
5
  class Atom
@@ -15,4 +16,6 @@ class Atom
15
16
 
16
17
  property :atomic_weight, Float, :index => true
17
18
 
19
+ property :url, URI, :index => true
20
+
18
21
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: dm-is-indexed
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Postmodern