pebble_path 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.
data/README.md CHANGED
@@ -33,9 +33,31 @@ Or install it yourself as:
33
33
 
34
34
  $ gem install pebble_path
35
35
 
36
+ Create a migration for the table that you want to put the paths on, e.g.
37
+
38
+ def self.up
39
+ labels = (0..9).map { |i| "label_#{i}".to_sym }
40
+
41
+ create_table :locations do |t|
42
+ labels.each do |label|
43
+ t.text label
44
+ end
45
+ t.timestamps
46
+ end
47
+
48
+ add_index :locations, labels, :unique => true, :name => 'index_locations_on_labels'
49
+ end
50
+
51
+
36
52
  ## Usage
37
53
 
38
- TODO: Write usage instructions here
54
+ Include the `PebblePath` module in the `ActiveRecord` model that has the labels
55
+
56
+ ```
57
+ class Location < ActiveRecord::Base
58
+ include PebblePath
59
+ end
60
+ ```
39
61
 
40
62
  ## Contributing
41
63
 
data/lib/pebble_path.rb CHANGED
@@ -20,6 +20,14 @@ module PebblePath
20
20
  validate :must_be_valid_uid_path
21
21
 
22
22
  after_initialize :initialize_path
23
+
24
+ def self.declare!(path)
25
+ raise ArgumentError, "Path must be valid" unless Pebblebed::Uid.valid_path?(path)
26
+ attributes = PebblePath.to_conditions(path)
27
+ path = self.where(attributes).first
28
+ path ||= self.create!(attributes)
29
+ end
30
+
23
31
  end
24
32
  end
25
33
 
data/pebble_path.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "pebble_path"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "0.0.2"
15
+ gem.version = "0.0.3"
16
16
 
17
17
  gem.add_development_dependency 'rspec'
18
18
  gem.add_dependency 'pebblebed', '>=0.0.15'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebble_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2012-05-15 00:00:00.000000000Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70309093728740 !ruby/object:Gem::Requirement
16
+ requirement: &70319524446100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70309093728740
24
+ version_requirements: *70319524446100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: pebblebed
27
- requirement: &70309093727040 !ruby/object:Gem::Requirement
27
+ requirement: &70319524478860 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.0.15
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70309093727040
35
+ version_requirements: *70319524478860
36
36
  description: Provide pebble-compliant paths for ActiveRecord models.
37
37
  email:
38
38
  - katrina.owen@gmail.com
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  requirements: []
72
72
  rubyforge_project:
73
- rubygems_version: 1.8.10
73
+ rubygems_version: 1.8.15
74
74
  signing_key:
75
75
  specification_version: 3
76
76
  summary: Provides searchable, parseable pebble-compliant UID paths, e.g. (such as