Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit dc75eaaf2d024400d8436cf848eaebe459fa2005 @scalabl3 committed Oct 31, 2012
Showing with 135 additions and 0 deletions.
  1. +17 −0 .gitignore
  2. +4 −0 Gemfile
  3. +22 −0 LICENSE
  4. +31 −0 README.md
  5. +2 −0 Rakefile
  6. +23 −0 couchbase_patterns.gemspec
  7. +33 −0 lib/couchbase_patterns.rb
  8. +3 −0 lib/couchbase_patterns/version.rb
17 .gitignore
@@ -0,0 +1,17 @@
+*.gem
+*.rbc
+.bundle
+.config
+.yardoc
+Gemfile.lock
+InstalledFiles
+_yardoc
+coverage
+doc/
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
4 Gemfile
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in couchbase_patterns.gemspec
+gemspec
22 LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Jasdeep Jaitla
+
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 README.md
@@ -0,0 +1,31 @@
+# This is a new gem and currently under initial development
+
+# CouchbasePatterns
+
+ActiveRecord-like Design Patterns for Couchbase modeling, based on KV patterns at CouchbaseModels.com
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem 'couchbase-patterns'
+
+And then execute:
+
+ $ bundle
+
+Or install it yourself as:
+
+ $ gem install couchbase-patterns
+
+## Usage
+
+TODO: Write usage instructions here
+
+## Contributing
+
+1. Fork it
+2. Create your feature branch (`git checkout -b my-new-feature`)
+3. Commit your changes (`git commit -am 'Added some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
2 Rakefile
@@ -0,0 +1,2 @@
+#!/usr/bin/env rake
+require "bundler/gem_tasks"
23 couchbase_patterns.gemspec
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/couchbase_patterns/version', __FILE__)
+
+Gem::Specification.new do |gem|
+
+ gem.authors = ["Jasdeep Jaitla"]
+ gem.email = ["jasdeep@scalabl3.com"]
+ gem.description = %q{ActiveRecord-like Design Patterns and Other Design Patterns for Modeling with Couchbase}
+ gem.summary = %q{CouchbasePatterns employs KV patterns that can be found on CouchbaseModels.com as a convenience. This is an experimental gem at this point!}
+ gem.homepage = "https://github.com/scalabl3/couchbase-patterns"
+
+ gem.add_dependency('couchbase-docstore', '>= 0.1.0')
+ gem.add_dependency('couchbase-settings', '>= 0.1.0')
+ gem.add_dependency('couchbase', '>= 1.2.0.z.beta3')
+
+ gem.files = `git ls-files`.split($\)
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
+ gem.name = "couchbase-patterns"
+ gem.require_paths = ["lib"]
+ gem.version = CouchbasePatterns::VERSION
+
+end
33 lib/couchbase_patterns.rb
@@ -0,0 +1,33 @@
+require "couchbase_settings"
+require "couchbase_doc_store"
+require "couchbase_patterns/version"
+
+# active record verbs
+
+ # has_one
+ # 1..1 relationship between this object-document and another object-document
+ # coupled with belongs_to Company has_one :office, Office belongs_to Company
+
+ # has_many
+ # 1..n relationship between source object-document and another set of object-documents
+ # coupled with belongs_to Company has_many :employees, Employee belongs_to Company
+
+ # belongs_to
+ # has a foreign key to another object-document (coupled with has_one/has_many)
+
+ # has_and_belongs_to_many :categories
+
+module CouchbasePatterns
+ # symbol-attributes to separate out as find_by methods,
+ # lookup attribute values MUST BE UNIQUE (i.e. email, phone number, uid, social network id, social security number, etc.)
+ def lookup_by(*attributes)
+ attributes.each do |a|
+ puts a
+ self.class.class_eval %Q{
+ def find_by_#{a} (&block)
+ yield(self) if block_given?
+ end
+ }
+ end # attributes.each
+ end # lookup_by
+end
3 lib/couchbase_patterns/version.rb
@@ -0,0 +1,3 @@
+module CouchbasePatterns
+ VERSION = "0.0.3"
+end

0 comments on commit dc75eaa

Please sign in to comment.