Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 966ff6bc9fb672b45f58aff45c97e4bd00489cb9 @cndreisbach cndreisbach committed Oct 1, 2012
Showing with 182 additions and 0 deletions.
  1. +17 −0 .gitignore
  2. +4 −0 Gemfile
  3. +22 −0 LICENSE.txt
  4. +111 −0 README.md
  5. +1 −0 Rakefile
  6. +19 −0 diametric.gemspec
  7. +5 −0 lib/diametric.rb
  8. +3 −0 lib/diametric/version.rb
@@ -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
@@ -0,0 +1,4 @@
+source 'https://rubygems.org'
+
+# Specify your gem's dependencies in diametric.gemspec
+gemspec
@@ -0,0 +1,22 @@
+Copyright (c) 2012 Clinton N. Dreisbach
+
+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.
111 README.md
@@ -0,0 +1,111 @@
+# Diametric
+
+Diametric is a library for building schemas, queries, and transactions for
+[Datomic][] from Ruby objects.
+
+Currently, Diametric does not contain the logic for communicating with Datomic,
+only for creating the schema, queries, and transactions.
+
+## Usage
+
+```ruby
+class Person
+ include Diametric
+
+ attribute :name, String, :index => true
+ attribute :email, String, :cardinality => :many
+ attribute :birthday, DateTime
+ attribute :iq, Integer
+ attribute :website, URI
+end
+
+Person.schema
+# Datomic transaction:
+# [{:db/id #db/id[:db.part/db]
+# :db/ident :person/name
+# :db/valueType :db.type/string
+# :db/cardinality :db.cardinality/one
+# :db/index true
+# :db.install/_attribute :db.part/db}
+# {:db/id #db/id[:db.part/db]
+# :db/ident :person/email
+# :db/valueType :db.type/string
+# :db/cardinality :db.cardinality/many
+# :db.install/_attribute :db.part/db}
+# {:db/id #db/id[:db.part/db]
+# :db/ident :person/birthday
+# :db/valueType :db.type/instant
+# :db/cardinality :db.cardinality/one
+# :db.install/_attribute :db.part/db}
+# {:db/id #db/id[:db.part/db]
+# :db/ident :person/iq
+# :db/valueType :db.type/long
+# :db/cardinality :db.cardinality/one
+# :db.install/_attribute :db.part/db}
+# {:db/id #db/id[:db.part/db]
+# :db/ident :person/website
+# :db/valueType :db.type/uri
+# :db/cardinality :db.cardinality/one
+# :db.install/_attribute :db.part/db}]
+
+Person.query(:name => "Clinton Dreisbach")
+# Datomic query:
+# [:find ?e ?name ?email ?birthday ?iq ?website
+# :from $ ?name
+# :where [?e :person/name ?name]
+# [?e :person/email ?email]
+# [?e :person/birthday ?birthday]
+# [?e :person/iq ?iq]
+# [?e :person/website ?website]]
+# Options:
+# :args => ["Clinton Dreisbach"]
+#
+# Returns as an array, [query, options].
+
+Person.attrs
+# [:dbid, :name, :email, :birthday, :iq, :website]
+
+person = Person.new(Hash[*(Person.attrs.zip(results_from_query).flatten)])
+# or
+person = Person.from_query(results_from_query)
+
+person.clean # Sets all attributes as unchanged.
+person.iq = 180
+person.transact
+# Datomic transaction:
+# [{:db/id person.dbid
+# :person/iq 180}]
+
+person = Person.new(:name => "Peanut")
+person.transact
+# Datomic transaction:
+# [{:db/id #db/id[:db.part/user]
+# :person/name "Peanut"}]
+```
+
+
+## Installation
+
+Add this line to your application's Gemfile:
+
+ gem 'diametric'
+
+And then execute:
+
+ $ bundle
+
+Or install it yourself as:
+
+ $ gem install diametric
+
+## 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 'Add some feature'`)
+4. Push to the branch (`git push origin my-new-feature`)
+5. Create new Pull Request
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
+# -*- encoding: utf-8 -*-
+lib = File.expand_path('../lib', __FILE__)
+$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
+require 'diametric/version'
+
+Gem::Specification.new do |gem|
+ gem.name = "diametric"
+ gem.version = Diametric::VERSION
+ gem.authors = ["Clinton N. Dreisbach"]
+ gem.email = ["crnixon@gmail.com"]
+ gem.description = %q{TODO: Write a gem description}
+ gem.summary = %q{TODO: Write a gem summary}
+ gem.homepage = ""
+
+ 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.require_paths = ["lib"]
+end
@@ -0,0 +1,5 @@
+require "diametric/version"
+
+module Diametric
+ # Your code goes here...
+end
@@ -0,0 +1,3 @@
+module Diametric
+ VERSION = "0.0.1"
+end

0 comments on commit 966ff6b

Please sign in to comment.