pebbles-uid 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,6 +43,31 @@ There are currently two characters which cannot be included in an oid:
43
43
 
44
44
  Oid is optional when creating a new resource.
45
45
 
46
+ ## Relations
47
+
48
+ A convention has emerged where the path of an object who belongs in a category
49
+ is built up using the category's path, with the category's oid, appended.
50
+
51
+ I.e.
52
+
53
+ ```ruby
54
+ category = Pebbles::Uid.new('post.doc:edu.uni.abc$123')
55
+ thing = Pebbles::Uid.new('course:edu.uni.abc.123$456')
56
+
57
+ thing.parent
58
+ # => 'course:edu.uni.abc$123'
59
+ thing.parent('post.doc')
60
+ # => 'post.doc:edu.uni.abc$123'
61
+
62
+ category.child_path
63
+ # => 'edu.uni.abc.123'
64
+
65
+ category.children
66
+ # => '*:edu.uni.abc.123'
67
+ category.children('post.subcategory')
68
+ # => 'post.subcategory:edu.uni.abc.123'
69
+ ```
70
+
46
71
  ## Queries
47
72
 
48
73
  ### For one specific resource
data/lib/pebbles-uid.rb CHANGED
@@ -104,5 +104,9 @@ module Pebbles
104
104
  "#{path}.#{oid}"
105
105
  end
106
106
 
107
+ def children(child_species = '*')
108
+ "#{child_species}:#{child_path}"
109
+ end
110
+
107
111
  end
108
112
  end
@@ -27,7 +27,7 @@ module Pebbles
27
27
  end
28
28
 
29
29
  def for_one?
30
- !wildcard_query? && !list?
30
+ oid?
31
31
  end
32
32
 
33
33
  def list?
@@ -42,7 +42,7 @@ module Pebbles
42
42
  end
43
43
 
44
44
  def collection?
45
- wildcard_query?
45
+ !for_one? && !list?
46
46
  end
47
47
 
48
48
  def path?
@@ -1,5 +1,5 @@
1
1
  module Pebbles
2
2
  class Uid
3
- VERSION = "0.0.15"
3
+ VERSION = "0.0.16"
4
4
  end
5
5
  end
data/spec/uid_spec.rb CHANGED
@@ -155,6 +155,11 @@ describe Pebbles::Uid do
155
155
 
156
156
  its(:child_path) { should eq('tourism.norway.fjords.1234') }
157
157
 
158
+ its(:children) { should eq('*:tourism.norway.fjords.1234')}
159
+ it "has children of a certain species" do
160
+ subject.children('stuff').should eq('stuff:tourism.norway.fjords.1234')
161
+ end
162
+
158
163
  its(:cache_key) { should eq('post.card:tourism.*$1234') }
159
164
 
160
165
  its(:to_hash) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebbles-uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70332659041680 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70332659041680
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  description: Handle pebble UIDs conveniently.
26
31
  email:
27
32
  - katrina.owen@gmail.com
@@ -72,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
77
  version: '0'
73
78
  requirements: []
74
79
  rubyforge_project:
75
- rubygems_version: 1.8.15
80
+ rubygems_version: 1.8.25
76
81
  signing_key:
77
82
  specification_version: 3
78
83
  summary: Unique identifiers in the Pebblestack universe, in the format species[.genus]:path$oid,
@@ -85,4 +90,3 @@ test_files:
85
90
  - spec/roots_spec.rb
86
91
  - spec/uid_spec.rb
87
92
  - spec/wildcard_spec.rb
88
- has_rdoc: