ripple 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ These developers have contributed code to Ripple:
2
+
3
+ * Sean Cribbs - sean@basho.com
4
+ * John Lynch - john@rigelgroupllc.com
@@ -1,5 +1,16 @@
1
1
  h1. Ripple Release Notes
2
2
 
3
+ h2. 0.5.1 Patch Release - 2010-02-22
4
+
5
+ This is a minor release with fixes for Ruby 1.9, bundler/edge Rails,
6
+ and a minor feature addition. Changes:
7
+
8
+ * Qualify namespaces for Ruby 1.9.
9
+ * Decoupled a few specs that gave the appearance of failure.
10
+ * Added "bucket" and "key" properties on Riak::Link objects. [John Lynch]
11
+ * Fully-qualify the @JSON@ constant, using @ActiveSupport::JSON@ instead.
12
+ * Adjusted gem specification to accommodate edge Rails. [Preston Marshall]
13
+
3
14
  h2. 0.5 Initial Release - 2010-02-10
4
15
 
5
16
  This is the first release of Ripple, which would not have been possible
@@ -21,4 +32,4 @@ It includes:
21
32
  ** Validations
22
33
  ** Dirty-tracking
23
34
  ** Simple finders - all documents, by key
24
- ** Reloading
35
+ ** Reloading
data/Rakefile CHANGED
@@ -16,8 +16,8 @@ begin
16
16
  gem.add_development_dependency "rack", ">=1.0"
17
17
  gem.add_development_dependency "yard", ">=0.5.2"
18
18
  gem.add_development_dependency "curb", ">=0.6"
19
- gem.add_dependency "activesupport", "3.0.0.beta"
20
- gem.add_dependency "activemodel", "3.0.0.beta"
19
+ gem.add_dependency "activesupport", "~>3.0.0.beta"
20
+ gem.add_dependency "activemodel", "~>3.0.0.beta"
21
21
  gem.requirements << "`gem install curb` for better HTTP performance"
22
22
  end
23
23
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/lib/riak/bucket.rb CHANGED
@@ -46,7 +46,7 @@ module Riak
46
46
  unless response.try(:[], :headers).try(:[],'content-type').try(:first) =~ /json$/
47
47
  raise Riak::InvalidResponse.new({"content-type" => ["application/json"]}, response[:headers], t("loading_bucket", :name => name))
48
48
  end
49
- payload = JSON.parse(response[:body])
49
+ payload = ActiveSupport::JSON.decode(response[:body])
50
50
  @keys = payload['keys'].map {|k| URI.unescape(k) } if payload['keys']
51
51
  @props = payload['props'] if payload['props']
52
52
  self
@@ -63,7 +63,7 @@ module Riak
63
63
  def keys(options={})
64
64
  if block_given?
65
65
  @client.http.get(200, @client.prefix, name, {:props => false}, {}) do |chunk|
66
- obj = JSON.parse(chunk) rescue {}
66
+ obj = ActiveSupport::JSON.decode(chunk) rescue {}
67
67
  yield obj['keys'].map {|k| URI.unescape(k) } if obj['keys']
68
68
  end
69
69
  elsif @keys.nil? || options[:reload]
data/lib/riak/link.rb CHANGED
@@ -35,6 +35,16 @@ module Riak
35
35
  @url, @rel = url, rel
36
36
  end
37
37
 
38
+ # @return [String] bucket_name, if the Link url is a known Riak link ("/raw/<bucket>/<key>")
39
+ def bucket
40
+ $1 if url =~ %r{/raw/([^/]+)/?}
41
+ end
42
+
43
+ # @return [String] key, if the Link url is a known Riak link ("/raw/<bucket>/<key>")
44
+ def key
45
+ $1 if url =~ %r{/raw/[^/]+/([^/]+)/?}
46
+ end
47
+
38
48
  def inspect; to_s; end
39
49
 
40
50
  def to_s
@@ -46,8 +56,7 @@ module Riak
46
56
  end
47
57
 
48
58
  def to_walk_spec
49
- bucket, object = $1, $2 if @url =~ %r{/raw/([^/]+)/([^/]+)/?}
50
- raise t("bucket_link_conversion") if @rel == "up" || object.nil?
59
+ raise t("bucket_link_conversion") if @rel == "up" || key.nil?
51
60
  WalkSpec.new(:bucket => bucket, :tag => @rel)
52
61
  end
53
62
  end
@@ -135,7 +135,7 @@ module Riak
135
135
  def run
136
136
  response = @client.http.post(200, @client.mapred, to_json, {"Content-Type" => "application/json", "Accept" => "application/json"})
137
137
  if response.try(:[], :headers).try(:[],'content-type').include?("application/json")
138
- JSON.parse(response[:body])
138
+ ActiveSupport::JSON.decode(response[:body])
139
139
  else
140
140
  response
141
141
  end
@@ -53,7 +53,7 @@ module Ripple
53
53
  included do
54
54
  extend BucketAccess
55
55
  include Persistence
56
- include EmbeddedDocument
56
+ include Ripple::EmbeddedDocument
57
57
  include Finders
58
58
  end
59
59
  end
@@ -22,7 +22,7 @@ module Ripple
22
22
  autoload :Callbacks
23
23
 
24
24
  included do
25
- include Callbacks
25
+ include Ripple::Document::Persistence::Callbacks
26
26
  end
27
27
 
28
28
  module InstanceMethods
@@ -23,10 +23,10 @@ module Ripple
23
23
 
24
24
  included do
25
25
  extend ActiveModel::Naming
26
- extend Document::Properties
26
+ extend Ripple::Document::Properties
27
27
  include Persistence
28
- include Document::AttributeMethods
29
- include Document::Validations
28
+ include Ripple::Document::AttributeMethods
29
+ include Ripple::Document::Validations
30
30
  end
31
31
 
32
32
  module ClassMethods
data/ripple.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ripple}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sean Cribbs"]
12
- s.date = %q{2010-02-10}
12
+ s.date = %q{2010-02-22}
13
13
  s.description = %q{ripple is a rich Ruby client for Riak, Basho's distributed database. It includes all the basics of accessing and manipulating Riak buckets and objects, and an object mapper library for building a rich domain on top of Riak.}
14
14
  s.email = %q{seancribbs@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
+ "CONTRIBUTORS.textile",
22
23
  "LICENSE",
23
24
  "README.textile",
24
25
  "RELEASE_NOTES.textile",
@@ -135,16 +136,16 @@ Gem::Specification.new do |s|
135
136
  s.add_development_dependency(%q<rack>, [">= 1.0"])
136
137
  s.add_development_dependency(%q<yard>, [">= 0.5.2"])
137
138
  s.add_development_dependency(%q<curb>, [">= 0.6"])
138
- s.add_runtime_dependency(%q<activesupport>, ["= 3.0.0.beta"])
139
- s.add_runtime_dependency(%q<activemodel>, ["= 3.0.0.beta"])
139
+ s.add_runtime_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
140
+ s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0.beta"])
140
141
  else
141
142
  s.add_dependency(%q<rspec>, [">= 1.3"])
142
143
  s.add_dependency(%q<fakeweb>, [">= 1.2"])
143
144
  s.add_dependency(%q<rack>, [">= 1.0"])
144
145
  s.add_dependency(%q<yard>, [">= 0.5.2"])
145
146
  s.add_dependency(%q<curb>, [">= 0.6"])
146
- s.add_dependency(%q<activesupport>, ["= 3.0.0.beta"])
147
- s.add_dependency(%q<activemodel>, ["= 3.0.0.beta"])
147
+ s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
148
+ s.add_dependency(%q<activemodel>, ["~> 3.0.0.beta"])
148
149
  end
149
150
  else
150
151
  s.add_dependency(%q<rspec>, [">= 1.3"])
@@ -152,8 +153,8 @@ Gem::Specification.new do |s|
152
153
  s.add_dependency(%q<rack>, [">= 1.0"])
153
154
  s.add_dependency(%q<yard>, [">= 0.5.2"])
154
155
  s.add_dependency(%q<curb>, [">= 0.6"])
155
- s.add_dependency(%q<activesupport>, ["= 3.0.0.beta"])
156
- s.add_dependency(%q<activemodel>, ["= 3.0.0.beta"])
156
+ s.add_dependency(%q<activesupport>, ["~> 3.0.0.beta"])
157
+ s.add_dependency(%q<activemodel>, ["~> 3.0.0.beta"])
157
158
  end
158
159
  end
159
160
 
@@ -21,13 +21,31 @@ describe Riak::Link do
21
21
  result.should be_all {|i| Riak::Link === i }
22
22
  end
23
23
 
24
- it "should set the url and rel parameters properly" do
24
+ it "should set the bucket, key, url and rel parameters properly" do
25
25
  result = Riak::Link.parse('</raw/foo/bar>; riaktag="tag", </raw/foo>; rel="up"')
26
26
  result[0].url.should == "/raw/foo/bar"
27
+ result[0].bucket.should == "foo"
28
+ result[0].key.should == "bar"
27
29
  result[0].rel.should == "tag"
28
30
  result[1].url.should == "/raw/foo"
31
+ result[1].bucket.should == "foo"
32
+ result[1].key.should == nil
29
33
  result[1].rel.should == "up"
30
34
  end
35
+
36
+ it "should set url properly, and set bucket and key to nil for non-Riak links" do
37
+ result = Riak::Link.parse('<http://www.example.com/123.html>; riaktag="tag", </raw/foo>; rel="up"')
38
+ result[0].url.should == "http://www.example.com/123.html"
39
+ result[0].bucket.should == nil
40
+ result[0].key.should == nil
41
+ result[0].rel.should == "tag"
42
+
43
+ result = Riak::Link.parse('<http://www.example.com/>; riaktag="tag", </raw/foo>; rel="up"')
44
+ result[0].url.should == "http://www.example.com/"
45
+ result[0].bucket.should == nil
46
+ result[0].key.should == nil
47
+ result[0].rel.should == "tag"
48
+ end
31
49
  end
32
50
 
33
51
  it "should convert to a string appropriate for use in the Link header" do
@@ -15,10 +15,12 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::AttributeMethods do
17
17
  before :all do
18
- class Widget
19
- include Ripple::Document
20
- property :size, Integer
21
- property :name, String, :default => "widget"
18
+ Object.module_eval do
19
+ class Widget
20
+ include Ripple::Document
21
+ property :size, Integer
22
+ property :name, String, :default => "widget"
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -15,9 +15,11 @@ require File.expand_path("../spec_helper", File.dirname(__FILE__))
15
15
 
16
16
  describe Ripple::Document::BucketAccess do
17
17
  before :all do
18
- class Invoice; include Ripple::Document; end
19
- class LateInvoice < Invoice; end
20
- class PaidInvoice < Invoice; self.bucket_name = "paid"; end
18
+ Object.module_eval do
19
+ class Invoice; include Ripple::Document; end
20
+ class LateInvoice < Invoice; end
21
+ class PaidInvoice < Invoice; self.bucket_name = "paid"; end
22
+ end
21
23
  end
22
24
 
23
25
  it "should use the plural model name as the bucket name" do
@@ -15,12 +15,12 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::Persistence::Callbacks do
17
17
  before :all do
18
- class Box; include Ripple::Document; property :shape, String end
18
+ Object.module_eval { class Box; include Ripple::Document; property :shape, String end }
19
19
  end
20
20
 
21
21
  it "should add create, update, save, and destroy callback declarations" do
22
22
  [:save, :create, :update, :destroy].each do |event|
23
- Box.private_instance_methods.should include("_run_#{event}_callbacks")
23
+ Box.private_instance_methods.map(&:to_s).should include("_run_#{event}_callbacks")
24
24
  [:before, :after, :around].each do |time|
25
25
  Box.should respond_to("#{time}_#{event}")
26
26
  end
@@ -15,7 +15,7 @@ require File.expand_path("../spec_helper", File.dirname(__FILE__))
15
15
 
16
16
  describe Ripple::Document do
17
17
  before :all do
18
- class Page; include Ripple::Document; end
18
+ Object.module_eval { class Page; include Ripple::Document; end }
19
19
  end
20
20
 
21
21
  it "should add bucket access methods to classes when included" do
@@ -15,7 +15,7 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::EmbeddedDocument do
17
17
  before :all do
18
- class Address; include Ripple::EmbeddedDocument; end
18
+ Object.module_eval { class Address; include Ripple::EmbeddedDocument; end }
19
19
  end
20
20
 
21
21
  it "should have a model name when included" do
@@ -15,9 +15,11 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::Finders do
17
17
  before :all do
18
- class Box
19
- include Ripple::Document
20
- property :shape, String
18
+ Object.module_eval do
19
+ class Box
20
+ include Ripple::Document
21
+ property :shape, String
22
+ end
21
23
  end
22
24
  end
23
25
 
@@ -123,7 +125,7 @@ describe Ripple::Document::Finders do
123
125
 
124
126
  describe "single-bucket inheritance" do
125
127
  before :all do
126
- class CardboardBox < Box; end
128
+ Object.module_eval { class CardboardBox < Box; end }
127
129
  end
128
130
 
129
131
  it "should instantiate as the proper type if defined in the document" do
@@ -15,11 +15,13 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::Persistence do
17
17
  before :all do
18
- class Widget
19
- include Ripple::Document
20
- property :size, Integer
21
- property :name, String, :default => "widget"
22
- end
18
+ Object.module_eval {
19
+ class Widget
20
+ include Ripple::Document
21
+ property :size, Integer
22
+ property :name, String, :default => "widget"
23
+ end
24
+ }
23
25
  end
24
26
 
25
27
  before :each do
@@ -67,7 +69,10 @@ describe Ripple::Document::Persistence do
67
69
 
68
70
  describe "when storing a class using single-bucket inheritance" do
69
71
  before :all do
70
- class Cog < Widget; property :name, String, :default => "cog"; end
72
+ Object.module_eval { class Cog < Widget; property :name, String, :default => "cog"; end }
73
+ end
74
+
75
+ before :each do
71
76
  @cog = Cog.new(:size => 1000)
72
77
  end
73
78
 
@@ -15,7 +15,7 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::Properties do
17
17
  before :all do
18
- class Email; include Ripple::Document; end
18
+ Object.module_eval { class Email; include Ripple::Document; end }
19
19
  end
20
20
 
21
21
  it "should make the model class have a property definition method" do
@@ -122,7 +122,11 @@ describe Ripple::Document::Property do
122
122
  @prop.type_cast("s").should == "s"
123
123
  @prop.type_cast(1).should == "1"
124
124
  @prop.type_cast(true).should == "true"
125
- @prop.type_cast([]).should == ""
125
+ if RUBY_VERSION < "1.9"
126
+ @prop.type_cast([]).should == ""
127
+ else
128
+ @prop.type_cast([]).should == "[]"
129
+ end
126
130
  end
127
131
  end
128
132
 
@@ -15,7 +15,7 @@ require File.expand_path("../../spec_helper", __FILE__)
15
15
 
16
16
  describe Ripple::Document::Validations do
17
17
  before :all do
18
- class Box; include Ripple::Document; property :shape, String end
18
+ Object.module_eval { class Box; include Ripple::Document; property :shape, String end }
19
19
  end
20
20
 
21
21
  before :each do
@@ -50,14 +50,16 @@ describe Ripple::Document::Validations do
50
50
  end
51
51
 
52
52
  it "should run validations at the correct lifecycle state" do
53
- pending "@_on_validate seems not to work?!"
54
- Box.property :size, Integer
55
- Box.validates_inclusion_of :size, :in => 1..30, :on => :update
53
+ Box.property :size, Integer, :inclusion => {:in => 1..30, :on => :update }
56
54
  @box.size = 0
57
55
  @box.should be_valid
58
56
  Box.properties.delete :size
59
57
  end
60
-
58
+
59
+ after :each do
60
+ Box.reset_callbacks(:validate)
61
+ end
62
+
61
63
  after :all do
62
64
  Object.send(:remove_const, :Box)
63
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ripple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Cribbs
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-10 00:00:00 -05:00
12
+ date: 2010-02-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -68,7 +68,7 @@ dependencies:
68
68
  version_requirement:
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "="
71
+ - - ~>
72
72
  - !ruby/object:Gem::Version
73
73
  version: 3.0.0.beta
74
74
  version:
@@ -78,7 +78,7 @@ dependencies:
78
78
  version_requirement:
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "="
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: 3.0.0.beta
84
84
  version:
@@ -94,6 +94,7 @@ extra_rdoc_files:
94
94
  files:
95
95
  - .document
96
96
  - .gitignore
97
+ - CONTRIBUTORS.textile
97
98
  - LICENSE
98
99
  - README.textile
99
100
  - RELEASE_NOTES.textile