riak-record 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2703179ee470fd51d6e013346a4bf6c436f71b1
4
+ data.tar.gz: 456dc132da85b756d066d135180bcffb3c91218e
5
+ SHA512:
6
+ metadata.gz: 2027738c72408fa872fb5f066f5402a19bda729e3c8ed77f382ca86b811bca74212e96574f86c6359544ba1d9725cb5f77bbd562d1895abe6048c09a6f37123d
7
+ data.tar.gz: 77b06cb8f384eca3a4f9bf0d6acf3590b5455ac3b5588e712780fae4edaef2068c669ca128dac306204b6df9751020d63f46b9c21e0b87a8569bbdb54c46adab
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,14 @@
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 "rspec", "~> 3.1.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 2.0.1"
13
+ gem "simplecov", ">= 0"
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,77 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.6)
5
+ builder (3.2.2)
6
+ descendants_tracker (0.0.4)
7
+ thread_safe (~> 0.3, >= 0.3.1)
8
+ diff-lcs (1.2.5)
9
+ docile (1.1.5)
10
+ faraday (0.9.0)
11
+ multipart-post (>= 1.2, < 3)
12
+ git (1.2.8)
13
+ github_api (0.12.1)
14
+ addressable (~> 2.3)
15
+ descendants_tracker (~> 0.0.4)
16
+ faraday (~> 0.8, < 0.10)
17
+ hashie (>= 3.2)
18
+ multi_json (>= 1.7.5, < 2.0)
19
+ nokogiri (~> 1.6.3)
20
+ oauth2
21
+ hashie (3.3.1)
22
+ highline (1.6.21)
23
+ jeweler (2.0.1)
24
+ builder
25
+ bundler (>= 1.0)
26
+ git (>= 1.2.5)
27
+ github_api
28
+ highline (>= 1.6.15)
29
+ nokogiri (>= 1.5.10)
30
+ rake
31
+ rdoc
32
+ json (1.8.1)
33
+ jwt (1.0.0)
34
+ mini_portile (0.6.0)
35
+ multi_json (1.10.1)
36
+ multi_xml (0.5.5)
37
+ multipart-post (2.0.0)
38
+ nokogiri (1.6.3.1)
39
+ mini_portile (= 0.6.0)
40
+ oauth2 (1.0.0)
41
+ faraday (>= 0.8, < 0.10)
42
+ jwt (~> 1.0)
43
+ multi_json (~> 1.3)
44
+ multi_xml (~> 0.5)
45
+ rack (~> 1.2)
46
+ rack (1.5.2)
47
+ rake (10.3.2)
48
+ rdoc (3.12.2)
49
+ json (~> 1.4)
50
+ rspec (3.1.0)
51
+ rspec-core (~> 3.1.0)
52
+ rspec-expectations (~> 3.1.0)
53
+ rspec-mocks (~> 3.1.0)
54
+ rspec-core (3.1.2)
55
+ rspec-support (~> 3.1.0)
56
+ rspec-expectations (3.1.0)
57
+ diff-lcs (>= 1.2.0, < 2.0)
58
+ rspec-support (~> 3.1.0)
59
+ rspec-mocks (3.1.0)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-support (3.1.0)
62
+ simplecov (0.9.0)
63
+ docile (~> 1.1.0)
64
+ multi_json
65
+ simplecov-html (~> 0.8.0)
66
+ simplecov-html (0.8.0)
67
+ thread_safe (0.3.4)
68
+
69
+ PLATFORMS
70
+ ruby
71
+
72
+ DEPENDENCIES
73
+ bundler (~> 1.0)
74
+ jeweler (~> 2.0.1)
75
+ rdoc (~> 3.12)
76
+ rspec (~> 3.1.0)
77
+ simplecov
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Robert Graff
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.md ADDED
@@ -0,0 +1,42 @@
1
+ # riak-record
2
+
3
+ RiakRecord is a thin and immature wrapper around riak-ruby-client. It creates a bucket for
4
+ each class, provides a simple finder, and creates attribute reader.
5
+
6
+ ## Usage
7
+
8
+ ```ruby
9
+ require 'riak-record'
10
+
11
+ RiakRecord.client = Riak::Client.new
12
+
13
+ class ExampleRecord < RiakRecord
14
+ bucket_name 'example_a'
15
+ record_attributes :attribute1, :attribute2
16
+ end
17
+
18
+ ExampleRecord.find("a-key") #> Instance of ExampleRecord
19
+ ExampleRecord.find(["a-key","b-key"]) #> Array of ExampleRecords returned
20
+
21
+ record = ExampleRecord.find("a-key")
22
+ record.riak_object #> directly access Riak::RObject
23
+ record.data #> same as record.riak_object.data
24
+ record.attribute1 #> record.riak_object.data[:attribute1]
25
+ ```
26
+
27
+
28
+
29
+ ## Contributing to riak-record
30
+
31
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
32
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
33
+ * Fork the project.
34
+ * Start a feature/bugfix branch.
35
+ * Commit and push until you are happy with your contribution.
36
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
37
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
38
+
39
+ ## Copyright
40
+
41
+ Copyright (c) 2014 Robert Graff. See LICENSE.txt for
42
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "riak-record"
18
+ gem.homepage = "http://github.com/rgraff/riak-record"
19
+ gem.license = "MIT"
20
+ gem.summary = "A wrapper around ruby-client."
21
+ gem.description = "RiakRecord is a thin and immature wrapper around riak-ruby-client. It creates a bucket for
22
+ each class, provides a simple finder, and creates attribute reader."
23
+ gem.email = "robert_graff@yahoo.com"
24
+ gem.authors = ["Robert Graff"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ desc "Code coverage detail"
36
+ task :simplecov do
37
+ ENV['COVERAGE'] = "true"
38
+ Rake::Task['spec'].execute
39
+ end
40
+
41
+ task :default => :spec
42
+
43
+ require 'rdoc/task'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "riak-record #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,47 @@
1
+ class RiakRecord
2
+ attr_reader :riak_object
3
+
4
+ def initialize(riak_object)
5
+ @riak_object = riak_object
6
+ end
7
+
8
+ def data
9
+ riak_object.data
10
+ end
11
+
12
+ def self.bucket_name(name = :not_a_name)
13
+ @bucket_name = name unless name == :not_a_name
14
+ @bucket_name
15
+ end
16
+
17
+ def self.bucket
18
+ @bucket ||= riak_client.bucket(@bucket_name)
19
+ end
20
+
21
+ def self.record_attributes(*attributes)
22
+ attributes.each do |method_name|
23
+ send :define_method, method_name do
24
+ data[method_name]
25
+ end
26
+ end
27
+ end
28
+
29
+
30
+ def self.find(key_or_keys)
31
+ if key_or_keys.is_a?(Array)
32
+ bucket.get_many(key_or_keys).map{ |r| self.new(r) }
33
+ else
34
+ r = bucket.get(key_or_keys)
35
+ self.new(r) unless r.nil?
36
+ end
37
+ end
38
+
39
+ def self.client=(client)
40
+ @@client = client
41
+ end
42
+
43
+ def self.client
44
+ @@client
45
+ end
46
+
47
+ end
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: riak-record 0.0.1 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "riak-record"
9
+ s.version = "0.0.1"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Robert Graff"]
14
+ s.date = "2014-09-14"
15
+ s.description = "RiakRecord is a thin and immature wrapper around riak-ruby-client. It creates a bucket for\n each class, provides a simple finder, and creates attribute reader."
16
+ s.email = "robert_graff@yahoo.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "lib/riak-record.rb",
31
+ "riak-record.gemspec",
32
+ "spec/riak-record_spec.rb",
33
+ "spec/spec_helper.rb"
34
+ ]
35
+ s.homepage = "http://github.com/rgraff/riak-record"
36
+ s.licenses = ["MIT"]
37
+ s.rubygems_version = "2.2.1"
38
+ s.summary = "A wrapper around ruby-client."
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 4
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_development_dependency(%q<rspec>, ["~> 3.1.0"])
45
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
48
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
49
+ else
50
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
51
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
52
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
53
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
54
+ s.add_dependency(%q<simplecov>, [">= 0"])
55
+ end
56
+ else
57
+ s.add_dependency(%q<rspec>, ["~> 3.1.0"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
60
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
61
+ s.add_dependency(%q<simplecov>, [">= 0"])
62
+ end
63
+ end
64
+
@@ -0,0 +1,64 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+
4
+ class ExampleClient
5
+ end
6
+
7
+ RiakRecord.client = ExampleClient.new
8
+
9
+ class ExampleA < RiakRecord
10
+ bucket_name 'example_a'
11
+ record_attributes :attribute1, :attribute2
12
+ end
13
+
14
+ class ExampleB < RiakRecord
15
+ bucket_name 'example_b'
16
+ end
17
+
18
+ describe "RiakRecord" do
19
+ it "should set the bucket name on each instance of RiakRecord class" do
20
+ expect(ExampleA.bucket_name).to eq('example_a')
21
+ expect(ExampleB.bucket_name).to eq('example_b')
22
+ end
23
+
24
+ it "should share a client among all classes" do
25
+ expect(ExampleA.client).to_not eq(nil)
26
+ expect(ExampleA.client).to eq(ExampleB.client)
27
+ end
28
+
29
+ describe "find" do
30
+ let(:bucket){ double }
31
+ let(:array){ Array.new }
32
+ before :each do
33
+ allow(ExampleA).to receive(:bucket).and_return(bucket)
34
+ end
35
+
36
+ it "should take an array and return an array" do
37
+ expect(bucket).to receive(:get_many).with(array).and_return([])
38
+ ExampleA.find(array)
39
+ end
40
+
41
+ it "should take a string and return nil if not found" do
42
+ allow(bucket).to receive(:get).with("a-key").and_return(nil)
43
+ expect( ExampleA.find("a-key") ).to be_nil
44
+ end
45
+
46
+ it "should take a string and return an instance of Example" do
47
+ allow(bucket).to receive(:get).with("a-key").and_return(double)
48
+ expect( ExampleA.find("a-key") ).to be_an_instance_of(ExampleA)
49
+ end
50
+ end
51
+
52
+ describe "record_attributes" do
53
+ let(:riak_object) { double(:data => data) }
54
+ let(:data) { {:attribute1 => "1"} }
55
+ it "should respond to each attribute" do
56
+ expect( ExampleA.new(riak_object) ).to respond_to(:attribute1)
57
+ expect( ExampleA.new(riak_object) ).to respond_to(:attribute2)
58
+ end
59
+
60
+ it "should return attribute from riak_object data" do
61
+ expect( ExampleA.new(riak_object).attribute1 ).to eq("1")
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,29 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_profile 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
18
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
19
+
20
+ require 'rspec'
21
+ require 'riak-record'
22
+
23
+ # Requires supporting files with custom matchers and macros, etc,
24
+ # in ./support/ and its subdirectories.
25
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
26
+
27
+ RSpec.configure do |config|
28
+
29
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riak-record
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Graff
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.1.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |-
84
+ RiakRecord is a thin and immature wrapper around riak-ruby-client. It creates a bucket for
85
+ each class, provides a simple finder, and creates attribute reader.
86
+ email: robert_graff@yahoo.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ files:
93
+ - .document
94
+ - .rspec
95
+ - Gemfile
96
+ - Gemfile.lock
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - VERSION
101
+ - lib/riak-record.rb
102
+ - riak-record.gemspec
103
+ - spec/riak-record_spec.rb
104
+ - spec/spec_helper.rb
105
+ homepage: http://github.com/rgraff/riak-record
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.2.1
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: A wrapper around ruby-client.
129
+ test_files: []