ripple_oh_caramba 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format progress
3
+ spec
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.5.2"
12
+ end
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.2)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+ shoulda (2.11.3)
11
+
12
+ PLATFORMS
13
+ ruby
14
+
15
+ DEPENDENCIES
16
+ bundler (~> 1.0.0)
17
+ jeweler (~> 1.5.2)
18
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 jbe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,85 @@
1
+
2
+ _ . _
3
+ + | +
4
+
5
+ ¤¤ | ¤¤
6
+
7
+ ^
8
+ ¤ ¤
9
+ ^ ^
10
+ . . . . .
11
+ RIPPLE OH CARAMBA
12
+ ' ' ' ' '
13
+ ' ' ' ' '
14
+ ' '
15
+ ' ' '
16
+ o o
17
+
18
+ ~ additions ~
19
+ for the
20
+ orm
21
+ called ripple
22
+ using
23
+ the
24
+ « riak database »
25
+ . . . .
26
+
27
+ ( it is )
28
+ . great . . .
29
+ . .
30
+ ' ' '
31
+ . ' . +
32
+ .
33
+ .
34
+ anyway.. .
35
+
36
+ $ gem install ripple_oh_caramba .
37
+ .
38
+ require 'ripple_oh_caramba' +
39
+ _ .
40
+ ' )
41
+ // this gives ripple some new o
42
+ DSL methods... (_.
43
+ . +
44
+ .
45
+
46
+ // REFERENTIAL ASSOCIATION
47
+
48
+ reference_one :email_confirmation
49
+ # set up referential accessor and a property
50
+ # called :email_confirmation_key
51
+
52
+ reference_many :sessions
53
+ # set up referential accessor based a hash
54
+ # of keys in the :session_keys property
55
+
56
+
57
+ // MUTUAL ASSOCIATION
58
+
59
+ references_one_mutual :wife, :as => :husband, :class => Wife
60
+ # updates are automatically applied to both ends
61
+
62
+ references_many_mutual :friends, :as => :friends, :class => self
63
+
64
+
65
+ // TOKENS FOR SIGNUP ETC
66
+
67
+ token_key! { ActiveSupport::SecureRandom.urlsafe_base64(16) }
68
+ # add a field called :token with the provided proc for
69
+ # default value, or the proc above if none is provided, and
70
+ # key_on that field.
71
+
72
+ token :yaya
73
+ # add a token called yaya, without keying on it.
74
+
75
+
76
+ (( DISCLAIMER ))
77
+
78
+ THE RIPPLE_OH_CARAMBA GEM WAS NOT WRITTEN TO BE PARTICULARLY
79
+ DURABLE OR OF HIGH QUALITY, BUT AS AN EXPERIMENT.
80
+
81
+ ~~ feel free to contribute ~~
82
+
83
+
84
+ * Copyright (c) 2011 Jostein Berre Eliassen.
85
+ See LICENSE.txt for details.
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ripple_oh_caramba"
16
+ gem.homepage = "http://github.com/jbe/ripple_oh_caramba"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Monkey patch to extend the Riak DSL.}
19
+ gem.description = %Q{Monkeypatches Riak, giving support for referential associations, mutual associations, and other stuff. Highly experimental.}
20
+ gem.email = "post@jostein.be"
21
+ gem.authors = ["jbe"]
22
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
23
+ gem.add_runtime_dependency 'ripple'
24
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,76 @@
1
+
2
+ require 'ripple'
3
+
4
+ # Monkey likes to patch
5
+
6
+ module Ripple::Document::ClassMethods
7
+
8
+
9
+ def reference_one(name, opts={})
10
+ name = name.to_s
11
+ kls = opts[:class] ||
12
+ name.camelize.constantize
13
+
14
+ property :"#{name}_key", String
15
+
16
+ class_eval <<-CODE
17
+ def #{name}
18
+ @#{name} ||= #{kls}.find(#{name}_key)
19
+ end
20
+
21
+ def #{name}=(doc)
22
+ if doc.class != #{kls}
23
+ raise "got " + doc.class + ", expected #{kls}"
24
+ end
25
+ raise "must have a key" unless doc.key
26
+ @#{name} = doc
27
+ self.#{name}_key = doc.key
28
+ end
29
+ CODE
30
+ end
31
+
32
+ def reference_many(name, opts={})
33
+ kls = opts[:class]
34
+ raise 'not imlemented yet'
35
+ end
36
+
37
+
38
+
39
+ def one_mutual(name, opts={})
40
+ as = opts[:as]
41
+ kls = opts[:class]
42
+ raise 'not imlemented yet'
43
+ end
44
+
45
+ def many_mutual(name, opts={})
46
+ as = opts[:as]
47
+ kls = opts[:class]
48
+ raise 'not imlemented yet'
49
+ end
50
+
51
+ def reference_one_mutual(name, opts={})
52
+ as = opts[:as]
53
+ kls = opts[:class]
54
+ raise 'not imlemented yet'
55
+ end
56
+
57
+ def reference_many_mutual(name, opts={})
58
+ as = opts[:as]
59
+ kls = opts[:class]
60
+ raise 'not imlemented yet'
61
+ end
62
+
63
+
64
+ ### TOKENS
65
+
66
+ def token(name, &blk)
67
+ property name, String, :default => blk ||
68
+ lambda { ActiveSupport::SecureRandom.urlsafe_base64(16) }
69
+ end
70
+
71
+ def token_key!(&blk)
72
+ token(:token, &blk)
73
+ key_on :token
74
+ end
75
+
76
+ end
@@ -0,0 +1,61 @@
1
+
2
+ require 'ripple_oh_caramba'
3
+
4
+
5
+ class Car
6
+ include Ripple::Document
7
+
8
+ reference_one :rival, :class => Car
9
+ end
10
+
11
+
12
+
13
+
14
+ describe 'reference_one' do
15
+ it 'gives error when given unpersisted class' do
16
+ lambda do
17
+ Car.new(:rival => Car.new)
18
+ end.should raise_error
19
+ end
20
+
21
+ it 'works' do
22
+ rival = Car.create
23
+ car = Car.new(:rival => rival)
24
+
25
+ car.rival.should == rival
26
+ car.rival_key.should == rival.key
27
+
28
+ car.save
29
+ Car.find(car.key).rival.should == car.rival
30
+ Car.find(car.key).rival_key.should == car.rival.key
31
+
32
+ rival.destroy
33
+ car.destroy
34
+ end
35
+ end
36
+
37
+
38
+
39
+
40
+ describe 'reference many' do
41
+ it 'works'
42
+ end
43
+
44
+ describe 'reference one mutual' do
45
+ it 'works'
46
+ end
47
+
48
+ describe 'reference many mutual' do
49
+ it 'works'
50
+ end
51
+
52
+ describe 'token_key!' do
53
+ it 'works'
54
+ end
55
+
56
+ describe 'token' do
57
+ it 'works'
58
+ end
59
+
60
+
61
+
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ripple_oh_caramba
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - jbe
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-20 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: shoulda
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ prerelease: false
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ segments:
41
+ - 1
42
+ - 0
43
+ - 0
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &id003 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 1
57
+ - 5
58
+ - 2
59
+ version: 1.5.2
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: ripple
65
+ requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ segments:
71
+ - 0
72
+ version: "0"
73
+ type: :runtime
74
+ prerelease: false
75
+ version_requirements: *id004
76
+ description: Monkeypatches Riak, giving support for referential associations, mutual associations, and other stuff. Highly experimental.
77
+ email: post@jostein.be
78
+ executables: []
79
+
80
+ extensions: []
81
+
82
+ extra_rdoc_files:
83
+ - LICENSE.txt
84
+ - README
85
+ files:
86
+ - .README.swp
87
+ - .document
88
+ - .rspec
89
+ - Gemfile
90
+ - Gemfile.lock
91
+ - LICENSE.txt
92
+ - README
93
+ - Rakefile
94
+ - VERSION
95
+ - lib/.ripple_oh_caramba.rb.swp
96
+ - lib/ripple_oh_caramba.rb
97
+ - spec/ripple_oh_caramba_spec.rb
98
+ has_rdoc: true
99
+ homepage: http://github.com/jbe/ripple_oh_caramba
100
+ licenses:
101
+ - MIT
102
+ post_install_message:
103
+ rdoc_options: []
104
+
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: -475559469
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ segments:
122
+ - 0
123
+ version: "0"
124
+ requirements: []
125
+
126
+ rubyforge_project:
127
+ rubygems_version: 1.3.7
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Monkey patch to extend the Riak DSL.
131
+ test_files:
132
+ - spec/ripple_oh_caramba_spec.rb