rico 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - jruby-19mode
5
+ - jruby-head
6
+ services:
7
+ - riak
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Rico
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/jcoene/rico.png?branch=master)](https://travis-ci.org/jcoene/rico)
4
+
3
5
  Rico provides primative data types on Riak.
4
6
 
5
7
  ## Installation
@@ -34,11 +36,11 @@ follows.length # => 0
34
36
 
35
37
  ## Configuration
36
38
 
37
- By default, Rico uses a generic Riak::Client instance for operations. You can specify your own (perhaps inside of a rails initializer) like so:
39
+ By default, Rico uses a generic Riak::Client instance for operations. You can specify your own options for the Riak client (perhaps inside of a rails initializer) like so:
38
40
 
39
41
  ```ruby
40
42
  Rico.configure do |c|
41
- c.riak = Riak::Client.new(http_port: 1234, ...)
43
+ c.options = { http_port: 1234, ... }
42
44
  end
43
45
  ```
44
46
 
@@ -116,8 +118,7 @@ Data is persisted at operation time. For example, List#add(5) will immediately u
116
118
 
117
119
  ## TODO
118
120
 
119
- - Automatic sibling resolution for simple types
120
- - Ability to provide sibling resolution callback
121
+ - Ability to provide custom sibling resolution callbacks
121
122
 
122
123
  ## Contributing
123
124
 
data/lib/rico.rb CHANGED
@@ -40,12 +40,16 @@ module Rico
40
40
  @namespace = namespace
41
41
  end
42
42
 
43
- def self.riak
44
- @riak ||= Riak::Client.new
43
+ def self.options
44
+ @options || {}
45
+ end
46
+
47
+ def self.options=(options)
48
+ @options = options
45
49
  end
46
50
 
47
- def self.riak=(riak)
48
- @riak = riak
51
+ def self.riak
52
+ Thread.current[:riak] ||= Riak::Client.new(options)
49
53
  end
50
54
  end
51
55
 
data/lib/rico/array.rb CHANGED
@@ -59,7 +59,8 @@ module Rico
59
59
 
60
60
  result -= deletions
61
61
 
62
- obj = Riak::RObject.new(robject.bucket, robject.key)
62
+ obj = robject.dup
63
+ obj.siblings = [obj.siblings.first]
63
64
  obj.data = { "_values" => result, "_deletes" => deletions }
64
65
  obj
65
66
  end
data/lib/rico/resolver.rb CHANGED
@@ -11,7 +11,7 @@ module Rico
11
11
  klass = Rico.const_get(klass_name)
12
12
  return nil unless klass.respond_to?(:resolve)
13
13
 
14
- klass.resolve(robject.siblings)
14
+ klass.resolve(robject)
15
15
  end
16
16
  end
17
17
  end
data/lib/rico/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rico
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
data/rico.gemspec CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Rico::VERSION
17
17
 
18
18
  gem.add_dependency "riak-client", "~> 1.1"
19
+
20
+ gem.add_development_dependency "rake", "~> 10.0"
19
21
  gem.add_development_dependency "rspec", "~> 2.12"
20
22
  gem.add_development_dependency "guard-rspec", "~> 2.3"
21
23
  end
data/spec/rico_spec.rb CHANGED
@@ -14,13 +14,12 @@ describe Rico do
14
14
  Rico.namespace.should eql "myapp"
15
15
  end
16
16
 
17
- it "accepts a riak client instance" do
18
- riak = Riak::Client.new
17
+ it "accepts a hash of options" do
19
18
  Rico.configure do |r|
20
- r.riak = riak
19
+ r.options = { http_port: 5151 }
21
20
  end
22
21
 
23
- Rico.riak.should eql riak
22
+ Rico.options.should eql({ http_port: 5151 })
24
23
  end
25
24
  end
26
25
 
data/spec/spec_helper.rb CHANGED
@@ -10,7 +10,6 @@ module RiakHelpers
10
10
 
11
11
  def self.reset!
12
12
  Rico.namespace = "test"
13
- Rico.riak = Riak::Client.new(http_port: 8091)
14
13
 
15
14
  Riak.disable_list_keys_warnings = true
16
15
  b = Rico.bucket(bucket)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rico
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
30
46
  - !ruby/object:Gem::Dependency
31
47
  name: rspec
32
48
  requirement: !ruby/object:Gem::Requirement
@@ -68,6 +84,7 @@ extra_rdoc_files: []
68
84
  files:
69
85
  - .gitignore
70
86
  - .rspec
87
+ - .travis.yml
71
88
  - Gemfile
72
89
  - Guardfile
73
90
  - LICENSE